From 67a23785eef1011709bc415c3ef80c31760743be Mon Sep 17 00:00:00 2001 From: Joe Betz Date: Thu, 12 Mar 2026 20:14:52 -0400 Subject: [PATCH] Update reset fields to match current field wiping behavior --- pkg/registry/networking/servicecidr/strategy.go | 10 ++++++++-- .../pkg/registry/customresource/status_strategy.go | 1 + .../pkg/registry/customresourcedefinition/strategy.go | 10 ++++++++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/pkg/registry/networking/servicecidr/strategy.go b/pkg/registry/networking/servicecidr/strategy.go index e1a3f962456..dcbb7277f65 100644 --- a/pkg/registry/networking/servicecidr/strategy.go +++ b/pkg/registry/networking/servicecidr/strategy.go @@ -56,10 +56,14 @@ func (serviceCIDRStrategy) NamespaceScoped() bool { func (serviceCIDRStrategy) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set { fields := map[fieldpath.APIVersion]*fieldpath.Set{ "networking.k8s.io/v1": fieldpath.NewSet( - fieldpath.MakePathOrDie("status"), + // Disabled to match PrepareForCreate/PrepareForUpdate, which do not wipe fields + // https://github.com/kubernetes/kubernetes/issues/137680 + // fieldpath.MakePathOrDie("status"), ), "networking.k8s.io/v1beta1": fieldpath.NewSet( - fieldpath.MakePathOrDie("status"), + // Disabled to match PrepareForCreate/PrepareForUpdate, which do not wipe fields + // https://github.com/kubernetes/kubernetes/issues/137680 + // fieldpath.MakePathOrDie("status"), ), } return fields @@ -130,9 +134,11 @@ var StatusStrategy = serviceCIDRStatusStrategy{Strategy} func (serviceCIDRStatusStrategy) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set { fields := map[fieldpath.APIVersion]*fieldpath.Set{ "networking.k8s.io/v1": fieldpath.NewSet( + fieldpath.MakePathOrDie("metadata"), fieldpath.MakePathOrDie("spec"), ), "networking.k8s.io/v1beta1": fieldpath.NewSet( + fieldpath.MakePathOrDie("metadata"), fieldpath.MakePathOrDie("spec"), ), } diff --git a/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresource/status_strategy.go b/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresource/status_strategy.go index b89e42db167..53ab2826252 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresource/status_strategy.go +++ b/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresource/status_strategy.go @@ -56,6 +56,7 @@ func (a statusStrategy) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set // we might need a mechanism that is the inverse of resetFields where // you specify only the fields to be kept rather than the fields to be wiped // that way you could wipe everything but the status in this case. + fieldpath.MakePathOrDie("metadata"), fieldpath.MakePathOrDie("spec"), ), } diff --git a/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresourcedefinition/strategy.go b/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresourcedefinition/strategy.go index 8713b8ec5b6..91d7929afea 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresourcedefinition/strategy.go +++ b/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresourcedefinition/strategy.go @@ -252,11 +252,17 @@ func (statusStrategy) NamespaceScoped() bool { func (statusStrategy) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set { fields := map[fieldpath.APIVersion]*fieldpath.Set{ "apiextensions.k8s.io/v1": fieldpath.NewSet( - fieldpath.MakePathOrDie("metadata"), + // Disabled to match PrepareForUpdate, which do not wipe metadata + // https://github.com/kubernetes/kubernetes/issues/137681 + // fieldpath.MakePathOrDie("metadata"), + fieldpath.MakePathOrDie("spec"), ), "apiextensions.k8s.io/v1beta1": fieldpath.NewSet( - fieldpath.MakePathOrDie("metadata"), + // Disabled to match PrepareForUpdate, which do not wipe metadata + // https://github.com/kubernetes/kubernetes/issues/137681 + // fieldpath.MakePathOrDie("metadata"), + fieldpath.MakePathOrDie("spec"), ), }