kubernetes/kops · error

region not provided in OS_REGION_NAME or openstack config se

Error message

region not provided in OS_REGION_NAME or openstack config section GLOBAL

What it means

OpenstackConfig.GetRegion determines the Swift region: first from the OS_REGION_NAME env var, otherwise from the 'region' key of the Global section of the openstack config. When neither is available (getSection fails or the values are missing), it returns this descriptive error instead of wrapping the underlying cause.

Source

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

	return false
}

func (oc OpenstackConfig) GetRegion() (string, error) {
	var region string
	if region = os.Getenv("OS_REGION_NAME"); region != "" {
		if len(region) > 1 {
			if region[0] == '\'' && region[len(region)-1] == '\'' {
				region = region[1 : len(region)-1]
			}
		}
		return region, nil
	}

	items := []string{"region"}
	// TODO: Unsure if this is the correct section for region
	values, err := oc.getSection("Global", items)
	if err != nil {
		return "", fmt.Errorf("region not provided in OS_REGION_NAME or openstack config section GLOBAL")
	}
	return values["region"], nil
}

func (oc OpenstackConfig) getCredentialFromFile() (gophercloud.AuthOptions, error) {
	opt := gophercloud.AuthOptions{}
	name := "Default"
	items := []string{"identity", "user", "user_id", "password", "domain_id", "domain_name", "tenant_id", "tenant_name"}
	values, err := oc.getSection(name, items)
	if err != nil {
		return opt, err
	}

	for _, c1 := range []string{"identity", "password"} {
		if values[c1] == "" {
			return opt, fmt.Errorf("missing %s in section of %s", c1, name)
		}
	}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. export OS_REGION_NAME=<your-region> in the environment.
  2. Add region = <your-region> under the [Global] section of ~/.openstack/config (or OPENSTACK_CREDENTIAL_FILE).
  3. Find your region with: openstack endpoint list and use the region of the object-store endpoint.
  4. If running in CI, add OS_REGION_NAME to the job's secret/env configuration.

Example fix

// before
[Global]
// after
[Global]
region = RegionOne
Defensive patterns

Strategy: validation

Validate before calling

// Ensure a region is resolvable before running openstack-backed kops
if os.Getenv("OS_REGION_NAME") == "" {
	if _, err := ini.Load("~/.openstack/config"); err == nil {
		// still verify [Global].region exists
		_ = err
	}
	return errors.New("export OS_REGION_NAME or set region in [Global]")
}

Prevention

When it happens

Trigger: newDesignate, NewOpenstackCloud, or NewSwiftClient -> GetRegion when OS_REGION_NAME is unset/empty AND the [Global] section is absent or has no 'region' key in the config file.

Common situations: Partially populated clouds.yaml-style files copied from other tools, environments where only OS_AUTH_URL/credentials were exported but not the region, multi-region deployments where the user forgot to pick one.

Related errors


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