{"record":{"id":"f71ea513bd2fc738","repo":"kubernetes/kops","slug":"instance-v-not-managed-by-mig-s","errorCode":null,"errorMessage":"instance %v not managed by mig %s","messagePattern":"instance (.+?) not managed by mig (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/nodeidentity/gce/identify.go","lineNumber":263,"sourceCode":"\tvar matches []*compute.ManagedInstance\n\n\tfilter := \"id=\" + strconv.FormatUint(instanceID, 10)\n\tzone := lastComponent(mig.Zone)\n\tif err := i.computeService.InstanceGroupManagers.ListManagedInstances(i.project, zone, mig.Name).Filter(filter).Pages(ctx, func(page *compute.InstanceGroupManagersListManagedInstancesResponse) error {\n\t\t// Post-filter... filters aren't implemented (b/27605549)\n\t\tfor _, instance := range page.ManagedInstances {\n\t\t\tif instance.Id != instanceID {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tmatches = append(matches, instance)\n\t\t}\n\t\treturn nil\n\t}); err != nil {\n\t\treturn nil, fmt.Errorf(\"error fetching GCE managed instance group members for %q: %v\", mig.Name, err)\n\t}\n\n\tif len(matches) == 0 {\n\t\treturn nil, fmt.Errorf(\"instance %v not managed by mig %s\", instanceID, mig.Name)\n\t}\n\tif len(matches) > 1 {\n\t\t// Should be impossible - shows that filters / post-filters are not working\n\t\treturn nil, fmt.Errorf(\"found multiple instances with id %v managed by mig %s\", instanceID, mig.Name)\n\t}\n\n\treturn matches[0], nil\n}\n\n// lastComponent returns the last component of a URL, i.e. anything after the last slash\n// If there is no slash, returns the whole string\nfunc lastComponent(s string) string {\n\tlastSlash := strings.LastIndex(s, \"/\")\n\tif lastSlash != -1 {\n\t\ts = s[lastSlash+1:]\n\t}\n\treturn s\n}","sourceCodeStart":245,"sourceCodeEnd":281,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/nodeidentity/gce/identify.go#L245-L281","documentation":"The MIG member listing succeeded, but none of the group's instances had the instance ID reported by the kubelet, so kops concludes the node is not actually managed by this MIG. It signals an identity mismatch between the cluster Node object and the GCE instance group.","triggerScenarios":"After filtering MIG members by their instance ID, len(matches)==0: the node's reported instance ID belongs to an instance that left the MIG, was deleted, or the node is a non-MIG instance misreporting membership.","commonSituations":"Node replaced in a rolling update while the old Node object still exists; instance recreated outside the MIG (unmanaged); stale Node objects after MIG resize-down; instance ID changed after stop/start.","solutions":["Delete the stale Node object (kubectl delete node <name>) so it is re-registered","Verify the instance is a MIG member: gcloud compute instance-groups managed list-instances <mig> --zone <zone>","Ensure the node was created by the MIG, not manually (kops create instance-group + update)","Re-check that the instance ID from node metadata matches a current MIG member"],"exampleFix":"// before: error only\n// after: operator remediation\ncase strings.Contains(err.Error(), \"not managed by mig\"):\n  // node is stale/unmanaged; remove and let MIG recreate it\n  client.CoreV1().Nodes().Delete(ctx, node.Name, metav1.DeleteOptions{})","handlingStrategy":"fallback","validationCode":"members, _ := migMembers(mig); containsInstanceID(members, instanceID) // precheck membership","typeGuard":null,"tryCatchPattern":"info, err := IdentifyNode(ctx, node)\nif err != nil && strings.Contains(err.Error(), \"not managed by mig\") {\n  // stale/unmanaged node: delete Node object, skip\n}","preventionTips":["Clean up stale Node objects promptly (node-lifecycle-controller)","Only create nodes via MIGs, never unmanaged instances","Run kops rolling-update rather than manual instance replacement"],"tags":["gce","mig","node-lifecycle","stale-node"],"backgroundTag":"instance-not-in-managed-group","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"}