kubernetes/kops · error

unable to find region

Error message

unable to find region

What it means

Thrown by NewOpenstackVerifier when the OS_REGION_NAME environment variable is unset or empty. The verifier needs the region to build region-scoped Nova (compute V2) endpoints; without it, client construction cannot proceed, so it fails fast before contacting OpenStack.

Source

Thrown at upup/pkg/fi/cloudup/openstack/verifier.go:61

type OpenStackVerifierOptions struct {
}

type openstackVerifier struct {
	novaClient *gophercloud.ServiceClient
	kubeClient *kubernetes.Clientset
}

var _ bootstrap.Verifier = (*openstackVerifier)(nil)

func NewOpenstackVerifier(opt *OpenStackVerifierOptions) (bootstrap.Verifier, error) {
	env, err := gos.AuthOptionsFromEnv()
	if err != nil {
		return nil, err
	}

	region := os.Getenv("OS_REGION_NAME")
	if region == "" {
		return nil, fmt.Errorf("unable to find region")
	}

	provider, err := gos.NewClient(env.IdentityEndpoint)
	if err != nil {
		return nil, err
	}
	ua := gophercloud.UserAgent{}
	ua.Prepend("kops/kopscontrollerverifier")
	provider.UserAgent = ua
	klog.V(4).Infof("Using user-agent %s", ua.Join())

	// node-controller should be able to renew it tokens against OpenStack API
	env.AllowReauth = true

	err = gos.Authenticate(context.TODO(), provider, env)
	if err != nil {
		return nil, err
	}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Export the region before running: `export OS_REGION_NAME=<region>` (find it via `openstack region list`).
  2. Re-source the correct OpenStack RC file that includes OS_REGION_NAME.
  3. If using CI/scripts, add OS_REGION_NAME alongside the other OS_* variables.

Example fix

// before
./kops-verifier ...  # fails: unable to find region
// after
export OS_REGION_NAME=$(openstack region list -f value -c Region | head -1)
./kops-verifier ...
Defensive patterns

Strategy: validation

Validate before calling

region := os.Getenv("OS_REGION_NAME")
if region == "" {
    return errors.New("OS_REGION_NAME must be set; source your openrc file")
}

Try / catch

verifier, err := NewOpenstackVerifier(ctx, buildEnv, cluster, kubeClientConfig)
if err != nil {
    log.Fatalf("verifier init: %v (did you source openrc?)", err)
}

Prevention

When it happens

Trigger: Running the kops verifier binary (via main) after openstack credential env loading, where OS_REGION_NAME is missing — not set in the shell, absent from the sourced RC file, or not injected in CI.

Common situations: Forgetting to source the OpenStack RC (openrc) file that sets OS_REGION_NAME; clouds.yaml-based auth that doesn't export a region; CI environments with partial OS_* credential injection; region renamed by the cloud operator.

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/a96f836b238406e1. Report an issue: GitHub.