kubernetes/kops · error
unable to find region
Error message
unable to find region
What it means
New() for the OpenStack nodeidentifier reads the region from the OS_REGION_NAME environment variable and fails if it is empty. The region is required to build region-scoped OpenStack service clients (nova).
Source
Thrown at pkg/nodeidentity/openstack/identify.go:59
)
// nodeIdentifier identifies a node
type nodeIdentifier struct {
novaClient *gophercloud.ServiceClient
cache expirationcache.Store
cacheEnabled bool
}
// New creates and returns a nodeidentity.Identifier for Nodes running on OpenStack
func New(cacheNodeidentityInfo bool) (nodeidentity.Identifier, error) {
env, err := openstack.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 := openstack.NewClient(env.IdentityEndpoint)
if err != nil {
return nil, err
}
ua := gophercloud.UserAgent{}
ua.Prepend("kops/nodeidentity")
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 = openstack.Authenticate(context.TODO(), provider, env)
if err != nil {
return nil, err
}View on GitHub (pinned to 4c8573c808)
Solutions
- Export OS_REGION_NAME in the environment (e.g. 'export OS_REGION_NAME=RegionOne') before starting the process
- Source the full openrc file that includes OS_REGION_NAME, not just the auth subset
- If using clouds.yaml, set the region_name in the cloud profile and ensure the env reflects it
Example fix
// before # openrc.sh missing OS_REGION_NAME // after export OS_REGION_NAME="RegionOne"
Defensive patterns
Strategy: validation
Validate before calling
if os.Getenv("OS_REGION_NAME") == "" {
return fmt.Errorf("OS_REGION_NAME must be set before initializing the openstack nodeidentifier")
} Try / catch
identifier, err := openstack.New()
if err != nil && strings.Contains(err.Error(), "unable to find region") {
return fmt.Errorf("openstack nodeidentifier init failed: set OS_REGION_NAME (openrc): %w", err)
} Prevention
- Source the complete openrc file (including OS_REGION_NAME) in deployment manifests/entrypoints
- Add a startup preflight that asserts required OS_* env vars are present
- When using clouds.yaml, mirror region_name into OS_REGION_NAME for components that read it
When it happens
Trigger: Constructing the OpenStack nodeidentifier (nodeidentity/openstack.New) in an environment where OS_REGION_NAME is unset or empty string, even though other OS_* auth variables are set.
Common situations: OpenStack credentials sourced from openrc files that omit OS_REGION_NAME, running in containers/pods where only auth env vars were copied, or clouds.yaml-based auth setups where region was expected elsewhere.
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
- unable to find region
- region not provided in OS_REGION_NAME or openstack config se
- error building nova client: %v
- providerID was not set for node %s
- providerID %q not recognized for node %s
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/237a613bdfb8d9cf.
Report an issue: GitHub.