{"record":{"id":"faebb230dbfe7d26","repo":"kubernetes/kops","slug":"could-not-delete-instance-s-v","errorCode":null,"errorMessage":"Could not delete instance %s: %v","messagePattern":"Could not delete instance (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/openstacktasks/servergroup.go","lineNumber":197,"sourceCode":"\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmetadataName := \"\"\n\t\t\t\t\t\tval, ok = server.Metadata[openstack.TagKopsName]\n\t\t\t\t\t\tif ok {\n\t\t\t\t\t\t\tmetadataName = val\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// name or metadata tag should match to instance name\n\t\t\t\t\t\t// this is needed for backwards compatibility\n\t\t\t\t\t\tif server.Name == instanceName || metadataName == instanceName {\n\t\t\t\t\t\t\tinstances = append(instances, server)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif len(instances) == 1 {\n\t\t\t\t\t\tklog.V(2).Infof(\"Openstack task ServerGroup scaling down instance %s\", instanceName)\n\t\t\t\t\t\terr := t.Cloud.DeleteInstanceWithID(instances[0].ID)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn fmt.Errorf(\"Could not delete instance %s: %v\", instanceName, err)\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn fmt.Errorf(\"found %d instances with name: %s\", len(instances), instanceName)\n\t\t\t\t\t}\n\t\t\t\t\tcurrentLastIndex -= 1\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t}\n\n\tklog.V(2).Infof(\"Openstack task ServerGroup::RenderOpenstack did nothing\")\n\treturn nil\n}\n","sourceCodeStart":179,"sourceCodeEnd":212,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/openstacktasks/servergroup.go#L179-L212","documentation":"RenderOpenstack returns this when deleting a single instance during ServerGroup scale-down fails: t.Cloud.DeleteInstanceWithID(instances[0].ID) returned an error. The instance name is included in the message and the underlying OpenStack error is wrapped via %v, so the root cause (403, 404, 409, etc.) is in the wrapped text.","triggerScenarios":"Scale-down path where exactly one matching instance was found and DeleteInstanceWithID fails: e.g. instance already deleted (404), project lacks rights on the instance (403), instance in a transitional state refusing delete (409), or Nova API/network error.","commonSituations":"A concurrent process (autoscaler, another kops apply) already removed the instance; cloud quota/RBAC policy change blocked deletion; the instance is stuck in an error/deleting state; a bare-metal or sheltered instance requiring a different delete flow.","solutions":["Read the wrapped Nova error in the message: for 404 the instance is already gone — re-run 'kops update cluster' to converge.","Check the instance state with 'openstack server show <id>' and force-delete if stuck ('openstack server delete --force' or wait for state to settle).","Verify the credentials/tenant own the instance (403 → RBAC/project mismatch).","Re-run kops apply; the cloud client has no delete retry, so transient failures need a retry."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Check the instance is in a deletable state before scaling down\nopenstack server show <instance-id> -f value -c status  # expect ACTIVE/SHUTOFF, not BUILDING/DELETING","typeGuard":null,"tryCatchPattern":"// Distinguish already-gone (404) from real failures\nerr := cloud.DeleteInstanceWithID(id)\nif err != nil {\n    if isNotFound(err) { klog.Info(\"instance already deleted; continuing\") } else { return err }\n}","preventionTips":["Avoid concurrent autoscaler + kops scale-down on the same group.","Ensure the OpenStack credentials own the instances (same project) before scaling.","Re-run kops update after transient failures to converge.","Force-delete instances stuck in error/deleting states before applying."],"tags":["openstack","nova","instance-deletion","cloud-api"],"backgroundTag":"openstack-instance-delete-failed","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}