-
Notifications
You must be signed in to change notification settings - Fork 38.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shorten eviction tests, and increase test suite timeout #46441
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ package e2e_node | |
|
||
import ( | ||
"fmt" | ||
"path/filepath" | ||
"time" | ||
|
||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
@@ -45,44 +46,37 @@ const ( | |
var _ = framework.KubeDescribe("InodeEviction [Slow] [Serial] [Disruptive] [Flaky]", func() { | ||
f := framework.NewDefaultFramework("inode-eviction-test") | ||
|
||
volumeMountPath := "/test-empty-dir-mnt" | ||
podTestSpecs := []podTestSpec{ | ||
{ | ||
evictionPriority: 1, // This pod should be evicted before the normal memory usage pod | ||
pod: v1.Pod{ | ||
pod: &v1.Pod{ | ||
ObjectMeta: metav1.ObjectMeta{Name: "container-inode-hog-pod"}, | ||
Spec: v1.PodSpec{ | ||
RestartPolicy: v1.RestartPolicyNever, | ||
Containers: []v1.Container{ | ||
{ | ||
Image: "gcr.io/google_containers/busybox:1.24", | ||
Name: "container-inode-hog-pod", | ||
Command: []string{ | ||
"sh", | ||
"-c", // Make 100 billion small files (more than we have inodes) | ||
"i=0; while [[ $i -lt 100000000000 ]]; do touch smallfile$i.txt; sleep 0.001; i=$((i+=1)); done;", | ||
}, | ||
Image: "gcr.io/google_containers/busybox:1.24", | ||
Name: "container-inode-hog-container", | ||
Command: getInodeConsumingCommand(""), | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
evictionPriority: 1, // This pod should be evicted before the normal memory usage pod | ||
pod: v1.Pod{ | ||
pod: &v1.Pod{ | ||
ObjectMeta: metav1.ObjectMeta{Name: "volume-inode-hog-pod"}, | ||
Spec: v1.PodSpec{ | ||
RestartPolicy: v1.RestartPolicyNever, | ||
Containers: []v1.Container{ | ||
{ | ||
Image: "gcr.io/google_containers/busybox:1.24", | ||
Name: "volume-inode-hog-pod", | ||
Command: []string{ | ||
"sh", | ||
"-c", // Make 100 billion small files (more than we have inodes) | ||
"i=0; while [[ $i -lt 100000000000 ]]; do touch /test-empty-dir-mnt/smallfile$i.txt; sleep 0.001; i=$((i+=1)); done;", | ||
}, | ||
Image: "gcr.io/google_containers/busybox:1.24", | ||
Name: "volume-inode-hog-container", | ||
Command: getInodeConsumingCommand(volumeMountPath), | ||
VolumeMounts: []v1.VolumeMount{ | ||
{MountPath: "/test-empty-dir-mnt", Name: "test-empty-dir"}, | ||
{MountPath: volumeMountPath, Name: "test-empty-dir"}, | ||
}, | ||
}, | ||
}, | ||
|
@@ -94,31 +88,15 @@ var _ = framework.KubeDescribe("InodeEviction [Slow] [Serial] [Disruptive] [Flak | |
}, | ||
{ | ||
evictionPriority: 0, // This pod should never be evicted | ||
pod: v1.Pod{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The original test case seems useful, why don't we keep it? |
||
ObjectMeta: metav1.ObjectMeta{Name: "normal-memory-usage-pod"}, | ||
Spec: v1.PodSpec{ | ||
RestartPolicy: v1.RestartPolicyNever, | ||
Containers: []v1.Container{ | ||
{ | ||
Image: "gcr.io/google_containers/busybox:1.24", | ||
Name: "normal-memory-usage-pod", | ||
Command: []string{ | ||
"sh", | ||
"-c", //make one big (5 Gb) file | ||
"dd if=/dev/urandom of=largefile bs=5000000000 count=1; while true; do sleep 5; done", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
pod: getInnocentPod(), | ||
}, | ||
} | ||
evictionTestTimeout := 30 * time.Minute | ||
testCondition := "Disk Pressure due to Inodes" | ||
|
||
Context(fmt.Sprintf("when we run containers that should cause %s", testCondition), func() { | ||
tempSetCurrentKubeletConfig(f, func(initialConfig *componentconfig.KubeletConfiguration) { | ||
initialConfig.EvictionHard = "nodefs.inodesFree<50%" | ||
initialConfig.EvictionHard = "nodefs.inodesFree<70%" | ||
}) | ||
// Place the remainder of the test within a context so that the kubelet config is set before and after the test. | ||
Context("With kubeconfig updated", func() { | ||
|
@@ -133,7 +111,7 @@ type podTestSpec struct { | |
// If two are ranked at 1, either is permitted to fail before the other. | ||
// The test ends when all other than the 0 have been evicted | ||
evictionPriority int | ||
pod v1.Pod | ||
pod *v1.Pod | ||
} | ||
|
||
// runEvictionTest sets up a testing environment given the provided nodes, and checks a few things: | ||
|
@@ -148,7 +126,7 @@ func runEvictionTest(f *framework.Framework, testCondition string, podTestSpecs | |
By("seting up pods to be used by tests") | ||
for _, spec := range podTestSpecs { | ||
By(fmt.Sprintf("creating pod with container: %s", spec.pod.Name)) | ||
f.PodClient().CreateSync(&spec.pod) | ||
f.PodClient().CreateSync(spec.pod) | ||
} | ||
}) | ||
|
||
|
@@ -342,3 +320,32 @@ func hasInodePressure(f *framework.Framework, testCondition string) (bool, error | |
} | ||
return hasPressure, nil | ||
} | ||
|
||
// returns a pod that does not use any resources | ||
func getInnocentPod() *v1.Pod { | ||
return &v1.Pod{ | ||
ObjectMeta: metav1.ObjectMeta{Name: "innocent-pod"}, | ||
Spec: v1.PodSpec{ | ||
RestartPolicy: v1.RestartPolicyNever, | ||
Containers: []v1.Container{ | ||
{ | ||
Image: "gcr.io/google_containers/busybox:1.24", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Why not just use pause container? |
||
Name: "innocent-container", | ||
Command: []string{ | ||
"sh", | ||
"-c", //make one large file | ||
"dd if=/dev/urandom of=largefile bs=5000000000 count=1; while true; do sleep 5; done", | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func getInodeConsumingCommand(path string) []string { | ||
return []string{ | ||
"sh", | ||
"-c", | ||
fmt.Sprintf("i=0; while true; do touch %s${i}.txt; sleep 0.001; i=$((i+=1)); done;", filepath.Join(path, "smallfile")), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So you're using default eviction threshold? Why did you remove the configuration?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the default is 250Mb. 10% seemed arbitrary, and I think using the default is a better way to check if it is working.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then please add a comment here to explain that. :)