Skip to content

Commit 52ddae0

Browse files
author
Kenichi Omichi
committed
Remove Delete/CreateSyncInNamespace()
DeleteSyncInNamespace() was used at an e2e node test and DeleteSync() only. In addition, the part of the e2e node test can be replaced with DeleteSync(). CreateSyncInNamespace() is the same thing and can be replaced with CreateSync(). So this replaces these functions and removes them for the cleanup.
1 parent a1364be commit 52ddae0

File tree

2 files changed

+6
-15
lines changed

2 files changed

+6
-15
lines changed

test/e2e/framework/pods.go

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,9 @@ func (c *PodClient) Create(pod *v1.Pod) *v1.Pod {
8383
return p
8484
}
8585

86-
// CreateSyncInNamespace creates a new pod according to the framework specifications in the given namespace, and waits for it to start.
87-
func (c *PodClient) CreateSyncInNamespace(pod *v1.Pod, namespace string) *v1.Pod {
86+
// CreateSync creates a new pod according to the framework specifications, and wait for it to start.
87+
func (c *PodClient) CreateSync(pod *v1.Pod) *v1.Pod {
88+
namespace := c.f.Namespace.Name
8889
p := c.Create(pod)
8990
ExpectNoError(e2epod.WaitForPodNameRunningInNamespace(c.f.ClientSet, p.Name, namespace))
9091
// Get the newest pod after it becomes running, some status may change after pod created, such as pod ip.
@@ -93,11 +94,6 @@ func (c *PodClient) CreateSyncInNamespace(pod *v1.Pod, namespace string) *v1.Pod
9394
return p
9495
}
9596

96-
// CreateSync creates a new pod according to the framework specifications, and wait for it to start.
97-
func (c *PodClient) CreateSync(pod *v1.Pod) *v1.Pod {
98-
return c.CreateSyncInNamespace(pod, c.f.Namespace.Name)
99-
}
100-
10197
// CreateBatch create a batch of pods. All pods are created before waiting.
10298
func (c *PodClient) CreateBatch(pods []*v1.Pod) []*v1.Pod {
10399
ps := make([]*v1.Pod, len(pods))
@@ -140,12 +136,7 @@ func (c *PodClient) Update(name string, updateFn func(pod *v1.Pod)) {
140136
// DeleteSync deletes the pod and wait for the pod to disappear for `timeout`. If the pod doesn't
141137
// disappear before the timeout, it will fail the test.
142138
func (c *PodClient) DeleteSync(name string, options *metav1.DeleteOptions, timeout time.Duration) {
143-
c.DeleteSyncInNamespace(name, c.f.Namespace.Name, options, timeout)
144-
}
145-
146-
// DeleteSyncInNamespace deletes the pod from the namespace and wait for the pod to disappear for `timeout`. If the pod doesn't
147-
// disappear before the timeout, it will fail the test.
148-
func (c *PodClient) DeleteSyncInNamespace(name string, namespace string, options *metav1.DeleteOptions, timeout time.Duration) {
139+
namespace := c.f.Namespace.Name
149140
err := c.Delete(name, options)
150141
if err != nil && !apierrors.IsNotFound(err) {
151142
Failf("Failed to delete pod %q: %v", name, err)

test/e2e_node/critical_pod_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ var _ = framework.KubeDescribe("CriticalPod [Serial] [Disruptive] [NodeFeature:C
8989

9090
// Create pods, starting with non-critical so that the critical preempts the other pods.
9191
f.PodClient().CreateBatch([]*v1.Pod{nonCriticalBestEffort, nonCriticalBurstable, nonCriticalGuaranteed})
92-
f.PodClientNS(kubeapi.NamespaceSystem).CreateSyncInNamespace(criticalPod, kubeapi.NamespaceSystem)
92+
f.PodClientNS(kubeapi.NamespaceSystem).CreateSync(criticalPod)
9393

9494
// Check that non-critical pods other than the besteffort have been evicted
9595
updatedPodList, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).List(metav1.ListOptions{})
@@ -107,7 +107,7 @@ var _ = framework.KubeDescribe("CriticalPod [Serial] [Disruptive] [NodeFeature:C
107107
f.PodClient().DeleteSync(guaranteedPodName, &metav1.DeleteOptions{}, framework.DefaultPodDeletionTimeout)
108108
f.PodClient().DeleteSync(burstablePodName, &metav1.DeleteOptions{}, framework.DefaultPodDeletionTimeout)
109109
f.PodClient().DeleteSync(bestEffortPodName, &metav1.DeleteOptions{}, framework.DefaultPodDeletionTimeout)
110-
f.PodClientNS(kubeapi.NamespaceSystem).DeleteSyncInNamespace(criticalPodName, kubeapi.NamespaceSystem, &metav1.DeleteOptions{}, framework.DefaultPodDeletionTimeout)
110+
f.PodClientNS(kubeapi.NamespaceSystem).DeleteSync(criticalPodName, &metav1.DeleteOptions{}, framework.DefaultPodDeletionTimeout)
111111
err := f.ClientSet.SchedulingV1().PriorityClasses().Delete(systemCriticalPriorityName, &metav1.DeleteOptions{})
112112
framework.ExpectNoError(err)
113113
// Log Events

0 commit comments

Comments
 (0)