mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 03:11:40 +00:00
remove unneeded references
This commit is contained in:
parent
e405ae9ec8
commit
2831f9a343
@ -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.
|
||||
|
@ -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
|
||||
}(),
|
||||
},
|
||||
|
@ -100,7 +100,7 @@ func TestValidateRuntimeUpdate(t *testing.T) {
|
||||
new: node.RuntimeClass{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "empty",
|
||||
ClusterName: "somethingelse", // immutable
|
||||
Namespace: "somethingelse", // immutable
|
||||
},
|
||||
Handler: "bar",
|
||||
},
|
||||
|
@ -1464,7 +1464,7 @@ func TestDropNonEphemeralContainerUpdates(t *testing.T) {
|
||||
Namespace: "test-ns",
|
||||
ResourceVersion: "1",
|
||||
Annotations: map[string]string{"foo": "bar", "whiz": "pop"},
|
||||
ClusterName: "milo",
|
||||
ZZZ_DeprecatedClusterName: "milo",
|
||||
},
|
||||
Spec: api.PodSpec{
|
||||
Containers: []api.Container{
|
||||
|
@ -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) {
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
@ -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")
|
||||
}
|
||||
}
|
||||
|
@ -39,16 +39,16 @@ func TestIgnoreClusterName(t *testing.T) {
|
||||
ns := v1.Namespace{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "test-namespace",
|
||||
ClusterName: "cluster-name-to-ignore",
|
||||
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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user