From 03e2a89a9fe28996247e8d2b0c91ba5ba0af3b7d Mon Sep 17 00:00:00 2001 From: Jakub Skiba Date: Wed, 14 Jan 2026 14:30:00 +0000 Subject: [PATCH 1/4] use patch instead of update in admissioncheck controller --- slice/internal/controller/admissioncheck_controller.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/slice/internal/controller/admissioncheck_controller.go b/slice/internal/controller/admissioncheck_controller.go index 6d4bbe2e3..54a01f2e2 100644 --- a/slice/internal/controller/admissioncheck_controller.go +++ b/slice/internal/controller/admissioncheck_controller.go @@ -62,8 +62,9 @@ func (r *AdmissionCheckReconciler) Reconcile(ctx context.Context, req ctrl.Reque } if currentCondition.Status != newCondition.Status { + patch := client.MergeFrom(ac.DeepCopy()) apimeta.SetStatusCondition(&ac.Status.Conditions, newCondition) - return reconcile.Result{}, client.IgnoreNotFound(r.client.Status().Update(ctx, ac)) + return reconcile.Result{}, client.IgnoreNotFound(r.client.Status().Patch(ctx, ac, patch)) } return reconcile.Result{}, nil From 14d5ad5cdb95a34f9a274691ca4d2c1f2cd03af4 Mon Sep 17 00:00:00 2001 From: Jakub Skiba Date: Mon, 19 Jan 2026 06:55:38 +0000 Subject: [PATCH 2/4] use SSA for the patch --- .../controller/admissioncheck_controller.go | 9 +++-- slice/internal/core/admissioncheck.go | 36 +++++++++++++++++++ 2 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 slice/internal/core/admissioncheck.go diff --git a/slice/internal/controller/admissioncheck_controller.go b/slice/internal/controller/admissioncheck_controller.go index 54a01f2e2..dd0c650ca 100644 --- a/slice/internal/controller/admissioncheck_controller.go +++ b/slice/internal/controller/admissioncheck_controller.go @@ -19,6 +19,8 @@ package controller import ( "context" + "tpu-slice-controller/internal/core" + apimeta "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/utils/ptr" @@ -59,12 +61,13 @@ func (r *AdmissionCheckReconciler) Reconcile(ctx context.Context, req ctrl.Reque Reason: "Active", Message: "The admission check is active", ObservedGeneration: ac.Generation, + LastTransitionTime: metav1.Now(), } if currentCondition.Status != newCondition.Status { - patch := client.MergeFrom(ac.DeepCopy()) - apimeta.SetStatusCondition(&ac.Status.Conditions, newCondition) - return reconcile.Result{}, client.IgnoreNotFound(r.client.Status().Patch(ctx, ac, patch)) + acPatch := core.BaseSSAAdmissionCheck(ac) + acPatch.Status.Conditions = []metav1.Condition{newCondition} + return reconcile.Result{}, client.IgnoreNotFound(r.client.Status().Patch(ctx, acPatch, client.Apply, client.FieldOwner(SliceControllerName), client.ForceOwnership)) } return reconcile.Result{}, nil diff --git a/slice/internal/core/admissioncheck.go b/slice/internal/core/admissioncheck.go new file mode 100644 index 000000000..2403e93c4 --- /dev/null +++ b/slice/internal/core/admissioncheck.go @@ -0,0 +1,36 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package core + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + kueue "sigs.k8s.io/kueue/apis/kueue/v1beta1" +) + +func BaseSSAAdmissionCheck(ac *kueue.AdmissionCheck) *kueue.AdmissionCheck { + return &kueue.AdmissionCheck{ + TypeMeta: metav1.TypeMeta{ + APIVersion: kueue.GroupVersion.String(), + Kind: "AdmissionCheck", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: ac.Name, + Namespace: ac.Namespace, + UID: ac.UID, + }, + } +} From ef7e076852791e9e88ca2d58345e979f461dc43d Mon Sep 17 00:00:00 2001 From: Jakub Skiba Date: Mon, 19 Jan 2026 13:07:14 +0000 Subject: [PATCH 3/4] use apimeta.SetStatusCondition --- slice/internal/controller/admissioncheck_controller.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/slice/internal/controller/admissioncheck_controller.go b/slice/internal/controller/admissioncheck_controller.go index dd0c650ca..b1a04ad7e 100644 --- a/slice/internal/controller/admissioncheck_controller.go +++ b/slice/internal/controller/admissioncheck_controller.go @@ -61,12 +61,11 @@ func (r *AdmissionCheckReconciler) Reconcile(ctx context.Context, req ctrl.Reque Reason: "Active", Message: "The admission check is active", ObservedGeneration: ac.Generation, - LastTransitionTime: metav1.Now(), } if currentCondition.Status != newCondition.Status { acPatch := core.BaseSSAAdmissionCheck(ac) - acPatch.Status.Conditions = []metav1.Condition{newCondition} + apimeta.SetStatusCondition(&acPatch.Status.Conditions, newCondition) return reconcile.Result{}, client.IgnoreNotFound(r.client.Status().Patch(ctx, acPatch, client.Apply, client.FieldOwner(SliceControllerName), client.ForceOwnership)) } From ac1fb86c8efecba6d3bfdfd09da63a2fee5a73a7 Mon Sep 17 00:00:00 2001 From: Jakub Skiba Date: Mon, 19 Jan 2026 13:23:52 +0000 Subject: [PATCH 4/4] fix merge --- slice/internal/core/admissioncheck.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slice/internal/core/admissioncheck.go b/slice/internal/core/admissioncheck.go index 2403e93c4..a78984c4e 100644 --- a/slice/internal/core/admissioncheck.go +++ b/slice/internal/core/admissioncheck.go @@ -18,7 +18,7 @@ package core import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - kueue "sigs.k8s.io/kueue/apis/kueue/v1beta1" + kueue "sigs.k8s.io/kueue/apis/kueue/v1beta2" ) func BaseSSAAdmissionCheck(ac *kueue.AdmissionCheck) *kueue.AdmissionCheck {