{"record":{"id":"c9186b1b717e5b4c","repo":"kubernetes/kops","slug":"failed-to-list-domains-s","errorCode":null,"errorMessage":"failed to list domains: %s","messagePattern":"failed to list domains: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/resources/digitalocean/resources.go","lineNumber":145,"sourceCode":"\n\t\t\tvar blocks []string\n\t\t\tfor _, dropletID := range volume.DropletIDs {\n\t\t\t\tblocks = append(blocks, \"droplet:\"+strconv.Itoa(dropletID))\n\t\t\t}\n\n\t\t\tresourceTracker.Blocks = blocks\n\t\t\tresourceTrackers = append(resourceTrackers, resourceTracker)\n\t\t}\n\t}\n\n\treturn resourceTrackers, nil\n}\n\nfunc listDNS(cloud fi.Cloud, clusterName string) ([]*resources.Resource, error) {\n\tc := cloud.(do.DOCloud)\n\tdomains, _, err := c.DomainService().List(context.TODO(), &godo.ListOptions{})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to list domains: %s\", err)\n\t}\n\n\tvar domainName string\n\tfor _, domain := range domains {\n\t\tif strings.HasSuffix(clusterName, domain.Name) {\n\t\t\tdomainName = domain.Name\n\t\t}\n\t}\n\n\tif domainName == \"\" {\n\t\treturn nil, fmt.Errorf(\"failed to find domain for cluster: %s\", clusterName)\n\t}\n\n\trecords, err := getAllRecordsByDomain(c, domainName)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to list records for domain %s: %s\", domainName, err)\n\t}\n","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/resources/digitalocean/resources.go#L127-L163","documentation":"Wraps any error from the DigitalOcean godo DomainService().List API call during DNS resource discovery in kops' digitalocean destroy/listDns flow. It indicates the cloud API listing of domains failed before kOps could match the cluster name to a domain. The underlying DO API error is embedded in the message.","triggerScenarios":"c.DomainService().List(context.TODO(), &godo.ListOptions{}) returns an error: invalid/expired DO API token, network failure, DO API outage, or rate limiting (429).","commonSituations":"Expired or misscoped DIGITALOCEAN_ACCESS_TOKEN (token lacking 'read' scope on domains), corporate proxy blocking api.digitalocean.com, or transient DO API 5xx during cluster deletion.","solutions":["Verify the DO API token is valid and has domain read scope (doctl auth init / check DIGITALOCEAN_ACCESS_TOKEN)","Retry the operation; transient API/network failures are common","Check https://www.digitaloceanstatus.com for API outages","Inspect the wrapped error in the message for 401/403/429 and address accordingly"],"exampleFix":"// before\nkops delete cluster --name my.cluster --cloud digitalocean  # fails with API error\n// after\nexport DIGITALOCEAN_ACCESS_TOKEN=<valid token with domain read scope>\nkops delete cluster --name my.cluster --cloud digitalocean","handlingStrategy":"try-catch","validationCode":"func validateDOToken(token string) error {\n\tif token == \"\" { return errors.New(\"DIGITALOCEAN_ACCESS_TOKEN not set\") }\n\tclient := godo.NewFromToken(token)\n\t_, _, err := client.Domains.List(context.TODO(), &godo.ListOptions{PerPage: 1})\n\treturn err\n}","typeGuard":"func isAuthError(err error) bool {\n\treturn strings.Contains(err.Error(), \"401\") || strings.Contains(err.Error(), \"403\")\n}","tryCatchPattern":"domains, _, err := c.DomainService().List(ctx, &godo.ListOptions{})\nif err != nil {\n\tif isRateLimit(err) { /* backoff and retry */ }\n\treturn fmt.Errorf(\"failed to list domains: %s\", err)\n}","preventionTips":["Verify token validity with `doctl account get` before running kops","Use a token with at least domain read scope","Retry with exponential backoff for transient API errors","Monitor DO status page during teardown"],"tags":["digitalocean","dns","api-authentication"],"backgroundTag":"digitalocean-api-error","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"}