{"record":{"id":"296441a74ba6d80b","repo":"kubernetes/kops","slug":"error-setting-metadata-on-instance-v","errorCode":null,"errorMessage":"error setting metadata on instance: %v","messagePattern":"error setting metadata on instance: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/gcetasks/instance.go","lineNumber":341,"sourceCode":"\ti, err := e.mapToGCE(project, ipAddressResolver)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif a == nil {\n\t\tklog.V(2).Infof(\"Creating instance %q\", i.Name)\n\t\tif _, err := cloud.Compute().Instances().Insert(project, zone, i); err != nil {\n\t\t\treturn fmt.Errorf(\"error creating Instance: %v\", err)\n\t\t}\n\t} else {\n\t\tif changes.Metadata != nil {\n\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","sourceCodeStart":323,"sourceCodeEnd":359,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/gcetasks/instance.go#L323-L359","documentation":"Wrapped error from Instance.RenderGCE when the Instances.SetMetadata API call fails while updating metadata on an existing instance. Often caused by a stale metadata fingerprint (concurrent modification) or a permissions/API error.","triggerScenarios":"Thrown at upup/pkg/fi/cloudup/gcetasks/instance.go:341 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry the apply — stale fingerprint errors resolve once Find() refreshes the fingerprint","Check for concurrent mutations of instance metadata (autoscaler, config agent, manual gcloud)","Inspect the wrapped error for permission or API issues"],"exampleFix":null,"handlingStrategy":"retry","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"}