diff --git a/pkg/kubelet/config/common.go b/pkg/kubelet/config/common.go index 4dd515d33fe..7dade01b9c3 100644 --- a/pkg/kubelet/config/common.go +++ b/pkg/kubelet/config/common.go @@ -80,8 +80,6 @@ func applyDefaults(pod *api.Pod, source string, isFile bool, nodeName types.Node // Set the Host field to indicate this pod is scheduled on the current node. pod.Spec.NodeName = string(nodeName) - pod.ObjectMeta.SelfLink = getSelfLink(pod.Name, pod.Namespace) - if pod.Annotations == nil { pod.Annotations = make(map[string]string) } @@ -102,15 +100,6 @@ func applyDefaults(pod *api.Pod, source string, isFile bool, nodeName types.Node return nil } -func getSelfLink(name, namespace string) string { - var selfLink string - if len(namespace) == 0 { - namespace = metav1.NamespaceDefault - } - selfLink = fmt.Sprintf("/api/v1/namespaces/%s/pods/%s", namespace, name) - return selfLink -} - type defaultFunc func(pod *api.Pod) error // tryDecodeSinglePod takes data and tries to extract valid Pod config information from it. diff --git a/pkg/kubelet/config/common_test.go b/pkg/kubelet/config/common_test.go index 00cbc4d7ca3..008fd8fc577 100644 --- a/pkg/kubelet/config/common_test.go +++ b/pkg/kubelet/config/common_test.go @@ -186,34 +186,6 @@ func TestDecodePodList(t *testing.T) { } } -func TestGetSelfLink(t *testing.T) { - var testCases = []struct { - desc string - name string - namespace string - expectedSelfLink string - }{ - { - desc: "No namespace specified", - name: "foo", - namespace: "", - expectedSelfLink: "/api/v1/namespaces/default/pods/foo", - }, - { - desc: "Namespace specified", - name: "foo", - namespace: "bar", - expectedSelfLink: "/api/v1/namespaces/bar/pods/foo", - }, - } - for _, testCase := range testCases { - selfLink := getSelfLink(testCase.name, testCase.namespace) - if testCase.expectedSelfLink != selfLink { - t.Errorf("%s: getSelfLink error, expected: %s, got: %s", testCase.desc, testCase.expectedSelfLink, selfLink) - } - } -} - func TestStaticPodNameGenerate(t *testing.T) { testCases := []struct { nodeName types.NodeName diff --git a/pkg/kubelet/config/file_linux_test.go b/pkg/kubelet/config/file_linux_test.go index 1d234c226de..bcc97de1754 100644 --- a/pkg/kubelet/config/file_linux_test.go +++ b/pkg/kubelet/config/file_linux_test.go @@ -173,7 +173,6 @@ func getTestCases(hostname types.NodeName) []*testCase { UID: "12345", Namespace: "mynamespace", Annotations: map[string]string{kubetypes.ConfigHashAnnotationKey: "12345"}, - SelfLink: getSelfLink("test-"+string(hostname), "mynamespace"), }, Spec: v1.PodSpec{ NodeName: string(hostname), diff --git a/pkg/kubelet/config/http_test.go b/pkg/kubelet/config/http_test.go index e99f5ac961d..879accb770d 100644 --- a/pkg/kubelet/config/http_test.go +++ b/pkg/kubelet/config/http_test.go @@ -164,7 +164,6 @@ func TestExtractPodsFromHTTP(t *testing.T) { Name: "foo" + "-" + nodeName, Namespace: "mynamespace", Annotations: map[string]string{kubetypes.ConfigHashAnnotationKey: "111"}, - SelfLink: getSelfLink("foo-"+nodeName, "mynamespace"), }, Spec: v1.PodSpec{ NodeName: nodeName, @@ -236,7 +235,6 @@ func TestExtractPodsFromHTTP(t *testing.T) { Name: "foo" + "-" + nodeName, Namespace: "default", Annotations: map[string]string{kubetypes.ConfigHashAnnotationKey: "111"}, - SelfLink: getSelfLink("foo-"+nodeName, metav1.NamespaceDefault), }, Spec: v1.PodSpec{ NodeName: nodeName, @@ -265,7 +263,6 @@ func TestExtractPodsFromHTTP(t *testing.T) { Name: "bar" + "-" + nodeName, Namespace: "default", Annotations: map[string]string{kubetypes.ConfigHashAnnotationKey: "222"}, - SelfLink: getSelfLink("bar-"+nodeName, metav1.NamespaceDefault), }, Spec: v1.PodSpec{ NodeName: nodeName, diff --git a/pkg/kubelet/container/ref.go b/pkg/kubelet/container/ref.go index 3d366dc188c..e4f860378a1 100644 --- a/pkg/kubelet/container/ref.go +++ b/pkg/kubelet/container/ref.go @@ -32,9 +32,6 @@ var ImplicitContainerPrefix = "implicitly required container " // GenerateContainerRef returns an *v1.ObjectReference which references the given container // within the given pod. Returns an error if the reference can't be constructed or the // container doesn't actually belong to the pod. -// -// This function will return an error if the provided Pod does not have a selfLink, -// but we expect selfLink to be populated at all call sites for the function. func GenerateContainerRef(pod *v1.Pod, container *v1.Container) (*v1.ObjectReference, error) { fieldPath, err := fieldPath(pod, container) if err != nil { diff --git a/pkg/kubelet/container/ref_test.go b/pkg/kubelet/container/ref_test.go index 3d05cf1e138..a10ba5268ef 100644 --- a/pkg/kubelet/container/ref_test.go +++ b/pkg/kubelet/container/ref_test.go @@ -74,7 +74,6 @@ func TestGenerateContainerRef(t *testing.T) { Namespace: "test-ns", UID: "bar", ResourceVersion: "42", - SelfLink: "/api/v1/pods/foo", }, Spec: v1.PodSpec{ Containers: []v1.Container{ @@ -85,13 +84,7 @@ func TestGenerateContainerRef(t *testing.T) { }, }, } - noSelfLinkPod = okPod - defaultedSelfLinkPod = okPod ) - noSelfLinkPod.Kind = "" - noSelfLinkPod.APIVersion = "" - noSelfLinkPod.ObjectMeta.SelfLink = "" - defaultedSelfLinkPod.ObjectMeta.SelfLink = "/api/v1/pods/ok" cases := []struct { name string @@ -132,23 +125,6 @@ func TestGenerateContainerRef(t *testing.T) { }, success: true, }, - { - name: "defaulted-selflink", - pod: &defaultedSelfLinkPod, - container: &v1.Container{ - Name: "by-name", - }, - expected: &v1.ObjectReference{ - Kind: "Pod", - APIVersion: "v1", - Name: "ok", - Namespace: "test-ns", - UID: "bar", - ResourceVersion: "42", - FieldPath: ".spec.containers{by-name}", - }, - success: true, - }, { name: "implicitly-required", pod: &okPod, diff --git a/pkg/kubelet/images/image_manager_test.go b/pkg/kubelet/images/image_manager_test.go index 82b3a4709e4..daaba231c00 100644 --- a/pkg/kubelet/images/image_manager_test.go +++ b/pkg/kubelet/images/image_manager_test.go @@ -187,7 +187,6 @@ func TestParallelPuller(t *testing.T) { Namespace: "test-ns", UID: "bar", ResourceVersion: "42", - SelfLink: "/api/v1/pods/foo", }} cases := pullerTestCases() @@ -215,7 +214,6 @@ func TestSerializedPuller(t *testing.T) { Namespace: "test-ns", UID: "bar", ResourceVersion: "42", - SelfLink: "/api/v1/pods/foo", }} cases := pullerTestCases() @@ -264,7 +262,6 @@ func TestPullAndListImageWithPodAnnotations(t *testing.T) { Namespace: "test-ns", UID: "bar", ResourceVersion: "42", - SelfLink: "/api/v1/pods/foo", Annotations: map[string]string{ "kubernetes.io/runtimehandler": "handler_name", }, diff --git a/pkg/kubelet/kubeletconfig/checkpoint/download.go b/pkg/kubelet/kubeletconfig/checkpoint/download.go index 1b2a3c852ad..e5771ff7b2d 100644 --- a/pkg/kubelet/kubeletconfig/checkpoint/download.go +++ b/pkg/kubelet/kubeletconfig/checkpoint/download.go @@ -60,7 +60,7 @@ type RemoteConfigSource interface { // KubeletFilename returns the name of the Kubelet config file as it should appear in the keys of Payload.Files() KubeletFilename() string - // APIPath returns the API path to the remote resource, e.g. its SelfLink + // APIPath returns the API path to the remote resource. APIPath() string // UID returns the globally unique identifier for the most recently downloaded payload targeted by the source.