mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 19:31:44 +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.
|
// trailing dashes are allowed.
|
||||||
var ValidateEndpointsName = apimachineryvalidation.NameIsDNSSubdomain
|
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.
|
// 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
|
// It is defined here to avoid import cycle between pkg/apis/storage/validation
|
||||||
// (where it should be) and this file.
|
// (where it should be) and this file.
|
||||||
|
@ -1360,7 +1360,7 @@ func testValidatePVC(t *testing.T, ephemeral bool) {
|
|||||||
isExpectedFailure: ephemeral,
|
isExpectedFailure: ephemeral,
|
||||||
claim: func() *core.PersistentVolumeClaim {
|
claim: func() *core.PersistentVolumeClaim {
|
||||||
claim := testVolumeClaim(goodName, goodNS, goodClaimSpec)
|
claim := testVolumeClaim(goodName, goodNS, goodClaimSpec)
|
||||||
claim.ClusterName = "foo"
|
claim.ZZZ_DeprecatedClusterName = "foo"
|
||||||
return claim
|
return claim
|
||||||
}(),
|
}(),
|
||||||
},
|
},
|
||||||
|
@ -99,8 +99,8 @@ func TestValidateRuntimeUpdate(t *testing.T) {
|
|||||||
old: old,
|
old: old,
|
||||||
new: node.RuntimeClass{
|
new: node.RuntimeClass{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "empty",
|
Name: "empty",
|
||||||
ClusterName: "somethingelse", // immutable
|
Namespace: "somethingelse", // immutable
|
||||||
},
|
},
|
||||||
Handler: "bar",
|
Handler: "bar",
|
||||||
},
|
},
|
||||||
|
@ -1460,11 +1460,11 @@ func TestDropNonEphemeralContainerUpdates(t *testing.T) {
|
|||||||
},
|
},
|
||||||
newPod: &api.Pod{
|
newPod: &api.Pod{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "test-pod",
|
Name: "test-pod",
|
||||||
Namespace: "test-ns",
|
Namespace: "test-ns",
|
||||||
ResourceVersion: "1",
|
ResourceVersion: "1",
|
||||||
Annotations: map[string]string{"foo": "bar", "whiz": "pop"},
|
Annotations: map[string]string{"foo": "bar", "whiz": "pop"},
|
||||||
ClusterName: "milo",
|
ZZZ_DeprecatedClusterName: "milo",
|
||||||
},
|
},
|
||||||
Spec: api.PodSpec{
|
Spec: api.PodSpec{
|
||||||
Containers: []api.Container{
|
Containers: []api.Container{
|
||||||
|
@ -190,7 +190,7 @@ func TestNewMetadataFields(t *testing.T) {
|
|||||||
objMeta.Annotations = nil
|
objMeta.Annotations = nil
|
||||||
objMeta.OwnerReferences = nil
|
objMeta.OwnerReferences = nil
|
||||||
objMeta.Finalizers = nil
|
objMeta.Finalizers = nil
|
||||||
objMeta.ClusterName = ""
|
objMeta.ZZZ_DeprecatedClusterName = ""
|
||||||
objMeta.ManagedFields = nil
|
objMeta.ManagedFields = nil
|
||||||
|
|
||||||
if !reflect.DeepEqual(metav1.ObjectMeta{}, objMeta) {
|
if !reflect.DeepEqual(metav1.ObjectMeta{}, objMeta) {
|
||||||
|
@ -374,7 +374,7 @@ func TestPriorityQueue_Update(t *testing.T) {
|
|||||||
t.Error("Expected unschedulableQ to be 1.")
|
t.Error("Expected unschedulableQ to be 1.")
|
||||||
}
|
}
|
||||||
updatedPod := medPriorityPodInfo.Pod.DeepCopy()
|
updatedPod := medPriorityPodInfo.Pod.DeepCopy()
|
||||||
updatedPod.ClusterName = "test"
|
updatedPod.Annotations["foo"] = "test"
|
||||||
q.Update(medPriorityPodInfo.Pod, updatedPod)
|
q.Update(medPriorityPodInfo.Pod, updatedPod)
|
||||||
rawPodInfo, err = q.podBackoffQ.Pop()
|
rawPodInfo, err = q.podBackoffQ.Pop()
|
||||||
podGotFromBackoffQ = rawPodInfo.(*framework.QueuedPodInfo).Pod
|
podGotFromBackoffQ = rawPodInfo.(*framework.QueuedPodInfo).Pod
|
||||||
@ -389,7 +389,7 @@ func TestPriorityQueue_Update(t *testing.T) {
|
|||||||
t.Error("Expected unschedulableQ to be 1.")
|
t.Error("Expected unschedulableQ to be 1.")
|
||||||
}
|
}
|
||||||
updatedPod = medPriorityPodInfo.Pod.DeepCopy()
|
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,
|
// Move clock by podInitialBackoffDuration, so that pods in the unschedulableQ would pass the backing off,
|
||||||
// and the pods will be moved into activeQ.
|
// and the pods will be moved into activeQ.
|
||||||
c.Step(q.podInitialBackoffDuration)
|
c.Step(q.podInitialBackoffDuration)
|
||||||
|
@ -534,7 +534,7 @@ func TestAccessorMethods(t *testing.T) {
|
|||||||
{accessor: "Annotations", val: map[string]string{"foo": "bar"}},
|
{accessor: "Annotations", val: map[string]string{"foo": "bar"}},
|
||||||
{accessor: "Finalizers", val: []string{"foo"}},
|
{accessor: "Finalizers", val: []string{"foo"}},
|
||||||
{accessor: "OwnerReferences", val: []metav1.OwnerReference{{Name: "foo"}}},
|
{accessor: "OwnerReferences", val: []metav1.OwnerReference{{Name: "foo"}}},
|
||||||
{accessor: "ClusterName", val: "foo"},
|
{accessor: "ZZZ_DeprecatedClusterName", val: "foo"},
|
||||||
}
|
}
|
||||||
for i, test := range tests {
|
for i, test := range tests {
|
||||||
t.Logf("evaluating test %d (%s)", i, test.accessor)
|
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,
|
// Given accessors for all fields implement the same logic,
|
||||||
// we are choosing an arbitrary one to test.
|
// we are choosing an arbitrary one to test.
|
||||||
clusterName := "clusterName"
|
namespace := "namespace"
|
||||||
object.SetClusterName(clusterName)
|
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)
|
accessor, err := meta.Accessor(obj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to get accessor for %#v: %v", obj, err)
|
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
|
return err
|
||||||
}
|
}
|
||||||
buffer := bytes.NewBuffer(nil)
|
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)
|
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)
|
t.Errorf("unexpected serialization: %s, expected: %s", a, e)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetObject should also set clusterName.
|
// GetObject should also set namespace.
|
||||||
buffer.Reset()
|
buffer.Reset()
|
||||||
if err := encodeClusterName(object.GetObject(), buffer); err != nil {
|
if err := encodeNamespace(object.GetObject(), buffer); err != nil {
|
||||||
t.Errorf("unexpected error: %v", err)
|
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)
|
t.Errorf("unexpected serialization: %s, expected: %s", a, e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -140,7 +140,7 @@ func TestCachingObjectRaces(t *testing.T) {
|
|||||||
for i := 0; i < numWorkers; i++ {
|
for i := 0; i < numWorkers; i++ {
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
object.SetClusterName("clusterName")
|
object.SetNamespace("namespace")
|
||||||
buffer := bytes.NewBuffer(nil)
|
buffer := bytes.NewBuffer(nil)
|
||||||
for _, encoder := range encoders {
|
for _, encoder := range encoders {
|
||||||
buffer.Reset()
|
buffer.Reset()
|
||||||
@ -156,8 +156,8 @@ func TestCachingObjectRaces(t *testing.T) {
|
|||||||
t.Errorf("failed to get accessor: %v", err)
|
t.Errorf("failed to get accessor: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if clusterName := accessor.GetClusterName(); clusterName != "clusterName" {
|
if namespace := accessor.GetNamespace(); namespace != "namespace" {
|
||||||
t.Errorf("unexpected clusterName: %s", clusterName)
|
t.Errorf("unexpected namespace: %s", namespace)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestOriginalObjectCaptured(t *testing.T) {
|
func TestOriginalObjectCaptured(t *testing.T) {
|
||||||
// this ReactionFunc sets the resources ClusterName
|
// this ReactionFunc sets the resources SelfLink
|
||||||
const testClusterName = "some-value"
|
const testSelfLink = "some-value"
|
||||||
reactors := []ReactionFunc{
|
reactors := []ReactionFunc{
|
||||||
func(action Action) (bool, runtime.Object, error) {
|
func(action Action) (bool, runtime.Object, error) {
|
||||||
createAction := action.(CreateActionImpl)
|
createAction := action.(CreateActionImpl)
|
||||||
@ -37,7 +37,7 @@ func TestOriginalObjectCaptured(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// set any field on the resource
|
// set any field on the resource
|
||||||
accessor.SetClusterName(testClusterName)
|
accessor.SetSelfLink(testSelfLink)
|
||||||
|
|
||||||
return true, createAction.Object, nil
|
return true, createAction.Object, nil
|
||||||
},
|
},
|
||||||
@ -69,7 +69,7 @@ func TestOriginalObjectCaptured(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate that the returned resource was modified by the ReactionFunc
|
// 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")
|
t.Errorf("expected resource returned by Invokes to be modified by the ReactionFunc")
|
||||||
}
|
}
|
||||||
// verify one action was performed
|
// verify one action was performed
|
||||||
@ -83,14 +83,14 @@ func TestOriginalObjectCaptured(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error: %v", err)
|
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")
|
t.Errorf("expected Action recorded to not be modified by ReactionFunc but it was")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestReactorChangesPersisted(t *testing.T) {
|
func TestReactorChangesPersisted(t *testing.T) {
|
||||||
// this ReactionFunc sets the resources ClusterName
|
// this ReactionFunc sets the resources SelfLink
|
||||||
const testClusterName = "some-value"
|
const testSelfLink = "some-value"
|
||||||
reactors := []ReactionFunc{
|
reactors := []ReactionFunc{
|
||||||
func(action Action) (bool, runtime.Object, error) {
|
func(action Action) (bool, runtime.Object, error) {
|
||||||
createAction := action.(CreateActionImpl)
|
createAction := action.(CreateActionImpl)
|
||||||
@ -100,7 +100,7 @@ func TestReactorChangesPersisted(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// set any field on the resource
|
// set any field on the resource
|
||||||
accessor.SetClusterName(testClusterName)
|
accessor.SetSelfLink(testSelfLink)
|
||||||
|
|
||||||
return false, createAction.Object, nil
|
return false, createAction.Object, nil
|
||||||
},
|
},
|
||||||
@ -111,8 +111,8 @@ func TestReactorChangesPersisted(t *testing.T) {
|
|||||||
return false, nil, err
|
return false, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// ensure the clusterName is set to testClusterName already
|
// ensure the selfLink is set to testSelfLink already
|
||||||
if accessor.GetClusterName() != testClusterName {
|
if accessor.GetSelfLink() != testSelfLink {
|
||||||
t.Errorf("expected resource passed to second reactor to be modified by first reactor")
|
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
|
// 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")
|
t.Errorf("expected resource returned by Invokes to be modified by the ReactionFunc")
|
||||||
}
|
}
|
||||||
// verify one action was performed
|
// verify one action was performed
|
||||||
@ -160,7 +160,7 @@ func TestReactorChangesPersisted(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error: %v", err)
|
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")
|
t.Errorf("expected Action recorded to not be modified by ReactionFunc but it was")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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"}}})
|
client := clientset.NewForConfigOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: &schema.GroupVersion{Group: "", Version: "v1"}}})
|
||||||
ns := v1.Namespace{
|
ns := v1.Namespace{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "test-namespace",
|
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{})
|
nsNew, err := client.CoreV1().Namespaces().Create(context.TODO(), &ns, metav1.CreateOptions{})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, ns.Name, nsNew.Name)
|
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{})
|
nsNew, err = client.CoreV1().Namespaces().Update(context.TODO(), &ns, metav1.UpdateOptions{})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, ns.Name, nsNew.Name)
|
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