diff --git a/controllers/ssa_client.go b/controllers/ssa_client.go index c23a396..b56c8f1 100644 --- a/controllers/ssa_client.go +++ b/controllers/ssa_client.go @@ -23,8 +23,8 @@ const ( // fields from the Update operation to the Apply operation. This is required // to ensure that the apply operations will also remove fields that were // set by the Update operation. -func upgradeManagedFields(ctx context.Context, c client.Client, obj client.Object) error { - patch, err := csaupgrade.UpgradeManagedFieldsPatch(obj, sets.New(string(fieldOwner)), string(fieldOwner)) +func upgradeManagedFields(ctx context.Context, c client.Client, obj client.Object, opts ...csaupgrade.Option) error { + patch, err := csaupgrade.UpgradeManagedFieldsPatch(obj, sets.New(string(fieldOwner)), string(fieldOwner), opts...) if err != nil { return err } diff --git a/controllers/subnamespace_controller.go b/controllers/subnamespace_controller.go index e17ba0d..46d1658 100644 --- a/controllers/subnamespace_controller.go +++ b/controllers/subnamespace_controller.go @@ -14,6 +14,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" metav1ac "k8s.io/client-go/applyconfigurations/meta/v1" + "k8s.io/client-go/util/csaupgrade" "k8s.io/client-go/util/workqueue" kstatus "sigs.k8s.io/cli-utils/pkg/kstatus/status" ctrl "sigs.k8s.io/controller-runtime" @@ -137,7 +138,11 @@ func (r *SubNamespaceReconciler) reconcileNS(ctx context.Context, sn *accuratev2 ) } - // TODO: upgrade managed fields to SSA when https://github.com/kubernetes/kubernetes/pull/123484 is released + // Ensure that status managed fields are upgraded to SSA before the following SSA. + // TODO(migration): This code could be removed after a couple of releases. + if err := upgradeManagedFields(ctx, r.Client, sn, csaupgrade.Subresource("status")); err != nil { + return err + } sn, p, err := newSubNamespacePatch(ac) if err != nil {