Fix default resource limits (node capacities) for downward api volumes

This commit is contained in:
Avesh Agarwal
2016-07-26 18:04:03 -04:00
committed by Avesh
parent 431e7ce1ab
commit 52a60fe3be
11 changed files with 127 additions and 31 deletions

View File

@@ -163,6 +163,20 @@ var _ = framework.KubeDescribe("Downward API volume", func() {
})
})
It("should provide node allocatable (cpu) as default cpu limit if the limit is not set", func() {
podName := "downwardapi-volume-" + string(uuid.NewUUID())
pod := downwardAPIVolumeForDefaultContainerResources(podName, "/etc/cpu_limit")
f.TestContainerOutputRegexp("downward API volume plugin", pod, 0, []string{"[1-9]"})
})
It("should provide node allocatable (memory) as default memory limit if the limit is not set", func() {
podName := "downwardapi-volume-" + string(uuid.NewUUID())
pod := downwardAPIVolumeForDefaultContainerResources(podName, "/etc/memory_limit")
f.TestContainerOutputRegexp("downward API volume plugin", pod, 0, []string{"[1-9]"})
})
})
func downwardAPIVolumePodForSimpleTest(name string, filePath string) *api.Pod {
@@ -192,6 +206,12 @@ func downwardAPIVolumeForContainerResources(name string, filePath string) *api.P
return pod
}
func downwardAPIVolumeForDefaultContainerResources(name string, filePath string) *api.Pod {
pod := downwardAPIVolumeBasePod(name, nil, nil)
pod.Spec.Containers = downwardAPIVolumeDefaultBaseContainer("client-container", filePath)
return pod
}
func downwardAPIVolumeBaseContainers(name, filePath string) []api.Container {
return []api.Container{
{
@@ -220,6 +240,23 @@ func downwardAPIVolumeBaseContainers(name, filePath string) []api.Container {
}
func downwardAPIVolumeDefaultBaseContainer(name, filePath string) []api.Container {
return []api.Container{
{
Name: name,
Image: "gcr.io/google_containers/mounttest:0.6",
Command: []string{"/mt", "--file_content=" + filePath},
VolumeMounts: []api.VolumeMount{
{
Name: "podinfo",
MountPath: "/etc",
},
},
},
}
}
func downwardAPIVolumePodForUpdateTest(name string, labels, annotations map[string]string, filePath string) *api.Pod {
pod := downwardAPIVolumeBasePod(name, labels, annotations)