kubernetes/kops · error

error building swift client: %v

Error message

error building swift client: %v

What it means

NewSwiftClient finally creates the Object Storage v1 service client via openstack.NewObjectStorageV1(pc, endpointOpt). This fails when the endpoint options are incomplete (missing region) or the Swift service cannot be resolved from the catalog, producing this wrapped error.

Source

Thrown at util/pkg/vfs/swiftfs.go:95

	}

	var endpointOpt gophercloud.EndpointOpts
	if region, err := config.GetRegion(); err != nil {
		klog.Warningf("Retrieving swift configuration from openstack config file: %v", err)
		endpointOpt, err = config.GetServiceConfig("Swift")
		if err != nil {
			return nil, err
		}
	} else {
		endpointOpt = gophercloud.EndpointOpts{
			Type:   "object-store",
			Region: region,
		}
	}

	client, err := openstack.NewObjectStorageV1(pc, endpointOpt)
	if err != nil {
		return nil, fmt.Errorf("error building swift client: %v", err)
	}
	return client, nil
}

type OpenstackConfig struct{}

func (OpenstackConfig) filename() (string, error) {
	name := os.Getenv("OPENSTACK_CREDENTIAL_FILE")
	if name != "" {
		klog.V(2).Infof("using openstack config found in $OPENSTACK_CREDENTIAL_FILE: %s", name)
		return name, nil
	}

	homeDir := homedir.HomeDir()
	if homeDir == "" {
		return "", fmt.Errorf("can not find home directory")
	}
	f := filepath.Join(homeDir, ".openstack", "config")

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Set OS_REGION_NAME to the region hosting your Swift service.
  2. Add 'region = <region>' to the [Global] section of ~/.openstack/config.
  3. Verify the object-store service exists: openstack service list | grep object-store and openstack endpoint list.
  4. Check GetServiceConfig('Swift') section in the config file provides a valid region/URL.

Example fix

// before (~/.openstack/config)
[Global]
; region missing
// after
[Global]
region = RegionOne
Defensive patterns

Strategy: validation

Validate before calling

// Ensure a region is available before building the swift client
if os.Getenv("OS_REGION_NAME") == "" {
	return errors.New("set OS_REGION_NAME or region in [Global] config section")
}

Prevention

When it happens

Trigger: getSwiftClient -> NewSwiftClient when the region could not be determined (GetRegion warned and GetServiceConfig('Swift') also failed, yielding a zero endpointOpt) or the Keystone catalog lacks a Swift/object-store entry for the region.

Common situations: OS_REGION_NAME unset and no [Global] region in the openstack config, a deployment without object-store service in the catalog, or misnamed service in the catalog for the requested region.

Related errors


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/a26cfea65a1d401c. Report an issue: GitHub.