kubernetes/kops · error

Could not delete instance %s: %v

Error message

Could not delete instance %s: %v

What it means

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.

Source

Thrown at upup/pkg/fi/cloudup/openstacktasks/servergroup.go:197

							continue
						}
						metadataName := ""
						val, ok = server.Metadata[openstack.TagKopsName]
						if ok {
							metadataName = val
						}
						// name or metadata tag should match to instance name
						// this is needed for backwards compatibility
						if server.Name == instanceName || metadataName == instanceName {
							instances = append(instances, server)
						}
					}

					if len(instances) == 1 {
						klog.V(2).Infof("Openstack task ServerGroup scaling down instance %s", instanceName)
						err := t.Cloud.DeleteInstanceWithID(instances[0].ID)
						if err != nil {
							return fmt.Errorf("Could not delete instance %s: %v", instanceName, err)
						}
					} else {
						return fmt.Errorf("found %d instances with name: %s", len(instances), instanceName)
					}
					currentLastIndex -= 1
				}
			}
		}
		return nil
	}

	klog.V(2).Infof("Openstack task ServerGroup::RenderOpenstack did nothing")
	return nil
}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Read the wrapped Nova error in the message: for 404 the instance is already gone — re-run 'kops update cluster' to converge.
  2. Check the instance state with 'openstack server show <id>' and force-delete if stuck ('openstack server delete --force' or wait for state to settle).
  3. Verify the credentials/tenant own the instance (403 → RBAC/project mismatch).
  4. Re-run kops apply; the cloud client has no delete retry, so transient failures need a retry.
Defensive patterns

Strategy: retry

Validate before calling

// Check the instance is in a deletable state before scaling down
openstack server show <instance-id> -f value -c status  # expect ACTIVE/SHUTOFF, not BUILDING/DELETING

Try / catch

// Distinguish already-gone (404) from real failures
err := cloud.DeleteInstanceWithID(id)
if err != nil {
    if isNotFound(err) { klog.Info("instance already deleted; continuing") } else { return err }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/faebb230dbfe7d26. Report an issue: GitHub.