Skip to content

Commit

Permalink
[YUNIKORN-1172] Clean up e2e test pods immediately
Browse files Browse the repository at this point in the history
  • Loading branch information
craigcondit committed Apr 6, 2022
1 parent be3bb70 commit 82a9a96
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
20 changes: 18 additions & 2 deletions test/e2e/framework/helpers/k8s/k8s_utils.go
Expand Up @@ -318,7 +318,10 @@ func (k *KubeCtl) isServiceAccountPresent(namespace string, svcAcctName string)
}

func (k *KubeCtl) DeleteNamespace(namespace string) error {
return k.clientSet.CoreV1().Namespaces().Delete(context.TODO(), namespace, metav1.DeleteOptions{})
var secs int64 = 0
return k.clientSet.CoreV1().Namespaces().Delete(context.TODO(), namespace, metav1.DeleteOptions{
GracePeriodSeconds: &secs,
})
}

func (k *KubeCtl) TearDownNamespace(namespace string) error {
Expand Down Expand Up @@ -375,7 +378,10 @@ func (k *KubeCtl) CreatePod(pod *v1.Pod, namespace string) (*v1.Pod, error) {
}

func (k *KubeCtl) DeletePod(podName string, namespace string) error {
err := k.clientSet.CoreV1().Pods(namespace).Delete(context.TODO(), podName, metav1.DeleteOptions{})
var secs int64 = 0
err := k.clientSet.CoreV1().Pods(namespace).Delete(context.TODO(), podName, metav1.DeleteOptions{
GracePeriodSeconds: &secs,
})
if err != nil {
return err
}
Expand All @@ -384,6 +390,16 @@ func (k *KubeCtl) DeletePod(podName string, namespace string) error {
return err
}

func (k *KubeCtl) DeletePodGracefully(podName string, namespace string) error {
err := k.clientSet.CoreV1().Pods(namespace).Delete(context.TODO(), podName, metav1.DeleteOptions{})
if err != nil {
return err
}

err = k.WaitForPodTerminated(namespace, podName, 120*time.Second)
return err
}

// return a condition function that indicates whether the given pod is
// currently in desired state
func (k *KubeCtl) isPodInDesiredState(podName string, namespace string, state v1.PodPhase) wait.ConditionFunc {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/recovery_and_restart/recovery_and_restart_test.go
Expand Up @@ -85,7 +85,7 @@ var _ = ginkgo.Describe("", func() {
ginkgo.By("Restart the scheduler pod")
schedulerPodName, err := kClient.GetSchedulerPod()
Ω(err).NotTo(gomega.HaveOccurred())
err = kClient.DeletePod(schedulerPodName, configmanager.YuniKornTestConfig.YkNamespace)
err = kClient.DeletePodGracefully(schedulerPodName, configmanager.YuniKornTestConfig.YkNamespace)
Ω(err).NotTo(gomega.HaveOccurred())
err = kClient.WaitForPodBySelectorRunning(configmanager.YuniKornTestConfig.YkNamespace, fmt.Sprintf("component=%s", configmanager.YKScheduler), 10)
Ω(err).NotTo(gomega.HaveOccurred())
Expand Down

0 comments on commit 82a9a96

Please sign in to comment.