From f1f1653be4a398c284935cc372d500b15aa83217 Mon Sep 17 00:00:00 2001 From: Antoine Pelisse Date: Wed, 18 Mar 2020 14:17:32 -0700 Subject: [PATCH] Do not reset managedFields in status update strategy Kubernetes-commit: 4d04631c6366bd5c8ebcad35fc1379e597e3ede2 --- pkg/apis/meta/v1/helpers.go | 4 +++- pkg/apis/meta/v1/helpers_test.go | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/apis/meta/v1/helpers.go b/pkg/apis/meta/v1/helpers.go index ec016fd3c..ad989ad75 100644 --- a/pkg/apis/meta/v1/helpers.go +++ b/pkg/apis/meta/v1/helpers.go @@ -252,7 +252,9 @@ func ResetObjectMetaForStatus(meta, existingMeta Object) { meta.SetAnnotations(existingMeta.GetAnnotations()) meta.SetFinalizers(existingMeta.GetFinalizers()) meta.SetOwnerReferences(existingMeta.GetOwnerReferences()) - meta.SetManagedFields(existingMeta.GetManagedFields()) + // managedFields must be preserved since it's been modified to + // track changed fields in the status update. + //meta.SetManagedFields(existingMeta.GetManagedFields()) } // MarshalJSON implements json.Marshaler diff --git a/pkg/apis/meta/v1/helpers_test.go b/pkg/apis/meta/v1/helpers_test.go index 54963c4ca..62023c079 100644 --- a/pkg/apis/meta/v1/helpers_test.go +++ b/pkg/apis/meta/v1/helpers_test.go @@ -189,6 +189,7 @@ func TestResetObjectMetaForStatus(t *testing.T) { existingMeta.SetCreationTimestamp(Time{}) existingMeta.SetDeletionTimestamp(nil) existingMeta.SetDeletionGracePeriodSeconds(nil) + existingMeta.SetManagedFields(nil) if !reflect.DeepEqual(meta, existingMeta) { t.Error(diff.ObjectDiff(meta, existingMeta))