{"record":{"id":"65ac8f27b66f807d","repo":"kubernetes/kops","slug":"cannot-apply-changes-to-instance-v","errorCode":null,"errorMessage":"cannot apply changes to Instance: %v","messagePattern":"cannot apply changes to Instance: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/gcetasks/instance.go","lineNumber":353,"sourceCode":"\t\t\tklog.V(2).Infof(\"Updating instance metadata on %q\", i.Name)\n\n\t\t\ti.Metadata.Fingerprint = a.metadataFingerprint\n\n\t\t\top, err := cloud.Compute().Instances().SetMetadata(project, zone, i.Name, i.Metadata)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"error setting metadata on instance: %v\", err)\n\t\t\t}\n\n\t\t\tif err := cloud.WaitForOp(op); err != nil {\n\t\t\t\treturn fmt.Errorf(\"error setting metadata on instance: %v\", err)\n\t\t\t}\n\n\t\t\tchanges.Metadata = nil\n\t\t}\n\n\t\tif !changes.isZero() {\n\t\t\tklog.Errorf(\"Cannot apply changes to Instance: %v\", changes)\n\t\t\treturn fmt.Errorf(\"cannot apply changes to Instance: %v\", changes)\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc BuildMachineTypeURL(project, zone, name string) string {\n\treturn fmt.Sprintf(\"https://www.googleapis.com/compute/v1/projects/%s/zones/%s/machineTypes/%s\", project, zone, name)\n}\n\nfunc BuildImageURL(defaultProject, nameSpec string) string {\n\ttokens := strings.Split(nameSpec, \"/\")\n\tvar project, name string\n\tif len(tokens) == 2 {\n\t\tproject = tokens[0]\n\t\tname = tokens[1]\n\t} else if len(tokens) == 1 {\n\t\tproject = defaultProject","sourceCodeStart":335,"sourceCodeEnd":371,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/gcetasks/instance.go#L335-L371","documentation":"Returned from Instance.RenderGCE after metadata updates are applied when the remaining diff is still non-zero. Instances cannot be mutated in place for most fields (machine type, zone, disks, network config), so any leftover change is rejected.","triggerScenarios":"Thrown at upup/pkg/fi/cloudup/gcetasks/instance.go:353 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Examine the printed changes to see which fields drifted (klog.Error logs the same diff)","Align the cluster spec with the actual instance, or roll the instance group so instances are recreated with the new config","For immutable-field changes, perform a rolling update instead of an in-place apply"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}