e2e can't use both pod.Name and pod.GenerateName

This fixes a problem when using the framework helper
e2epod.CreateExecPodOrFail() more than once in the same test.

The problem is that this function was creating pods with both the
pod.Name and pod.GenerateName set.
The second pod failed to be created with a 500 with Reason ServerTimeout
indicating a unique name could not be found in the time allotted,
xref https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/
This commit is contained in:
Antonio Ojea 2020-10-01 12:28:06 +02:00
parent aa1f912868
commit 3e182e84ea

View File

@ -456,7 +456,9 @@ func NewExecPodSpec(ns, name string, hostNetwork bool) *v1.Pod {
// newExecPodSpec returns the pod spec of exec pod
func newExecPodSpec(ns, generateName string) *v1.Pod {
pod := NewAgnhostPod(ns, "agnhost-pod", nil, nil, nil)
// GenerateName is an optional prefix, used by the server,
// to generate a unique name ONLY IF the Name field has not been provided
pod := NewAgnhostPod(ns, "", nil, nil, nil)
pod.ObjectMeta.GenerateName = generateName
return pod
}