diff --git a/pkg/apis/core/validation/validation.go b/pkg/apis/core/validation/validation.go index 6e2af9cf930..df67fccc5a9 100644 --- a/pkg/apis/core/validation/validation.go +++ b/pkg/apis/core/validation/validation.go @@ -287,9 +287,6 @@ var ValidateServiceAccountName = apimachineryvalidation.ValidateServiceAccountNa // trailing dashes are allowed. var ValidateEndpointsName = apimachineryvalidation.NameIsDNSSubdomain -// ValidateClusterName can be used to check whether the given cluster name is valid. -var ValidateClusterName = apimachineryvalidation.ValidateClusterName - // ValidateClassName can be used to check whether the given class name is valid. // It is defined here to avoid import cycle between pkg/apis/storage/validation // (where it should be) and this file. diff --git a/pkg/apis/core/validation/validation_test.go b/pkg/apis/core/validation/validation_test.go index 44e93fa10db..0ccde3c1e17 100644 --- a/pkg/apis/core/validation/validation_test.go +++ b/pkg/apis/core/validation/validation_test.go @@ -1360,7 +1360,7 @@ func testValidatePVC(t *testing.T, ephemeral bool) { isExpectedFailure: ephemeral, claim: func() *core.PersistentVolumeClaim { claim := testVolumeClaim(goodName, goodNS, goodClaimSpec) - claim.ClusterName = "foo" + claim.ZZZ_DeprecatedClusterName = "foo" return claim }(), }, diff --git a/pkg/apis/node/validation/validation_test.go b/pkg/apis/node/validation/validation_test.go index b5ecb1adb87..453637b2bf5 100644 --- a/pkg/apis/node/validation/validation_test.go +++ b/pkg/apis/node/validation/validation_test.go @@ -99,8 +99,8 @@ func TestValidateRuntimeUpdate(t *testing.T) { old: old, new: node.RuntimeClass{ ObjectMeta: metav1.ObjectMeta{ - Name: "empty", - ClusterName: "somethingelse", // immutable + Name: "empty", + Namespace: "somethingelse", // immutable }, Handler: "bar", }, diff --git a/pkg/registry/core/pod/strategy_test.go b/pkg/registry/core/pod/strategy_test.go index cc674303a25..0c603818d71 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"}, - ClusterName: "milo", + Name: "test-pod", + Namespace: "test-ns", + ResourceVersion: "1", + Annotations: map[string]string{"foo": "bar", "whiz": "pop"}, + ZZZ_DeprecatedClusterName: "milo", }, Spec: api.PodSpec{ Containers: []api.Container{ diff --git a/pkg/registry/rbac/helpers_test.go b/pkg/registry/rbac/helpers_test.go index 7a9cca59788..595a8fb03a6 100644 --- a/pkg/registry/rbac/helpers_test.go +++ b/pkg/registry/rbac/helpers_test.go @@ -190,7 +190,7 @@ func TestNewMetadataFields(t *testing.T) { objMeta.Annotations = nil objMeta.OwnerReferences = nil objMeta.Finalizers = nil - objMeta.ClusterName = "" + objMeta.ZZZ_DeprecatedClusterName = "" objMeta.ManagedFields = nil if !reflect.DeepEqual(metav1.ObjectMeta{}, objMeta) { diff --git a/pkg/scheduler/internal/queue/scheduling_queue_test.go b/pkg/scheduler/internal/queue/scheduling_queue_test.go index 3f5e3a42513..3bc4fb80b32 100644 --- a/pkg/scheduler/internal/queue/scheduling_queue_test.go +++ b/pkg/scheduler/internal/queue/scheduling_queue_test.go @@ -374,7 +374,7 @@ func TestPriorityQueue_Update(t *testing.T) { t.Error("Expected unschedulableQ to be 1.") } updatedPod := medPriorityPodInfo.Pod.DeepCopy() - updatedPod.ClusterName = "test" + updatedPod.Annotations["foo"] = "test" q.Update(medPriorityPodInfo.Pod, updatedPod) rawPodInfo, err = q.podBackoffQ.Pop() podGotFromBackoffQ = rawPodInfo.(*framework.QueuedPodInfo).Pod @@ -389,7 +389,7 @@ func TestPriorityQueue_Update(t *testing.T) { t.Error("Expected unschedulableQ to be 1.") } updatedPod = medPriorityPodInfo.Pod.DeepCopy() - updatedPod.ClusterName = "test1" + updatedPod.Annotations["foo"] = "test1" // Move clock by podInitialBackoffDuration, so that pods in the unschedulableQ would pass the backing off, // and the pods will be moved into activeQ. c.Step(q.podInitialBackoffDuration) 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 f73a45fe8fe..0ef51a035c4 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 @@ -534,7 +534,7 @@ 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: "ClusterName", val: "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/storage/cacher/caching_object_test.go b/staging/src/k8s.io/apiserver/pkg/storage/cacher/caching_object_test.go index 34fee69934f..3c5199320f2 100644 --- a/staging/src/k8s.io/apiserver/pkg/storage/cacher/caching_object_test.go +++ b/staging/src/k8s.io/apiserver/pkg/storage/cacher/caching_object_test.go @@ -92,31 +92,31 @@ func TestCachingObjectFieldAccessors(t *testing.T) { // Given accessors for all fields implement the same logic, // we are choosing an arbitrary one to test. - clusterName := "clusterName" - object.SetClusterName(clusterName) + namespace := "namespace" + object.SetNamespace(namespace) - encodeClusterName := func(obj runtime.Object, w io.Writer) error { + encodeNamespace := func(obj runtime.Object, w io.Writer) error { accessor, err := meta.Accessor(obj) if err != nil { t.Fatalf("failed to get accessor for %#v: %v", obj, err) } - _, err = w.Write([]byte(accessor.GetClusterName())) + _, err = w.Write([]byte(accessor.GetNamespace())) return err } buffer := bytes.NewBuffer(nil) - if err := object.CacheEncode("", encodeClusterName, buffer); err != nil { + if err := object.CacheEncode("", encodeNamespace, buffer); err != nil { t.Errorf("unexpected error: %v", err) } - if a, e := buffer.String(), clusterName; a != e { + if a, e := buffer.String(), namespace; a != e { t.Errorf("unexpected serialization: %s, expected: %s", a, e) } - // GetObject should also set clusterName. + // GetObject should also set namespace. buffer.Reset() - if err := encodeClusterName(object.GetObject(), buffer); err != nil { + if err := encodeNamespace(object.GetObject(), buffer); err != nil { t.Errorf("unexpected error: %v", err) } - if a, e := buffer.String(), clusterName; a != e { + if a, e := buffer.String(), namespace; a != e { t.Errorf("unexpected serialization: %s, expected: %s", a, e) } } @@ -140,7 +140,7 @@ func TestCachingObjectRaces(t *testing.T) { for i := 0; i < numWorkers; i++ { go func() { defer wg.Done() - object.SetClusterName("clusterName") + object.SetNamespace("namespace") buffer := bytes.NewBuffer(nil) for _, encoder := range encoders { buffer.Reset() @@ -156,8 +156,8 @@ func TestCachingObjectRaces(t *testing.T) { t.Errorf("failed to get accessor: %v", err) return } - if clusterName := accessor.GetClusterName(); clusterName != "clusterName" { - t.Errorf("unexpected clusterName: %s", clusterName) + if namespace := accessor.GetNamespace(); namespace != "namespace" { + t.Errorf("unexpected namespace: %s", namespace) } }() } diff --git a/staging/src/k8s.io/client-go/testing/fake_test.go b/staging/src/k8s.io/client-go/testing/fake_test.go index b335e700a20..949e0ad6df5 100644 --- a/staging/src/k8s.io/client-go/testing/fake_test.go +++ b/staging/src/k8s.io/client-go/testing/fake_test.go @@ -26,8 +26,8 @@ import ( ) func TestOriginalObjectCaptured(t *testing.T) { - // this ReactionFunc sets the resources ClusterName - const testClusterName = "some-value" + // this ReactionFunc sets the resources SelfLink + const testSelfLink = "some-value" reactors := []ReactionFunc{ func(action Action) (bool, runtime.Object, error) { createAction := action.(CreateActionImpl) @@ -37,7 +37,7 @@ func TestOriginalObjectCaptured(t *testing.T) { } // set any field on the resource - accessor.SetClusterName(testClusterName) + accessor.SetSelfLink(testSelfLink) return true, createAction.Object, nil }, @@ -69,7 +69,7 @@ func TestOriginalObjectCaptured(t *testing.T) { } // validate that the returned resource was modified by the ReactionFunc - if accessor.GetClusterName() != testClusterName { + if accessor.GetSelfLink() != testSelfLink { t.Errorf("expected resource returned by Invokes to be modified by the ReactionFunc") } // verify one action was performed @@ -83,14 +83,14 @@ func TestOriginalObjectCaptured(t *testing.T) { if err != nil { t.Fatalf("unexpected error: %v", err) } - if accessor.GetClusterName() != "" { + if accessor.GetSelfLink() != "" { t.Errorf("expected Action recorded to not be modified by ReactionFunc but it was") } } func TestReactorChangesPersisted(t *testing.T) { - // this ReactionFunc sets the resources ClusterName - const testClusterName = "some-value" + // this ReactionFunc sets the resources SelfLink + const testSelfLink = "some-value" reactors := []ReactionFunc{ func(action Action) (bool, runtime.Object, error) { createAction := action.(CreateActionImpl) @@ -100,7 +100,7 @@ func TestReactorChangesPersisted(t *testing.T) { } // set any field on the resource - accessor.SetClusterName(testClusterName) + accessor.SetSelfLink(testSelfLink) return false, createAction.Object, nil }, @@ -111,8 +111,8 @@ func TestReactorChangesPersisted(t *testing.T) { return false, nil, err } - // ensure the clusterName is set to testClusterName already - if accessor.GetClusterName() != testClusterName { + // ensure the selfLink is set to testSelfLink already + if accessor.GetSelfLink() != testSelfLink { t.Errorf("expected resource passed to second reactor to be modified by first reactor") } @@ -146,7 +146,7 @@ func TestReactorChangesPersisted(t *testing.T) { } // validate that the returned resource was modified by the ReactionFunc - if accessor.GetClusterName() != testClusterName { + if accessor.GetSelfLink() != testSelfLink { t.Errorf("expected resource returned by Invokes to be modified by the ReactionFunc") } // verify one action was performed @@ -160,7 +160,7 @@ func TestReactorChangesPersisted(t *testing.T) { if err != nil { t.Fatalf("unexpected error: %v", err) } - if accessor.GetClusterName() != "" { + if accessor.GetSelfLink() != "" { t.Errorf("expected Action recorded to not be modified by ReactionFunc but it was") } } diff --git a/test/integration/objectmeta/objectmeta_test.go b/test/integration/objectmeta/objectmeta_test.go index f2be620bc8a..b10cf67cbf7 100644 --- a/test/integration/objectmeta/objectmeta_test.go +++ b/test/integration/objectmeta/objectmeta_test.go @@ -38,17 +38,17 @@ func TestIgnoreClusterName(t *testing.T) { 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", - ClusterName: "cluster-name-to-ignore", + 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.ClusterName) + 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.ClusterName) + assert.Empty(t, nsNew.ZZZ_DeprecatedClusterName) }