{"record":{"id":"d0c3f59194d6a93d","repo":"kubernetes/kops","slug":"error-stopping-instance-d-v","errorCode":null,"errorMessage":"error stopping instance %d: %v","messagePattern":"error stopping instance (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/do/cloud.go","lineNumber":141,"sourceCode":"\tklog.V(8).Info(\"digitalocean cloud provider DeleteGroup not implemented yet\")\n\treturn fmt.Errorf(\"digital ocean cloud provider does not support deleting cloud groups at this time\")\n}\n\n// DeregisterInstance drains a cloud instance and loadbalancers.\nfunc (c *doCloudImplementation) DeregisterInstance(i *cloudinstances.CloudInstance) error {\n\tklog.V(8).Info(\"DO DeregisterInstance not implemented\")\n\treturn nil\n}\n\nfunc (c *doCloudImplementation) DeleteInstance(i *cloudinstances.CloudInstance) error {\n\tdropletID, err := strconv.Atoi(i.ID)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to convert droplet ID to int: %s\", err)\n\t}\n\n\t_, _, err = c.Client.DropletActions.Shutdown(context.TODO(), dropletID)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error stopping instance %d: %v\", dropletID, err)\n\t}\n\n\t// Wait for 5 min to stop the instance\n\tfor i := 0; i < 5; i++ {\n\t\tdroplet, _, err := c.Client.Droplets.Get(context.TODO(), dropletID)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error describing instance %d: %v\", dropletID, err)\n\t\t}\n\n\t\tklog.V(8).Infof(\"stopping DO instance %q, current Status: %q\", droplet, droplet.Status)\n\n\t\tif droplet.Status == \"off\" {\n\t\t\tbreak\n\t\t}\n\n\t\tif i == 5 {\n\t\t\treturn fmt.Errorf(\"fail to stop DO instance %v in 5 mins\", dropletID)\n\t\t}","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/do/cloud.go#L123-L159","documentation":"After parsing the droplet ID, DeleteInstance calls the DO DropletActions.Shutdown API to gracefully power off the droplet. If that API call fails, the error is wrapped as 'error stopping instance <id>'. The instance is not deleted and the rolling-delete flow aborts.","triggerScenarios":"DropletActions.Shutdown returns an error during `kops delete instance`/rolling update on DO: droplet already powered off/deleted, DO API auth failure (invalid token), droplet ID no longer exists, or DO API 5xx/rate-limit response.","commonSituations":"Expired or revoked DigitalOcean API token; droplet deleted manually in the DO console while kOps tries to delete it; transient DO API outage.","solutions":["Verify the DO API token is valid and has write scope (doctl auth check / doctl compute droplet get <id>)","Confirm the droplet still exists; if deleted manually, refresh kOps cloud state via `kops update cluster`","Retry the rolling update — DO transient errors usually clear","If the droplet is stuck, power it off via doctl then let kOps proceed"],"exampleFix":"// before\nexport DIGITALOCEAN_ACCESS_TOKEN=expired_token\n// after\nexport DIGITALOCEAN_ACCESS_TOKEN=<valid token with write scope>\nkops rolling-update cluster --name cluster.example.com --yes","handlingStrategy":"try-catch","validationCode":"// pre-flight: token works and droplet exists\n_, _, err := client.Droplets.Get(ctx, dropletID)\nif err != nil {\n    return fmt.Errorf(\"droplet %d unreachable before shutdown: %w\", dropletID, err)\n}","typeGuard":null,"tryCatchPattern":"_, _, err := c.Client.DropletActions.Shutdown(ctx, dropletID)\nif err != nil {\n    if gErr, ok := err.(godo.ErrorResponse); ok && gErr.Response.StatusCode == 404 {\n        return nil // already gone; treat as success\n    }\n    return fmt.Errorf(\"error stopping instance %d: %v\", dropletID, err)\n}","preventionTips":["Use a valid DO token with write scope for the whole operation","Don't delete droplets manually while kOps operations run","Retry on DO 5xx/rate-limit responses","Check DO status page during large rolling updates"],"tags":["digitalocean","api-error","instance-lifecycle"],"backgroundTag":"instance-shutdown-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"}