{"record":{"id":"057a242ee815672f","repo":"kubernetes/kops","slug":"instancegroups-patch-not-supported-for-server-sid","errorCode":null,"errorMessage":"InstanceGroups::Patch not supported for server-side client","messagePattern":"InstanceGroups::Patch not supported for server-side client","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops-controller/pkg/controllerclientset/instancegroups.go","lineNumber":120,"sourceCode":"\nfunc (c *instanceGroups) Update(ctx context.Context, g *kopsapi.InstanceGroup, opts metav1.UpdateOptions) (*kopsapi.InstanceGroup, error) {\n\treturn nil, fmt.Errorf(\"InstanceGroups::Update not supported for server-side client\")\n}\n\nfunc (c *instanceGroups) Delete(ctx context.Context, name string, options metav1.DeleteOptions) error {\n\treturn fmt.Errorf(\"InstanceGroups::Delete not supported for server-side client\")\n}\n\nfunc (r *instanceGroups) DeleteCollection(ctx context.Context, options metav1.DeleteOptions, listOptions metav1.ListOptions) error {\n\treturn fmt.Errorf(\"InstanceGroups::DeleteCollection not supported for server-side client\")\n}\n\nfunc (r *instanceGroups) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) {\n\treturn nil, fmt.Errorf(\"InstanceGroups::Watch not supported for server-side client\")\n}\n\nfunc (r *instanceGroups) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *kopsapi.InstanceGroup, err error) {\n\treturn nil, fmt.Errorf(\"InstanceGroups::Patch not supported for server-side client\")\n}\n","sourceCodeStart":102,"sourceCodeEnd":122,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops-controller/pkg/controllerclientset/instancegroups.go#L102-L122","documentation":"Patch is not implemented on the server-side instanceGroups wrapper in the kops-controller clientset. Despite the clientset's server-side-apply orientation, this resource's Patch method was not wired up, so it always returns this sentinel error with a nil result. No API request is issued.","triggerScenarios":"Calling ctxClient.InstanceGroups().Patch(ctx, name, types.StrategicMergePatchType, data, metav1.PatchOptions{}, subresources...) — e.g. strategic-merge or JSON-patch updates to an InstanceGroup, including status subresource patches.","commonSituations":"Porting mutation logic that used the legacy kops clientset's Patch to the controller clientset; applying merge patches from a generic reconciler framework; JSON-patch based field updates in CI tooling built on this client.","solutions":["Use server-side apply instead: build a full *kopsapi.InstanceGroup and call Apply(ctx, obj, metav1.ApplyOptions{FieldManager: \"...\"})","Fetch with Get, mutate the object, and write with Update(ctx, obj, metav1.UpdateOptions{})","Use a standard client-go typed clientset for the kops.k8s.io/v1alpha2 group when patch semantics are mandatory","Implement Patch in cmd/kops-controller/pkg/controllerclientset/instancegroups.go if it is needed"],"exampleFix":"// before\npatchBytes, _ := json.Marshal(map[string]interface{}{\"spec\": map[string]interface{}{\"minSize\": 3}})\n_, err := client.InstanceGroups().Patch(ctx, \"nodes\", types.StrategicMergePatchType, patchBytes, metav1.PatchOptions{})\n// after\nig, err := client.InstanceGroups().Get(ctx, \"nodes\", metav1.GetOptions{})\nif err != nil { return err }\nig.Spec.MinSize = ptr.To(int32(3))\n_, err = client.InstanceGroups().Update(ctx, ig, metav1.UpdateOptions{})","handlingStrategy":"try-catch","validationCode":"if _, ok := igClient.(interface {\n\tPatch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*kopsapi.InstanceGroup, error)\n}); !ok {\n\tuseGetUpdateInstead = true\n}\n","typeGuard":"func supportsPatch(v interface{}) bool {\n\t_, ok := v.(interface {\n\t\tPatch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*kopsapi.InstanceGroup, error)\n\t})\n\treturn ok\n}","tryCatchPattern":"_, err := igClient.Patch(ctx, name, types.StrategicMergePatchType, data, metav1.PatchOptions{})\nif err != nil && strings.Contains(err.Error(), \"not supported for server-side client\") {\n\treturn getMutateAndUpdate(ctx, name) // Get + mutate + Update fallback\n}","preventionTips":["Prefer Get + Update or server-side Apply over Patch with this clientset","Check the clientset source for unsupported methods before adopting patch-based patterns","Keep mutation helpers generic so a Get/Update fallback is a one-line switch"],"tags":["kubernetes","kops-controller","patch","unsupported-method"],"backgroundTag":"unsupported-clientset-method","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"}