kubernetes/kops · error
could not delete instance %q: %v
Error message
could not delete instance %q: %v
What it means
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.
Source
Thrown at upup/pkg/fi/cloudup/openstack/cloud.go:661
cluster := g.Raw.(*kops.Cluster)
allInstances, err := c.ListInstances(servers.ListOpts{
Name: fmt.Sprintf("^%s", g.InstanceGroup.Name),
})
if err != nil {
return err
}
instances := []servers.Server{}
for _, instance := range allInstances {
if !InstanceInClusterAndIG(instance, cluster.Name, g.InstanceGroup.Name) {
continue
}
instances = append(instances, instance)
}
for _, instance := range instances {
err := c.DeleteInstanceWithID(instance.ID)
if err != nil {
return fmt.Errorf("could not delete instance %q: %v", instance.ID, err)
}
}
err = deletePorts(c, g.InstanceGroup.Name, cluster.Name)
if err != nil {
return err
}
sgName := g.InstanceGroup.Name
if name, ok := g.InstanceGroup.Annotations[OS_ANNOTATION+SERVER_GROUP_NAME]; ok {
sgName = name
}
sgs, err := c.ListServerGroups(servergroups.ListOpts{})
if err != nil {
return fmt.Errorf("could not list server groups %v", err)
}
for _, sg := range sgs {View on GitHub (pinned to 4c8573c808)
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
Defensive patterns
Strategy: retry
Validate before calling
srv, err := c.GetInstance(instance.ID)
if err != nil { /* skip: already gone */ }
if srv.Status == "DELETING" || srv.TaskState != "" { wait } Try / catch
if err := c.DeleteInstanceWithID(instance.ID); err != nil {
var gErr gophercloud.ErrUnexpectedResponseCode
if errors.As(err, &gErr) && gErr.Actual == 404 { continue }
return fmt.Errorf("could not delete instance %q: %v", instance.ID, err)
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- could not delete server group %q: %v
- error deleting instance: %s
- Could not delete instance %s: %v
- error building nova client: %v
- no decernable storage availability zone could be mapped to c
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/65645ba488858267.
Report an issue: GitHub.