Skip to content

Commit

Permalink
fix: upgrade SubNamespace status managed fields from CSA to SSA
Browse files Browse the repository at this point in the history
  • Loading branch information
erikgb committed May 15, 2024
1 parent 9aab6be commit aa97596
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions controllers/ssa_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
7 changes: 6 additions & 1 deletion controllers/subnamespace_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit aa97596

Please sign in to comment.