diff --git a/api/api-rules/aggregator_violation_exceptions.list b/api/api-rules/aggregator_violation_exceptions.list index ff9e459d7b4..b2c97b0088d 100644 --- a/api/api-rules/aggregator_violation_exceptions.list +++ b/api/api-rules/aggregator_violation_exceptions.list @@ -30,7 +30,6 @@ API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,Duration,Du API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,InternalEvent,Object API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,InternalEvent,Type API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,MicroTime,Time -API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,ObjectMeta,ZZZ_DeprecatedClusterName API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,StatusCause,Type API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,Time,Time API rule violation: names_match,k8s.io/apimachinery/pkg/runtime,Unknown,ContentEncoding diff --git a/api/api-rules/apiextensions_violation_exceptions.list b/api/api-rules/apiextensions_violation_exceptions.list index ff9e459d7b4..b2c97b0088d 100644 --- a/api/api-rules/apiextensions_violation_exceptions.list +++ b/api/api-rules/apiextensions_violation_exceptions.list @@ -30,7 +30,6 @@ API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,Duration,Du API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,InternalEvent,Object API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,InternalEvent,Type API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,MicroTime,Time -API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,ObjectMeta,ZZZ_DeprecatedClusterName API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,StatusCause,Type API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,Time,Time API rule violation: names_match,k8s.io/apimachinery/pkg/runtime,Unknown,ContentEncoding diff --git a/api/api-rules/codegen_violation_exceptions.list b/api/api-rules/codegen_violation_exceptions.list index 6a351a7cb87..0a275601e22 100644 --- a/api/api-rules/codegen_violation_exceptions.list +++ b/api/api-rules/codegen_violation_exceptions.list @@ -30,7 +30,6 @@ API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,Duration,Du API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,InternalEvent,Object API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,InternalEvent,Type API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,MicroTime,Time -API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,ObjectMeta,ZZZ_DeprecatedClusterName API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,StatusCause,Type API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,Time,Time API rule violation: names_match,k8s.io/apimachinery/pkg/runtime,Unknown,ContentEncoding diff --git a/api/api-rules/sample_apiserver_violation_exceptions.list b/api/api-rules/sample_apiserver_violation_exceptions.list index 880abb62f03..62a4b8445d3 100644 --- a/api/api-rules/sample_apiserver_violation_exceptions.list +++ b/api/api-rules/sample_apiserver_violation_exceptions.list @@ -31,7 +31,6 @@ API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,Duration,Du API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,InternalEvent,Object API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,InternalEvent,Type API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,MicroTime,Time -API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,ObjectMeta,ZZZ_DeprecatedClusterName API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,StatusCause,Type API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,Time,Time API rule violation: names_match,k8s.io/apimachinery/pkg/runtime,Unknown,ContentEncoding diff --git a/api/api-rules/violation_exceptions.list b/api/api-rules/violation_exceptions.list index b95d4e53e64..a261773eccb 100644 --- a/api/api-rules/violation_exceptions.list +++ b/api/api-rules/violation_exceptions.list @@ -437,7 +437,6 @@ API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,Duration,Du API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,InternalEvent,Object API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,InternalEvent,Type API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,MicroTime,Time -API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,ObjectMeta,ZZZ_DeprecatedClusterName API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,StatusCause,Type API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,Time,Time API rule violation: names_match,k8s.io/apimachinery/pkg/runtime,Unknown,ContentEncoding diff --git a/pkg/api/testing/applyconfiguration_test.go b/pkg/api/testing/applyconfiguration_test.go index dbdf1692855..5975456738c 100644 --- a/pkg/api/testing/applyconfiguration_test.go +++ b/pkg/api/testing/applyconfiguration_test.go @@ -180,7 +180,6 @@ func fuzzObject(t *testing.T, gvk schema.GroupVersionKind) runtime.Object { c.FuzzNoCustom(s) s.ManagedFields = nil s.SelfLink = "" - s.ZZZ_DeprecatedClusterName = "" }, ).Fuzz(internalObj) diff --git a/pkg/apis/core/validation/validation_test.go b/pkg/apis/core/validation/validation_test.go index a4383152440..35b82123553 100644 --- a/pkg/apis/core/validation/validation_test.go +++ b/pkg/apis/core/validation/validation_test.go @@ -1356,14 +1356,6 @@ func testValidatePVC(t *testing.T, ephemeral bool) { return claim }(), }, - "with-cluster-name": { - isExpectedFailure: ephemeral, - claim: func() *core.PersistentVolumeClaim { - claim := testVolumeClaim(goodName, goodNS, goodClaimSpec) - claim.ZZZ_DeprecatedClusterName = "foo" - return claim - }(), - }, "with-managed-fields": { isExpectedFailure: ephemeral, claim: func() *core.PersistentVolumeClaim { diff --git a/pkg/registry/core/pod/strategy_test.go b/pkg/registry/core/pod/strategy_test.go index 0c603818d71..742578e734a 100644 --- a/pkg/registry/core/pod/strategy_test.go +++ b/pkg/registry/core/pod/strategy_test.go @@ -1460,11 +1460,11 @@ func TestDropNonEphemeralContainerUpdates(t *testing.T) { }, newPod: &api.Pod{ ObjectMeta: metav1.ObjectMeta{ - Name: "test-pod", - Namespace: "test-ns", - ResourceVersion: "1", - Annotations: map[string]string{"foo": "bar", "whiz": "pop"}, - ZZZ_DeprecatedClusterName: "milo", + Name: "test-pod", + Namespace: "test-ns", + ResourceVersion: "1", + Annotations: map[string]string{"foo": "bar", "whiz": "pop"}, + Finalizers: []string{"milo"}, }, Spec: api.PodSpec{ Containers: []api.Container{ diff --git a/pkg/registry/rbac/helpers_test.go b/pkg/registry/rbac/helpers_test.go index 595a8fb03a6..765ca3fea04 100644 --- a/pkg/registry/rbac/helpers_test.go +++ b/pkg/registry/rbac/helpers_test.go @@ -190,7 +190,6 @@ func TestNewMetadataFields(t *testing.T) { objMeta.Annotations = nil objMeta.OwnerReferences = nil objMeta.Finalizers = nil - objMeta.ZZZ_DeprecatedClusterName = "" objMeta.ManagedFields = nil if !reflect.DeepEqual(metav1.ObjectMeta{}, objMeta) { diff --git a/staging/src/k8s.io/apimachinery/pkg/api/meta/meta.go b/staging/src/k8s.io/apimachinery/pkg/api/meta/meta.go index 81403393fb6..42e21c1dfc1 100644 --- a/staging/src/k8s.io/apimachinery/pkg/api/meta/meta.go +++ b/staging/src/k8s.io/apimachinery/pkg/api/meta/meta.go @@ -130,7 +130,6 @@ func AsPartialObjectMetadata(m metav1.Object) *metav1.PartialObjectMetadata { Annotations: m.GetAnnotations(), OwnerReferences: m.GetOwnerReferences(), Finalizers: m.GetFinalizers(), - ZZZ_DeprecatedClusterName: m.GetZZZ_DeprecatedClusterName(), ManagedFields: m.GetManagedFields(), }, } diff --git a/staging/src/k8s.io/apimachinery/pkg/api/validation/objectmeta.go b/staging/src/k8s.io/apimachinery/pkg/api/validation/objectmeta.go index 9a1fe073146..8b77c641c4b 100644 --- a/staging/src/k8s.io/apimachinery/pkg/api/validation/objectmeta.go +++ b/staging/src/k8s.io/apimachinery/pkg/api/validation/objectmeta.go @@ -40,9 +40,6 @@ var BannedOwners = map[schema.GroupVersionKind]struct{}{ {Group: "", Version: "v1", Kind: "Event"}: {}, } -// ValidateZZZ_DeprecatedClusterName can be used to check whether the given cluster name is valid. -var ValidateZZZ_DeprecatedClusterName = NameIsDNS1035Label - // ValidateAnnotations validates that a set of annotations are correctly defined. func ValidateAnnotations(annotations map[string]string, fldPath *field.Path) field.ErrorList { allErrs := field.ErrorList{} @@ -184,11 +181,6 @@ func ValidateObjectMetaAccessor(meta metav1.Object, requiresNamespace bool, name allErrs = append(allErrs, field.Forbidden(fldPath.Child("namespace"), "not allowed on this type")) } } - if len(meta.GetZZZ_DeprecatedClusterName()) != 0 { - for _, msg := range ValidateZZZ_DeprecatedClusterName(meta.GetZZZ_DeprecatedClusterName(), false) { - allErrs = append(allErrs, field.Invalid(fldPath.Child("clusterName"), meta.GetZZZ_DeprecatedClusterName(), msg)) - } - } allErrs = append(allErrs, ValidateNonnegativeField(meta.GetGeneration(), fldPath.Child("generation"))...) allErrs = append(allErrs, v1validation.ValidateLabels(meta.GetLabels(), fldPath.Child("labels"))...) @@ -261,7 +253,6 @@ func ValidateObjectMetaAccessorUpdate(newMeta, oldMeta metav1.Object, fldPath *f allErrs = append(allErrs, ValidateImmutableField(newMeta.GetCreationTimestamp(), oldMeta.GetCreationTimestamp(), fldPath.Child("creationTimestamp"))...) allErrs = append(allErrs, ValidateImmutableField(newMeta.GetDeletionTimestamp(), oldMeta.GetDeletionTimestamp(), fldPath.Child("deletionTimestamp"))...) allErrs = append(allErrs, ValidateImmutableField(newMeta.GetDeletionGracePeriodSeconds(), oldMeta.GetDeletionGracePeriodSeconds(), fldPath.Child("deletionGracePeriodSeconds"))...) - allErrs = append(allErrs, ValidateImmutableField(newMeta.GetZZZ_DeprecatedClusterName(), oldMeta.GetZZZ_DeprecatedClusterName(), fldPath.Child("clusterName"))...) allErrs = append(allErrs, v1validation.ValidateLabels(newMeta.GetLabels(), fldPath.Child("labels"))...) allErrs = append(allErrs, ValidateAnnotations(newMeta.GetAnnotations(), fldPath.Child("annotations"))...) diff --git a/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/helpers_test.go b/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/helpers_test.go index b12cc8a30ce..af6d9cf7d55 100644 --- a/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/helpers_test.go +++ b/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/helpers_test.go @@ -205,7 +205,6 @@ func TestResetObjectMetaForStatus(t *testing.T) { existingMeta.SetUID(types.UID("")) existingMeta.SetName("") existingMeta.SetNamespace("") - existingMeta.SetZZZ_DeprecatedClusterName("") existingMeta.SetCreationTimestamp(Time{}) existingMeta.SetDeletionTimestamp(nil) existingMeta.SetDeletionGracePeriodSeconds(nil) diff --git a/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/meta.go b/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/meta.go index 1ea90de1eda..92d3ed5e012 100644 --- a/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/meta.go +++ b/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/meta.go @@ -59,8 +59,6 @@ type Object interface { SetFinalizers(finalizers []string) GetOwnerReferences() []OwnerReference SetOwnerReferences([]OwnerReference) - GetZZZ_DeprecatedClusterName() string - SetZZZ_DeprecatedClusterName(clusterName string) GetManagedFields() []ManagedFieldsEntry SetManagedFields(managedFields []ManagedFieldsEntry) } @@ -172,10 +170,6 @@ func (meta *ObjectMeta) GetOwnerReferences() []OwnerReference { return m func (meta *ObjectMeta) SetOwnerReferences(references []OwnerReference) { meta.OwnerReferences = references } -func (meta *ObjectMeta) GetZZZ_DeprecatedClusterName() string { return meta.ZZZ_DeprecatedClusterName } -func (meta *ObjectMeta) SetZZZ_DeprecatedClusterName(clusterName string) { - meta.ZZZ_DeprecatedClusterName = clusterName -} func (meta *ObjectMeta) GetManagedFields() []ManagedFieldsEntry { return meta.ManagedFields } func (meta *ObjectMeta) SetManagedFields(managedFields []ManagedFieldsEntry) { meta.ManagedFields = managedFields diff --git a/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/types.go b/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/types.go index eb071d410bc..5b1ba1a883b 100644 --- a/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/types.go +++ b/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/types.go @@ -254,14 +254,9 @@ type ObjectMeta struct { // +patchStrategy=merge Finalizers []string `json:"finalizers,omitempty" patchStrategy:"merge" protobuf:"bytes,14,rep,name=finalizers"` - // Deprecated: ClusterName is a legacy field that was always cleared by - // the system and never used; it will be removed completely in 1.25. - // - // The name in the go struct is changed to help clients detect - // accidental use. - // - // +optional - ZZZ_DeprecatedClusterName string `json:"clusterName,omitempty" protobuf:"bytes,15,opt,name=clusterName"` + // Tombstone: ClusterName was a legacy field that was always cleared by + // the system and never used. + // ClusterName string `json:"clusterName,omitempty" protobuf:"bytes,15,opt,name=clusterName"` // ManagedFields maps workflow-id and version to the set of fields // that are managed by that workflow. This is mostly for internal diff --git a/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/unstructured.go b/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/unstructured.go index f0fad90fd47..a499eee8ebb 100644 --- a/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/unstructured.go +++ b/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/unstructured.go @@ -444,18 +444,6 @@ func (u *Unstructured) SetFinalizers(finalizers []string) { u.setNestedStringSlice(finalizers, "metadata", "finalizers") } -func (u *Unstructured) GetZZZ_DeprecatedClusterName() string { - return getNestedString(u.Object, "metadata", "clusterName") -} - -func (u *Unstructured) SetZZZ_DeprecatedClusterName(clusterName string) { - if len(clusterName) == 0 { - RemoveNestedField(u.Object, "metadata", "clusterName") - return - } - u.setNestedField(clusterName, "metadata", "clusterName") -} - func (u *Unstructured) GetManagedFields() []metav1.ManagedFieldsEntry { items, found, err := NestedSlice(u.Object, "metadata", "managedFields") if !found || err != nil { diff --git a/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/unstructured_test.go b/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/unstructured_test.go index 81372162a9b..be9a48f7141 100644 --- a/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/unstructured_test.go +++ b/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/unstructured_test.go @@ -105,7 +105,6 @@ func TestUnstructuredMetadataOmitempty(t *testing.T) { u.SetAnnotations(nil) u.SetOwnerReferences(nil) u.SetFinalizers(nil) - u.SetZZZ_DeprecatedClusterName("") u.SetManagedFields(nil) gotMetadata, _, err := unstructured.NestedFieldNoCopy(u.UnstructuredContent(), "metadata") @@ -147,6 +146,5 @@ func setObjectMetaUsingAccessors(u, uCopy *unstructured.Unstructured) { uCopy.SetAnnotations(u.GetAnnotations()) uCopy.SetOwnerReferences(u.GetOwnerReferences()) uCopy.SetFinalizers(u.GetFinalizers()) - uCopy.SetZZZ_DeprecatedClusterName(u.GetZZZ_DeprecatedClusterName()) uCopy.SetManagedFields(u.GetManagedFields()) } diff --git a/staging/src/k8s.io/apimachinery/pkg/test/apis_meta_v1_unstructed_unstructure_test.go b/staging/src/k8s.io/apimachinery/pkg/test/apis_meta_v1_unstructed_unstructure_test.go index 0ef51a035c4..b1a50a41a25 100644 --- a/staging/src/k8s.io/apimachinery/pkg/test/apis_meta_v1_unstructed_unstructure_test.go +++ b/staging/src/k8s.io/apimachinery/pkg/test/apis_meta_v1_unstructed_unstructure_test.go @@ -170,7 +170,6 @@ func TestUnstructuredGetters(t *testing.T) { "finalizer.1", "finalizer.2", }, - "clusterName": "cluster123", }, }, } @@ -245,9 +244,6 @@ func TestUnstructuredGetters(t *testing.T) { if got, want := unstruct.GetFinalizers(), []string{"finalizer.1", "finalizer.2"}; !reflect.DeepEqual(got, want) { t.Errorf("GetFinalizers()=%v, want %v", got, want) } - if got, want := unstruct.GetZZZ_DeprecatedClusterName(), "cluster123"; got != want { - t.Errorf("GetZZZ_DeprecatedClusterName()=%v, want %v", got, want) - } if got, want := unstruct.GetDeletionGracePeriodSeconds(), &ten; !reflect.DeepEqual(got, want) { t.Errorf("GetDeletionGracePeriodSeconds()=%v, want %v", got, want) } @@ -302,7 +298,6 @@ func TestUnstructuredSetters(t *testing.T) { "finalizer.1", "finalizer.2", }, - "clusterName": "cluster123", }, }, } @@ -338,7 +333,6 @@ func TestUnstructuredSetters(t *testing.T) { } unstruct.SetOwnerReferences(newOwnerReferences) unstruct.SetFinalizers([]string{"finalizer.1", "finalizer.2"}) - unstruct.SetZZZ_DeprecatedClusterName("cluster123") unstruct.SetDeletionGracePeriodSeconds(&ten) unstruct.SetGeneration(ten) @@ -534,7 +528,6 @@ func TestAccessorMethods(t *testing.T) { {accessor: "Annotations", val: map[string]string{"foo": "bar"}}, {accessor: "Finalizers", val: []string{"foo"}}, {accessor: "OwnerReferences", val: []metav1.OwnerReference{{Name: "foo"}}}, - {accessor: "ZZZ_DeprecatedClusterName", val: "foo"}, } for i, test := range tests { t.Logf("evaluating test %d (%s)", i, test.accessor) diff --git a/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/fieldmanager/fieldmanager_test.go b/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/fieldmanager/fieldmanager_test.go index c24b859a306..d73b6bfc229 100644 --- a/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/fieldmanager/fieldmanager_test.go +++ b/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/fieldmanager/fieldmanager_test.go @@ -267,7 +267,6 @@ func TestApplyStripsFields(t *testing.T) { newObj.SetName("b") newObj.SetNamespace("b") newObj.SetUID("b") - newObj.SetZZZ_DeprecatedClusterName("b") newObj.SetGeneration(0) newObj.SetResourceVersion("b") newObj.SetCreationTimestamp(metav1.NewTime(time.Now())) diff --git a/staging/src/k8s.io/apiserver/pkg/registry/rest/create.go b/staging/src/k8s.io/apiserver/pkg/registry/rest/create.go index 83d5e576aa3..23cff3a1469 100644 --- a/staging/src/k8s.io/apiserver/pkg/registry/rest/create.go +++ b/staging/src/k8s.io/apiserver/pkg/registry/rest/create.go @@ -123,12 +123,6 @@ func BeforeCreate(strategy RESTCreateStrategy, ctx context.Context, obj runtime. objectMeta.SetManagedFields(nil) } - // ZZZ_DeprecatedClusterName is ignored and should not be saved - if len(objectMeta.GetZZZ_DeprecatedClusterName()) > 0 { - objectMeta.SetZZZ_DeprecatedClusterName("") - warning.AddWarning(ctx, "", "metadata.clusterName was specified. This field is not preserved and will be removed from the schema in 1.25") - } - if errs := strategy.Validate(ctx, obj); len(errs) > 0 { return errors.NewInvalid(kind.GroupKind(), objectMeta.GetName(), errs) } diff --git a/staging/src/k8s.io/apiserver/pkg/registry/rest/resttest/resttest.go b/staging/src/k8s.io/apiserver/pkg/registry/rest/resttest/resttest.go index ae5b9da512b..b9d53c3aad5 100644 --- a/staging/src/k8s.io/apiserver/pkg/registry/rest/resttest/resttest.go +++ b/staging/src/k8s.io/apiserver/pkg/registry/rest/resttest/resttest.go @@ -168,8 +168,6 @@ func (t *Tester) TestCreate(valid runtime.Object, createFn CreateFunc, getFn Get t.testCreateInvokesValidation(opts, invalid...) t.testCreateValidatesNames(valid.DeepCopyObject(), dryRunOpts) t.testCreateValidatesNames(valid.DeepCopyObject(), opts) - t.testCreateIgnoreZZZ_DeprecatedClusterName(valid.DeepCopyObject(), dryRunOpts) - t.testCreateIgnoreZZZ_DeprecatedClusterName(valid.DeepCopyObject(), opts) } // Test updating an object. @@ -190,7 +188,6 @@ func (t *Tester) TestUpdate(valid runtime.Object, createFn CreateFunc, getFn Get t.testUpdatePropagatesUpdatedObjectError(valid.DeepCopyObject(), createFn, getFn, dryRunOpts) t.testUpdatePropagatesUpdatedObjectError(valid.DeepCopyObject(), createFn, getFn, opts) t.testUpdateIgnoreGenerationUpdates(valid.DeepCopyObject(), createFn, getFn) - t.testUpdateIgnoreZZZ_DeprecatedClusterName(valid.DeepCopyObject(), createFn, getFn) } // Test deleting an object. @@ -506,22 +503,6 @@ func (t *Tester) testCreateResetsUserData(valid runtime.Object, opts metav1.Crea } } -func (t *Tester) testCreateIgnoreZZZ_DeprecatedClusterName(valid runtime.Object, opts metav1.CreateOptions) { - objectMeta := t.getObjectMetaOrFail(valid) - objectMeta.SetName(t.namer(3)) - objectMeta.SetZZZ_DeprecatedClusterName("clustername-to-ignore") - - obj, err := t.storage.(rest.Creater).Create(t.TestContext(), valid.DeepCopyObject(), rest.ValidateAllObjectFunc, &opts) - if err != nil { - t.Fatalf("Unexpected error: %v", err) - } - defer t.delete(t.TestContext(), obj) - createdObjectMeta := t.getObjectMetaOrFail(obj) - if len(createdObjectMeta.GetZZZ_DeprecatedClusterName()) != 0 { - t.Errorf("Expected empty clusterName on created object, got '%v'", createdObjectMeta.GetZZZ_DeprecatedClusterName()) - } -} - // ============================================================================= // Update tests. @@ -790,41 +771,6 @@ func (t *Tester) testUpdateRejectsMismatchedNamespace(obj runtime.Object, create } } -func (t *Tester) testUpdateIgnoreZZZ_DeprecatedClusterName(obj runtime.Object, createFn CreateFunc, getFn GetFunc) { - ctx := t.TestContext() - - foo := obj.DeepCopyObject() - name := t.namer(9) - t.setObjectMeta(foo, name) - - if err := createFn(ctx, foo); err != nil { - t.Errorf("unexpected error: %v", err) - } - - storedFoo, err := getFn(ctx, foo) - if err != nil { - t.Errorf("unexpected error: %v", err) - } - - older := storedFoo.DeepCopyObject() - olderMeta := t.getObjectMetaOrFail(older) - olderMeta.SetZZZ_DeprecatedClusterName("clustername-to-ignore") - - _, _, err = t.storage.(rest.Updater).Update(t.TestContext(), olderMeta.GetName(), rest.DefaultUpdatedObjectInfo(older), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc, false, &metav1.UpdateOptions{}) - if err != nil { - t.Errorf("Unexpected error: %v", err) - } - - updatedFoo, err := getFn(ctx, older) - if err != nil { - t.Errorf("unexpected error: %v", err) - } - if clusterName := t.getObjectMetaOrFail(updatedFoo).GetZZZ_DeprecatedClusterName(); len(clusterName) != 0 { - t.Errorf("Unexpected clusterName update: expected empty, got %v", clusterName) - } - -} - // ============================================================================= // Deletion tests. diff --git a/staging/src/k8s.io/apiserver/pkg/registry/rest/update.go b/staging/src/k8s.io/apiserver/pkg/registry/rest/update.go index e5ae7af0ebb..805aa0fb57a 100644 --- a/staging/src/k8s.io/apiserver/pkg/registry/rest/update.go +++ b/staging/src/k8s.io/apiserver/pkg/registry/rest/update.go @@ -136,11 +136,6 @@ func BeforeUpdate(strategy RESTUpdateStrategy, ctx context.Context, obj, old run strategy.PrepareForUpdate(ctx, obj, old) - // ZZZ_DeprecatedClusterName is ignored and should not be saved - if len(objectMeta.GetZZZ_DeprecatedClusterName()) > 0 { - objectMeta.SetZZZ_DeprecatedClusterName("") - warning.AddWarning(ctx, "", "metadata.clusterName was specified. This field is not preserved and will be removed from the schema in 1.25") - } // Use the existing UID if none is provided if len(objectMeta.GetUID()) == 0 { objectMeta.SetUID(oldMeta.GetUID()) diff --git a/staging/src/k8s.io/apiserver/pkg/storage/cacher/caching_object.go b/staging/src/k8s.io/apiserver/pkg/storage/cacher/caching_object.go index 2e3ea6a7da6..258efed8425 100644 --- a/staging/src/k8s.io/apiserver/pkg/storage/cacher/caching_object.go +++ b/staging/src/k8s.io/apiserver/pkg/storage/cacher/caching_object.go @@ -395,17 +395,6 @@ func (o *cachingObject) SetOwnerReferences(references []metav1.OwnerReference) { func() { o.object.SetOwnerReferences(references) }, ) } -func (o *cachingObject) GetZZZ_DeprecatedClusterName() string { - o.lock.RLock() - defer o.lock.RUnlock() - return o.object.GetZZZ_DeprecatedClusterName() -} -func (o *cachingObject) SetZZZ_DeprecatedClusterName(clusterName string) { - o.conditionalSet( - func() bool { return o.object.GetZZZ_DeprecatedClusterName() == clusterName }, - func() { o.object.SetZZZ_DeprecatedClusterName(clusterName) }, - ) -} func (o *cachingObject) GetManagedFields() []metav1.ManagedFieldsEntry { o.lock.RLock() defer o.lock.RUnlock() diff --git a/test/integration/objectmeta/objectmeta_test.go b/test/integration/objectmeta/objectmeta_test.go deleted file mode 100644 index b10cf67cbf7..00000000000 --- a/test/integration/objectmeta/objectmeta_test.go +++ /dev/null @@ -1,54 +0,0 @@ -/* -Copyright 2016 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 objectmeta - -import ( - "context" - "testing" - - "github.com/stretchr/testify/assert" - - "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime/schema" - clientset "k8s.io/client-go/kubernetes" - restclient "k8s.io/client-go/rest" - "k8s.io/kubernetes/test/integration/framework" -) - -func TestIgnoreClusterName(t *testing.T) { - config := framework.NewControlPlaneConfig() - _, s, closeFn := framework.RunAnAPIServer(config) - defer closeFn() - - client := clientset.NewForConfigOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: &schema.GroupVersion{Group: "", Version: "v1"}}}) - ns := v1.Namespace{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-namespace", - ZZZ_DeprecatedClusterName: "cluster-name-to-ignore", - }, - } - nsNew, err := client.CoreV1().Namespaces().Create(context.TODO(), &ns, metav1.CreateOptions{}) - assert.NoError(t, err) - assert.Equal(t, ns.Name, nsNew.Name) - assert.Empty(t, nsNew.ZZZ_DeprecatedClusterName) - - nsNew, err = client.CoreV1().Namespaces().Update(context.TODO(), &ns, metav1.UpdateOptions{}) - assert.NoError(t, err) - assert.Equal(t, ns.Name, nsNew.Name) - assert.Empty(t, nsNew.ZZZ_DeprecatedClusterName) -}