-
Notifications
You must be signed in to change notification settings - Fork 40k
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
randomize pd test container name #27084
Conversation
Signed-off-by: Huamin Chen <hchen@redhat.com>
GCE e2e build/test passed for commit acfcbff. |
@@ -431,9 +427,10 @@ func detachPD(hostName, pdName string) error { | |||
func testPDPod(diskNames []string, targetHost string, readOnly bool, numContainers int) *api.Pod { | |||
containers := make([]api.Container, numContainers) | |||
for i := range containers { | |||
containers[i].Name = "mycontainer" | |||
name := "mycontainer" + strconv.Itoa(mathrand.Int()) |
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.
A monotonically increasing number unique to the program might work better here as it eliminates the chance of collision
LGTM with some comments. @saad-ali do you want to take a look? |
LGTM @rootfs did you run the tests to verify they are working. The merge bot doesn't run these tests. |
@saad-ali yes i ran tests overnight. |
Taking another look at this PR. It actually won't change anything since the pod/container names are still generated once per test. Every iteration creating and tearing down the same pod will still end up with the same pod/container name. Am I missing something? |
@saad-ali before this change, the container name is always 'mycontainer'. This change appends a random number to the container name like the following Jun 9 16:55:27.298: INFO: Running '/srv/dev/kubernetes/_output/local/bin/linux/amd64/kubectl exec --namespace=e2e-tests-pod-disks-lh723 pd-test-e8c5f20d-2e62-11e6-a1ff-b8ca3a62792c -c=mycontainer36928506542153397011 -- cat /testpd1/tracker2' |
From an exec standpoint, it's the pod name that needs to be unique, not the container name. It looks like that's already unique per pod (https://github.com/rootfs/kubernetes/blob/acfcbffd42ae92242c0b949f938152b3814de9c6/test/e2e/pd.go#L457)? |
thanks @ncdc for the insight. The Pod name is created before the test starts, so even it is unique between tests, it is still deterministic in the same test https://github.com/rootfs/kubernetes/blob/acfcbffd42ae92242c0b949f938152b3814de9c6/test/e2e/pd.go#L180 |
Ok, yeah, I didn't have a chance to read through the entire test file to find that. So yes, you need to create a new pod for each test case and test iteration, especially if you're deleting a pod and recreating. |
Let me check the failed the tests again. |
@ncdc @saad-ali the following log from doesn't convince me this fix can help. .In the failure, the container names were different (mycontainer3 and mycontainer4) and yet still failed
|
Correct, this won't help. You can't do this reliably:
The problem is that you have 2 pods with the same name but different UUIDs, and exec doesn't support UUIDs right now, so it picks the "wrong" (deleted) pod from steps 1/2. |
fix #26141
based on comments from @ncdc