kubernetes/kops · error

error finding openstack region: %v

Error message

error finding openstack region: %v

What it means

NewOpenstackCloud (upup/pkg/fi/cloudup/openstack/cloud.go:331) resolves the OpenStack region from the environment/config via vfs.OpenstackConfig.GetRegion() before creating the cloud provider. If the region cannot be determined, construction fails with this wrapped error. kOps needs the region to key its cloud-instance cache and to build every service client's EndpointOpts.

Source

Thrown at upup/pkg/fi/cloudup/openstack/cloud.go:331

	floatingSubnet  *string
	tags            map[string]string
	region          string
	useOctavia      bool
	zones           []string
	floatingEnabled bool
	useVIPACL       *bool
}

var _ fi.Cloud = (*openstackCloud)(nil)

var openstackCloudInstances = make(map[string]OpenstackCloud)

func NewOpenstackCloud(cluster *kops.Cluster, uagent string) (OpenstackCloud, error) {
	config := vfs.OpenstackConfig{}

	region, err := config.GetRegion()
	if err != nil {
		return nil, fmt.Errorf("error finding openstack region: %v", err)
	}

	raw := openstackCloudInstances[region]
	if raw != nil {
		return raw, nil
	}

	authOption, err := config.GetCredential()
	if err != nil {
		return nil, err
	}

	provider, err := openstack.NewClient(authOption.IdentityEndpoint)
	if err != nil {
		return nil, fmt.Errorf("error building openstack provider client: %v", err)
	}
	ua := gophercloud.UserAgent{}
	ua.Prepend(fmt.Sprintf("kops/%s", uagent))

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Export OS_REGION_NAME in your environment or add region to the OpenStack config used by kops
  2. Source a complete openrc file: source openrc.sh and verify with `openstack region list` that the region exists
  3. Re-run kops after verifying `echo $OS_REGION_NAME` prints the intended region

Example fix

// before
export OS_USERNAME=admin
export OS_PASSWORD=secret
# OS_REGION_NAME missing
// after
export OS_USERNAME=admin
export OS_PASSWORD=secret
export OS_REGION_NAME=RegionOne
Defensive patterns

Strategy: validation

Validate before calling

region := os.Getenv("OS_REGION_NAME")
if region == "" {
    return fmt.Errorf("OS_REGION_NAME must be set before calling NewOpenstackCloud")
}
if err := verifyRegionExists(region); err != nil {
    return err
}
return nil

Prevention

When it happens

Trigger: GetRegion() fails because OS_REGION_NAME is unset and no region can be inferred from the auth config, or the configured region value is empty/invalid per the config parser.

Common situations: Partial OpenStack credential export (OS_USERNAME/OS_PASSWORD set but OS_REGION_NAME forgotten); credentials file missing the region field; CI environments sourcing an incomplete openrc file; using application credentials without a region hint.

Understand the failure class

Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.

Related errors


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