{"record":{"id":"58365244a82da98e","repo":"kubernetes/kops","slug":"error-deleting-instance-s","errorCode":null,"errorMessage":"error deleting instance: %s","messagePattern":"error deleting instance: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/openstack/instance.go","lineNumber":199,"sourceCode":"}\n\nfunc (c *openstackCloud) DeleteInstance(i *cloudinstances.CloudInstance) error {\n\treturn deleteInstance(c, i)\n}\n\nfunc deleteInstance(c OpenstackCloud, i *cloudinstances.CloudInstance) error {\n\treturn deleteInstanceWithID(c, i.ID)\n}\n\nfunc (c *openstackCloud) DeleteInstanceWithID(instanceID string) error {\n\treturn deleteInstanceWithID(c, instanceID)\n}\n\nfunc deleteInstanceWithID(c OpenstackCloud, instanceID string) error {\n\tdone, err := vfs.RetryWithBackoff(deleteBackoff, func() (bool, error) {\n\t\terr := servers.Delete(context.TODO(), c.ComputeClient(), instanceID).ExtractErr()\n\t\tif err != nil && !isNotFound(err) {\n\t\t\treturn false, fmt.Errorf(\"error deleting instance: %s\", err)\n\t\t}\n\t\tif isNotFound(err) {\n\t\t\treturn true, nil\n\t\t}\n\t\treturn false, nil\n\t})\n\tif err != nil {\n\t\treturn err\n\t} else if done {\n\t\treturn nil\n\t} else {\n\t\treturn wait.ErrWaitTimeout\n\t}\n}\n\n// DeregisterInstance drains a cloud instance and loadbalancers.\nfunc (c *openstackCloud) DeregisterInstance(i *cloudinstances.CloudInstance) error {\n\treturn deregisterInstance(c, i.ID)","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/openstack/instance.go#L181-L217","documentation":"This error is returned by deleteInstanceWithID when the Openstack Nova servers.Delete API call fails with any error other than 404 Not Found. It is wrapped in vfs.RetryWithBackoff, so the delete is retried with backoff until it succeeds, is not found, or the backoff window expires (in which case the last error is surfaced wrapped in this message).","triggerScenarios":"servers.Delete returns a non-NotFound error: the compute endpoint is unreachable, authentication token expired, the instance is in a state that forbids deletion (e.g. BUILD, vm_state ERROR), or a 409/412/500 is returned by Nova.","commonSituations":"Keystone token expiry mid-operation; deleting an instance that is still being provisioned; OpenStack API outage or nova-compute failure; network partition between kops controller and the OpenStack cloud.","solutions":["Check the wrapped %s message for the underlying Nova error (401/409/500) and fix that root cause first","Verify the instance state with `openstack server show <id>`; wait for it to leave BUILD/ERROR state or force-delete it manually","Re-authenticate / refresh credentials; confirm OS_* environment or cloud config is valid and not expired","If retries exhausted, delete the instance manually via CLI and re-run the kops operation"],"exampleFix":"// before: fail hard on transient delete errors\nerr := servers.Delete(context.TODO(), c.ComputeClient(), instanceID).ExtractErr()\nif err != nil {\n    return false, fmt.Errorf(\"error deleting instance: %s\", err)\n}\n// after: tolerate 409 instance-already-being-deleted as success\nerr := servers.Delete(context.TODO(), c.ComputeClient(), instanceID).ExtractErr()\nif err != nil && !isNotFound(err) {\n    if _, ok := err.(gophercloud.ErrDefault409); ok {\n        return false, nil // retry, instance is being torn down\n    }\n    return false, fmt.Errorf(\"error deleting instance: %s\", err)\n}","handlingStrategy":"retry","validationCode":"// check instance exists and is in a deletable state before calling delete\nserver, err := cloud.GetInstance(instanceID)\nif err != nil { return err }\nif server.Status == \"DELETING\" { return nil } // already going away","typeGuard":null,"tryCatchPattern":"// retry with backoff around the kops delete path\nbackoff := wait.Backoff{Duration: 5 * time.Second, Factor: 2, Steps: 5}\nerr := wait.ExponentialBackoff(backoff, func() (bool, error) {\n    err := cloud.DeleteInstance(inst)\n    if err != nil && strings.Contains(err.Error(), \"error deleting instance\") {\n        return false, nil // transient; retry\n    }\n    return err == nil, err\n})","preventionTips":["Inspect the underlying Nova error string before assuming the delete failed permanently","Ensure instances are ACTIVE before deleting; BUILD/ERROR states often reject deletion","Keep credentials fresh; use expiring-token-aware clients","Delete via kops rather than out-of-band so state stays consistent"],"tags":["openstack","nova","instance-deletion","retry"],"backgroundTag":"openstack-api-call-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"}