{"record":{"id":"6661d8edd2ac7a82","repo":"kubernetes/kops","slug":"deregistering-cloud-instance-s-of-group-q-w","errorCode":null,"errorMessage":"deregistering cloud instance %s of group %q: %w","messagePattern":"deregistering cloud instance (.+?) of group %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/scaleway/cloud.go","lineNumber":260,"sourceCode":"\t\t}\n\t\treturn fmt.Errorf(\"deleting cloud instance %s of group %s: %w\", i.ID, i.CloudInstanceGroup.HumanName, err)\n\t}\n\n\terr = s.DeleteServer(server.Server)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"deleting cloud instance %s of group %s: %w\", i.ID, i.CloudInstanceGroup.HumanName, err)\n\t}\n\n\treturn nil\n}\n\nfunc (s *scwCloudImplementation) DeregisterInstance(i *cloudinstances.CloudInstance) error {\n\tserver, err := s.instanceAPI.GetServer(&instance.GetServerRequest{\n\t\tZone:     s.zone,\n\t\tServerID: i.ID,\n\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"deregistering cloud instance %s of group %q: %w\", i.ID, i.CloudInstanceGroup.HumanName, err)\n\t}\n\tserverIP, err := s.GetServerIP(server.Server.ID, server.Server.Zone)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"deregistering cloud instance %s of group %q: %w\", i.ID, i.CloudInstanceGroup.HumanName, err)\n\t}\n\n\t// We remove the instance's IP from load-balancers\n\tlbs, err := s.GetClusterLoadBalancers(s.ClusterName(server.Server.Tags))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"deregistering cloud instance %s of group %q: %w\", i.ID, i.CloudInstanceGroup.HumanName, err)\n\t}\n\tfor _, loadBalancer := range lbs {\n\t\tbackEnds, err := s.lbAPI.ListBackends(&lb.ZonedAPIListBackendsRequest{\n\t\t\tZone: s.zone,\n\t\t\tLBID: loadBalancer.ID,\n\t\t}, scw.WithAllPages())\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"deregistering cloud instance %s of group %q: listing load-balancer's back-ends for instance creation: %w\", i.ID, i.CloudInstanceGroup.HumanName, err)","sourceCodeStart":242,"sourceCodeEnd":278,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/scaleway/cloud.go#L242-L278","documentation":"DeregisterInstance removes a node from Scaleway load-balancers before it leaves the cluster. The first step fetches the server with instanceAPI.GetServer; any non-nil error is wrapped as \"deregistering cloud instance %s of group %q: %w\". Unlike DeleteInstance there is no 404 special-casing here, so an already-deleted instance also fails deregistration.","triggerScenarios":"instanceAPI.GetServer(&instance.GetServerRequest{Zone: s.zone, ServerID: i.ID}) returns an error: server already deleted (404), wrong zone, bad server ID, insufficient permissions, or API/network failure.","commonSituations":"Deregistering a node that was already terminated out-of-band (404 surfaces as this error); zone mismatch between the kOps config and the server's actual zone; IAM key lacking servers:read.","solutions":["Check the wrapped error status — if 404, the instance is already gone and deregistration is moot.","Verify s.zone matches the server's zone (cluster tags vs Scaleway profile defaults).","Ensure credentials grant servers:read in the project.","Retry after transient API errors."],"exampleFix":"// before: deleting a node then deregistering it\nkops delete instance   // server gone -> GetServer 404 -> error\n// after: deregister BEFORE deleting the instance","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"func isAlreadyDeleted(err error) bool {\n  var respErr *scw.ResponseError\n  return errors.As(err, &respErr) && respErr.StatusCode == http.StatusNotFound\n}","tryCatchPattern":"if err := cloud.DeregisterInstance(inst); err != nil {\n  if isAlreadyDeleted(err) {\n    klog.Infof(\"instance %s already removed; skipping deregister\", inst.ID)\n    return nil\n  }\n  return err\n}","preventionTips":["Deregister instances before deleting them, not after.","Handle 404 as success for deregistration flows, like DeleteInstance does.","Keep server IDs in kops state in sync with the Scaleway console."],"tags":["scaleway","load-balancer","deregister","instance-api"],"backgroundTag":"cloud-instance-deletion-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"}