{"record":{"id":"1e090d797cf58dd6","repo":"kubernetes/kops","slug":"error-deleting-http-healthcheck-s-v","errorCode":null,"errorMessage":"error deleting HTTP HealthCheck %s: %v","messagePattern":"error deleting HTTP HealthCheck (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/resources/gce/gce.go","lineNumber":700,"sourceCode":"\n// deleteHTTPHealthCheck is the helper function to delete a Resource for a HTTP health check object\nfunc deleteHTTPHealthCheck(cloud fi.Cloud, r *resources.Resource) error {\n\tc := cloud.(gce.GCECloud)\n\tt := r.Obj.(*compute.HttpHealthCheck)\n\n\tklog.V(2).Infof(\"Deleting GCE HTTP HealthCheck %s\", t.SelfLink)\n\tu, err := gce.ParseGoogleCloudURL(t.SelfLink)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\top, err := c.Compute().HTTPHealthChecks().Delete(u.Project, u.Name)\n\tif err != nil {\n\t\tif gce.IsNotFound(err) {\n\t\t\tklog.Infof(\"HTTP HealthCheck not found, assuming deleted: %q\", t.SelfLink)\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"error deleting HTTP HealthCheck %s: %v\", t.SelfLink, err)\n\t}\n\n\treturn c.WaitForOp(op)\n}\n\n// deleteFirewallRule is the helper function to delete a Resource for a Firewall object\nfunc deleteFirewallRule(cloud fi.Cloud, r *resources.Resource) error {\n\tc := cloud.(gce.GCECloud)\n\tt := r.Obj.(*compute.Firewall)\n\n\tklog.V(2).Infof(\"Deleting GCE FirewallRule %s\", t.SelfLink)\n\tu, err := gce.ParseGoogleCloudURL(t.SelfLink)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\top, err := c.Compute().Firewalls().Delete(u.Project, u.Name)\n\tif err != nil {","sourceCodeStart":682,"sourceCodeEnd":718,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/resources/gce/gce.go#L682-L718","documentation":"Wraps a failure from Compute HTTPHealthChecks().Delete in deleteHTTPHealthCheck, used when tearing down cluster load-balancer resources. A 404 is treated as success ('assuming deleted'), so this error means the delete call itself failed for a non-NotFound reason. The message includes the health check's SelfLink and the raw underlying error (%v, not %w).","triggerScenarios":"c.Compute().HTTPHealthChecks().Delete(u.Project, u.Name) returns 403 permission denied, 412 conflict (health check still in use by a target pool), 429 rate limit, or 5xx. The 412 in-use case is the most common non-trivial cause.","commonSituations":"Target pool still references the health check because target pool deletion failed or was skipped earlier in teardown; kops service account lost compute.healthChecks.delete permission; concurrent deletion attempts from two kops runs.","solutions":["Ensure the target pool referencing the health check is deleted first, then re-run kops delete cluster.","Check IAM: the service account needs compute.healthChecks.delete.","Verify no concurrent kops/cloud operations are deleting the same resource; re-run after the other completes.","If the GCP console shows the health check already gone, re-run — NotFound is treated as success.","For a stuck 412, inspect which target pool still references it and remove the reference."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// ensure nothing still references the health check\npool, err := computeService.TargetPools.Get(project, region, poolName).Do()\nif err == nil {\n    for _, hc := range pool.HealthChecks {\n        if strings.HasSuffix(hc, \"/healthChecks/\"+hcName) {\n            return fmt.Errorf(\"target pool %s still references health check %s\", poolName, hcName)\n        }\n    }\n}","typeGuard":"func isGCEAPIError(err error) (*googleapi.Error, bool) {\n    var gerr *googleapi.Error\n    return gerr, errors.As(err, &gerr)\n}","tryCatchPattern":"for attempt := 0; attempt < 5; attempt++ {\n    err := deleteHTTPHealthCheck(t)\n    var gerr *googleapi.Error\n    if err == nil { break }\n    if errors.As(err, &gerr) && gerr.Code == 404 { break } // already deleted\n    if errors.As(err, &gerr) && (gerr.Code == 412 || gerr.Code == 429 || gerr.Code >= 500) {\n        time.Sleep(backoff(attempt)); continue\n    }\n    return err // permanent\n}","preventionTips":["Delete target pools before health checks (respect teardown ordering)","Never run two kops delete operations concurrently on one cluster","Verify compute.healthChecks.delete IAM before teardown","Re-run kops delete cluster after fixing failures — deletes are idempotent (404 = success)","Check for GKE/other controllers re-creating health checks"],"tags":["gce","gcp","health-check","delete","teardown"],"backgroundTag":"gcp-resource-delete-conflict","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"}