Skip to content

Commit

Permalink
Merge pull request kubernetes#3242 from thockin/name_is_required
Browse files Browse the repository at this point in the history
Never set pod.Name in kubelet config code
  • Loading branch information
erictune committed Jan 6, 2015
2 parents 823d878 + 88fe5c6 commit 2c25ca2
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 13 deletions.
6 changes: 1 addition & 5 deletions pkg/kubelet/config/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package config

import (
"errors"
"fmt"
"path"
"strconv"
"time"
Expand Down Expand Up @@ -93,10 +92,7 @@ func eventToPods(ev watch.Event) ([]api.BoundPod, error) {
return pods, errors.New("unable to parse response as BoundPods")
}

for i, pod := range boundPods.Items {
if len(pod.Name) == 0 {
pod.Name = fmt.Sprintf("%d", i+1)
}
for _, pod := range boundPods.Items {
// TODO: generate random UID if not present
if pod.UID == "" && !pod.CreationTimestamp.IsZero() {
pod.UID = strconv.FormatInt(pod.CreationTimestamp.Unix(), 10)
Expand Down
1 change: 0 additions & 1 deletion pkg/kubelet/config/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ func extractFromFile(filename string) (api.BoundPod, error) {
return pod, fmt.Errorf("can't convert pod from file %q: %v", filename, err)
}

pod.Name = simpleSubdomainSafeHash(filename)
if len(pod.UID) == 0 {
pod.UID = simpleSubdomainSafeHash(filename)
}
Expand Down
5 changes: 1 addition & 4 deletions pkg/kubelet/config/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func TestReadFromFile(t *testing.T) {
update := got.(kubelet.PodUpdate)
expected := CreatePodUpdate(kubelet.SET, kubelet.FileSource, api.BoundPod{
ObjectMeta: api.ObjectMeta{
Name: simpleSubdomainSafeHash(file.Name()),
Name: "test",
UID: simpleSubdomainSafeHash(file.Name()),
Namespace: "default",
},
Expand Down Expand Up @@ -161,8 +161,6 @@ func TestExtractFromValidDataFile(t *testing.T) {
file := writeTestFile(t, os.TempDir(), "test_pod_config", string(text))
defer os.Remove(file.Name())

expectedPod.Name = simpleSubdomainSafeHash(file.Name())

ch := make(chan interface{}, 1)
c := sourceFile{file.Name(), ch}
err = c.extractFromPath()
Expand Down Expand Up @@ -228,7 +226,6 @@ func TestExtractFromDir(t *testing.T) {
}
ioutil.WriteFile(name, data, 0755)
files[i] = file
pods[i].Name = simpleSubdomainSafeHash(name)
}

ch := make(chan interface{}, 1)
Expand Down
3 changes: 0 additions & 3 deletions pkg/kubelet/config/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,6 @@ func (s *sourceURL) extractFromURL() error {
if err := api.Scheme.Convert(&manifest, &pod); err != nil {
return err
}
if len(pod.Name) == 0 {
pod.Name = "1"
}
if len(pod.Namespace) == 0 {
pod.Namespace = api.NamespaceDefault
}
Expand Down

0 comments on commit 2c25ca2

Please sign in to comment.