Skip to content

Commit 8337206

Browse files
author
Kevin Taylor
committed
Fix pod creation for node e2e tests
1 parent 076af3d commit 8337206

File tree

1 file changed

+16
-20
lines changed

1 file changed

+16
-20
lines changed

test/e2e/common/expansion.go

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -376,14 +376,12 @@ var _ = framework.KubeDescribe("Variable Expansion", func() {
376376
}
377377

378378
By("creating the pod with failed condition")
379-
pod, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(pod)
380-
Expect(err).ToNot(HaveOccurred(), "while creating pod")
381-
382-
err = framework.WaitTimeoutForPodRunningInNamespace(f.ClientSet, pod.Name, pod.Namespace, framework.PodStartShortTimeout)
383-
Expect(err).To(HaveOccurred(), "while waiting for pod to be running")
384-
385379
var podClient *framework.PodClient
386380
podClient = f.PodClient()
381+
pod = podClient.Create(pod)
382+
383+
err := framework.WaitTimeoutForPodRunningInNamespace(f.ClientSet, pod.Name, pod.Namespace, framework.PodStartShortTimeout)
384+
Expect(err).To(HaveOccurred(), "while waiting for pod to be running")
387385

388386
By("updating the pod")
389387
podClient.Update(podName, func(pod *v1.Pod) {
@@ -470,10 +468,12 @@ var _ = framework.KubeDescribe("Variable Expansion", func() {
470468
}
471469

472470
By("creating the pod")
473-
pod, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(pod)
471+
var podClient *framework.PodClient
472+
podClient = f.PodClient()
473+
pod = podClient.Create(pod)
474474

475475
By("waiting for pod running")
476-
err = framework.WaitTimeoutForPodRunningInNamespace(f.ClientSet, pod.Name, pod.Namespace, framework.PodStartShortTimeout)
476+
err := framework.WaitTimeoutForPodRunningInNamespace(f.ClientSet, pod.Name, pod.Namespace, framework.PodStartShortTimeout)
477477
Expect(err).NotTo(HaveOccurred(), "while waiting for pod to be running")
478478

479479
By("creating a file in subpath")
@@ -491,9 +491,6 @@ var _ = framework.KubeDescribe("Variable Expansion", func() {
491491
}
492492

493493
By("updating the annotation value")
494-
var podClient *framework.PodClient
495-
podClient = f.PodClient()
496-
497494
podClient.Update(podName, func(pod *v1.Pod) {
498495
pod.ObjectMeta.Annotations["mysubpath"] = "mynewpath"
499496
})
@@ -609,17 +606,15 @@ var _ = framework.KubeDescribe("Variable Expansion", func() {
609606

610607
// Start pod
611608
By(fmt.Sprintf("Creating pod %s", pod.Name))
612-
pod, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(pod)
613-
Expect(err).ToNot(HaveOccurred(), "while creating pod")
609+
var podClient *framework.PodClient
610+
podClient = f.PodClient()
611+
pod = podClient.Create(pod)
614612
defer func() {
615613
framework.DeletePodWithWait(f, f.ClientSet, pod)
616614
}()
617-
err = framework.WaitForPodRunningInNamespace(f.ClientSet, pod)
615+
err := framework.WaitForPodRunningInNamespace(f.ClientSet, pod)
618616
Expect(err).ToNot(HaveOccurred(), "while waiting for pod to be running")
619617

620-
var podClient *framework.PodClient
621-
podClient = f.PodClient()
622-
623618
By("updating the pod")
624619
podClient.Update(podName, func(pod *v1.Pod) {
625620
pod.ObjectMeta.Annotations = map[string]string{"mysubpath": "newsubpath"}
@@ -645,14 +640,15 @@ var _ = framework.KubeDescribe("Variable Expansion", func() {
645640

646641
func testPodFailSubpath(f *framework.Framework, pod *v1.Pod) {
647642

648-
pod, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(pod)
649-
Expect(err).ToNot(HaveOccurred(), "while creating pod")
643+
var podClient *framework.PodClient
644+
podClient = f.PodClient()
645+
pod = podClient.Create(pod)
650646

651647
defer func() {
652648
framework.DeletePodWithWait(f, f.ClientSet, pod)
653649
}()
654650

655-
err = framework.WaitTimeoutForPodRunningInNamespace(f.ClientSet, pod.Name, pod.Namespace, framework.PodStartShortTimeout)
651+
err := framework.WaitTimeoutForPodRunningInNamespace(f.ClientSet, pod.Name, pod.Namespace, framework.PodStartShortTimeout)
656652
Expect(err).To(HaveOccurred(), "while waiting for pod to be running")
657653
}
658654

0 commit comments

Comments
 (0)