Merge pull request #9807 from krousey/container_manifest

Removing ContainerManifest
This commit is contained in:
Maxwell Forbes
2015-06-24 17:55:29 -07:00
15 changed files with 26 additions and 360 deletions

View File

@@ -52,11 +52,6 @@ func applyDefaults(pod *api.Pod, source string, isFile bool, nodeName string) er
glog.V(5).Infof("Generated UID %q pod %q from %s", pod.UID, pod.Name, source)
}
// This is required for backward compatibility, and should be removed once we
// completely deprecate ContainerManifest.
if len(pod.Name) == 0 {
pod.Name = string(pod.UID)
}
pod.Name = generatePodName(pod.Name, nodeName)
glog.V(5).Infof("Generated Name %q for UID %q from URL %s", pod.Name, pod.UID, source)

View File

@@ -110,41 +110,6 @@ func TestReadPodsFromFile(t *testing.T) {
},
}),
},
{
desc: "Pod without ID",
pod: &api.Pod{
TypeMeta: api.TypeMeta{
Kind: "Pod",
APIVersion: "",
},
ObjectMeta: api.ObjectMeta{
// No name
UID: "12345",
},
Spec: api.PodSpec{
Containers: []api.Container{{Name: "image", Image: "test/image", SecurityContext: securitycontext.ValidSecurityContextWithContainerDefaults()}},
},
},
expected: CreatePodUpdate(kubelet.SET, kubelet.FileSource, &api.Pod{
ObjectMeta: api.ObjectMeta{
Name: "12345-" + hostname,
UID: "12345",
Namespace: kubelet.NamespaceDefault,
SelfLink: getSelfLink("12345-"+hostname, kubelet.NamespaceDefault),
},
Spec: api.PodSpec{
NodeName: hostname,
RestartPolicy: api.RestartPolicyAlways,
DNSPolicy: api.DNSClusterFirst,
Containers: []api.Container{{
Name: "image",
Image: "test/image",
TerminationMessagePath: "/dev/termination-log",
ImagePullPolicy: "IfNotPresent",
SecurityContext: securitycontext.ValidSecurityContextWithContainerDefaults()}},
},
}),
},
}
for _, testCase := range testCases {
@@ -152,7 +117,7 @@ func TestReadPodsFromFile(t *testing.T) {
var versionedPod runtime.Object
err := testapi.Converter().Convert(&testCase.pod, &versionedPod)
if err != nil {
t.Fatalf("error in versioning the pod: %s", testCase.desc, err)
t.Fatalf("%s: error in versioning the pod: %v", testCase.desc, err)
}
fileContents, err := testapi.Codec().Encode(versionedPod)
if err != nil {

View File

@@ -50,55 +50,58 @@ func TestExtractFromHttpBadness(t *testing.T) {
expectEmptyChannel(t, ch)
}
func TestExtractInvalidManifest(t *testing.T) {
func TestExtractInvalidPods(t *testing.T) {
var testCases = []struct {
desc string
manifests interface{}
desc string
pod *api.Pod
}{
{
desc: "No version",
manifests: []api.ContainerManifest{{Version: ""}},
desc: "No version",
pod: &api.Pod{TypeMeta: api.TypeMeta{APIVersion: ""}},
},
{
desc: "Invalid version",
manifests: []api.ContainerManifest{{Version: "v1betta2"}},
desc: "Invalid version",
pod: &api.Pod{TypeMeta: api.TypeMeta{APIVersion: "v1betta2"}},
},
{
desc: "Invalid volume name",
manifests: []api.ContainerManifest{
{Version: testapi.Version(), Volumes: []api.Volume{{Name: "_INVALID_"}}},
pod: &api.Pod{
TypeMeta: api.TypeMeta{APIVersion: testapi.Version()},
Spec: api.PodSpec{
Volumes: []api.Volume{{Name: "_INVALID_"}},
},
},
},
{
desc: "Duplicate volume names",
manifests: []api.ContainerManifest{
{
Version: testapi.Version(),
pod: &api.Pod{
TypeMeta: api.TypeMeta{APIVersion: testapi.Version()},
Spec: api.PodSpec{
Volumes: []api.Volume{{Name: "repeated"}, {Name: "repeated"}},
},
},
},
{
desc: "Unspecified container name",
manifests: []api.ContainerManifest{
{
Version: testapi.Version(),
pod: &api.Pod{
TypeMeta: api.TypeMeta{APIVersion: testapi.Version()},
Spec: api.PodSpec{
Containers: []api.Container{{Name: ""}},
},
},
},
{
desc: "Invalid container name",
manifests: []api.ContainerManifest{
{
Version: testapi.Version(),
pod: &api.Pod{
TypeMeta: api.TypeMeta{APIVersion: testapi.Version()},
Spec: api.PodSpec{
Containers: []api.Container{{Name: "_INVALID_"}},
},
},
},
}
for _, testCase := range testCases {
data, err := json.Marshal(testCase.manifests)
data, err := json.Marshal(testCase.pod)
if err != nil {
t.Fatalf("%s: Some weird json problem: %v", testCase.desc, err)
}

View File

@@ -109,7 +109,7 @@ func verifyPackUnpack(t *testing.T, podNamespace, podUID, podName, containerName
}
}
func TestContainerManifestNaming(t *testing.T) {
func TestContainerNaming(t *testing.T) {
podUID := "12345678"
verifyPackUnpack(t, "file", podUID, "name", "container")
verifyPackUnpack(t, "file", podUID, "name-with-dashes", "container")