{"record":{"id":"237a613bdfb8d9cf","repo":"kubernetes/kops","slug":"unable-to-find-region","errorCode":null,"errorMessage":"unable to find region","messagePattern":"unable to find region","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/nodeidentity/openstack/identify.go","lineNumber":59,"sourceCode":")\n\n// nodeIdentifier identifies a node\ntype nodeIdentifier struct {\n\tnovaClient   *gophercloud.ServiceClient\n\tcache        expirationcache.Store\n\tcacheEnabled bool\n}\n\n// New creates and returns a nodeidentity.Identifier for Nodes running on OpenStack\nfunc New(cacheNodeidentityInfo bool) (nodeidentity.Identifier, error) {\n\tenv, err := openstack.AuthOptionsFromEnv()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tregion := os.Getenv(\"OS_REGION_NAME\")\n\tif region == \"\" {\n\t\treturn nil, fmt.Errorf(\"unable to find region\")\n\t}\n\n\tprovider, err := openstack.NewClient(env.IdentityEndpoint)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tua := gophercloud.UserAgent{}\n\tua.Prepend(\"kops/nodeidentity\")\n\tprovider.UserAgent = ua\n\tklog.V(4).Infof(\"Using user-agent %s\", ua.Join())\n\n\t// node-controller should be able to renew it tokens against OpenStack API\n\tenv.AllowReauth = true\n\n\terr = openstack.Authenticate(context.TODO(), provider, env)\n\tif err != nil {\n\t\treturn nil, err\n\t}","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/nodeidentity/openstack/identify.go#L41-L77","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\n# openrc.sh missing OS_REGION_NAME\n// after\nexport OS_REGION_NAME=\"RegionOne\"","handlingStrategy":"validation","validationCode":"if os.Getenv(\"OS_REGION_NAME\") == \"\" {\n    return fmt.Errorf(\"OS_REGION_NAME must be set before initializing the openstack nodeidentifier\")\n}","typeGuard":null,"tryCatchPattern":"identifier, err := openstack.New()\nif err != nil && strings.Contains(err.Error(), \"unable to find region\") {\n    return fmt.Errorf(\"openstack nodeidentifier init failed: set OS_REGION_NAME (openrc): %w\", err)\n}","preventionTips":["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"],"tags":["openstack","node-identity","environment","region"],"backgroundTag":"missing-env-var","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}