Skip to content

Commit 2975d71

Browse files
committed
chore(controller): update patch usage per k8s api deprecation
Signed-off-by: Vaughn Dice <vdice@akamai.com>
1 parent 5c448f6 commit 2975d71

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

internal/controller/shim_controller.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,13 @@ func (sr *ShimReconciler) deployJobOnNode(ctx context.Context, shim *rcmv1.Shim,
321321
}
322322

323323
// We want to use server-side apply https://kubernetes.io/docs/reference/using-api/server-side-apply
324-
patchMethod := client.Apply
324+
jobData, err := json.Marshal(job)
325+
if err != nil {
326+
return fmt.Errorf("failed to marshal job: %w", err)
327+
}
328+
patchMethod := client.RawPatch(types.ApplyPatchType, jobData)
325329
patchOptions := &client.PatchOptions{
326-
Force: ptr(true), // Force b/c any fields we are setting need to be owned by the spin-operator
330+
Force: ptr(true), // Force b/c any fields we are setting need to be owned by the shim-operator
327331
FieldManager: "shim-operator",
328332
}
329333

@@ -587,7 +591,11 @@ func (sr *ShimReconciler) handleDeployRuntimeClass(ctx context.Context, shim *rc
587591
}
588592

589593
// We want to use server-side apply https://kubernetes.io/docs/reference/using-api/server-side-apply
590-
patchMethod := client.Apply
594+
runtimeClassData, err := json.Marshal(runtimeClass)
595+
if err != nil {
596+
return ctrl.Result{}, fmt.Errorf("failed to marshal runtimeclass: %w", err)
597+
}
598+
patchMethod := client.RawPatch(types.ApplyPatchType, runtimeClassData)
591599
patchOptions := &client.PatchOptions{
592600
Force: ptr(true), // Force b/c any fields we are setting need to be owned by the spin-operator
593601
FieldManager: "shim-operator",

0 commit comments

Comments
 (0)