{"record":{"id":"65645ba488858267","repo":"kubernetes/kops","slug":"could-not-delete-instance-q-v","errorCode":null,"errorMessage":"could not delete instance %q: %v","messagePattern":"could not delete instance %q: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/openstack/cloud.go","lineNumber":661,"sourceCode":"\tcluster := g.Raw.(*kops.Cluster)\n\tallInstances, err := c.ListInstances(servers.ListOpts{\n\t\tName: fmt.Sprintf(\"^%s\", g.InstanceGroup.Name),\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tinstances := []servers.Server{}\n\tfor _, instance := range allInstances {\n\t\tif !InstanceInClusterAndIG(instance, cluster.Name, g.InstanceGroup.Name) {\n\t\t\tcontinue\n\t\t}\n\t\tinstances = append(instances, instance)\n\t}\n\tfor _, instance := range instances {\n\t\terr := c.DeleteInstanceWithID(instance.ID)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"could not delete instance %q: %v\", instance.ID, err)\n\t\t}\n\t}\n\n\terr = deletePorts(c, g.InstanceGroup.Name, cluster.Name)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tsgName := g.InstanceGroup.Name\n\tif name, ok := g.InstanceGroup.Annotations[OS_ANNOTATION+SERVER_GROUP_NAME]; ok {\n\t\tsgName = name\n\t}\n\tsgs, err := c.ListServerGroups(servergroups.ListOpts{})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not list server groups %v\", err)\n\t}\n\n\tfor _, sg := range sgs {","sourceCodeStart":643,"sourceCodeEnd":679,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/openstack/cloud.go#L643-L679","documentation":"Wrapped error returned when deleting a Nova server (instance) by ID fails while tearing down an OpenStack instance group. kOps lists the group's instances and calls DeleteInstanceWithID for each; any per-instance failure aborts the group deletion.","triggerScenarios":"DeleteInstanceWithID(instance.ID) returns an error from the Nova API, typically 404 (instance already terminated), 409 (instance in transitional task state), or auth/endpoint failure.","commonSituations":"Instance previously deleted manually or by autoscaler; server stuck in DELETING/REBUILDING state so Nova returns 409; expired OpenStack token; wrong project credentials so the instance is not visible.","solutions":["Inspect the wrapped error: 404 means the instance is gone, re-run delete to continue","If 409, wait for the server to leave its task state then retry","Check `openstack server show <id>` to confirm state and project ownership","Verify credentials (OS_USERNAME/OS_PROJECT_NAME) target the correct project"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"srv, err := c.GetInstance(instance.ID)\nif err != nil { /* skip: already gone */ }\nif srv.Status == \"DELETING\" || srv.TaskState != \"\" { wait }","typeGuard":null,"tryCatchPattern":"if err := c.DeleteInstanceWithID(instance.ID); err != nil {\n    var gErr gophercloud.ErrUnexpectedResponseCode\n    if errors.As(err, &gErr) && gErr.Actual == 404 { continue }\n    return fmt.Errorf(\"could not delete instance %q: %v\", instance.ID, err)\n}","preventionTips":["Wait for servers to leave transitional task states before deleting","Avoid overlapping delete operations on the same group","Confirm project credentials match the instance owner"],"tags":["openstack","nova","instance-deletion","teardown"],"backgroundTag":"openstack-resource-deletion-failed","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"}