mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 06:27:05 +00:00
Merge pull request #3242 from thockin/name_is_required
Never set pod.Name in kubelet config code
This commit is contained in:
commit
2c25ca229f
@ -19,7 +19,6 @@ package config
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"path"
|
||||
"strconv"
|
||||
"time"
|
||||
@ -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)
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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",
|
||||
},
|
||||
@ -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()
|
||||
@ -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)
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user