mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 05:27:21 +00:00
Merge pull request #69944 from jingxu97/defertest
Make sure kubelet is restarted after it is stopped in the test
This commit is contained in:
commit
0ab29b4852
@ -220,13 +220,13 @@ func TestVolumeUnmountsFromDeletedPodWithForceOption(c clientset.Interface, f *f
|
|||||||
Expect(result.Code).To(BeZero(), fmt.Sprintf("Expected grep exit code of 0, got %d", result.Code))
|
Expect(result.Code).To(BeZero(), fmt.Sprintf("Expected grep exit code of 0, got %d", result.Code))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This command is to make sure kubelet is started after test finishes no matter it fails or not.
|
||||||
|
defer func() {
|
||||||
|
KubeletCommand(KStart, c, clientPod)
|
||||||
|
}()
|
||||||
By("Stopping the kubelet.")
|
By("Stopping the kubelet.")
|
||||||
KubeletCommand(KStop, c, clientPod)
|
KubeletCommand(KStop, c, clientPod)
|
||||||
defer func() {
|
|
||||||
if err != nil {
|
|
||||||
KubeletCommand(KStart, c, clientPod)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
By(fmt.Sprintf("Deleting Pod %q", clientPod.Name))
|
By(fmt.Sprintf("Deleting Pod %q", clientPod.Name))
|
||||||
if forceDelete {
|
if forceDelete {
|
||||||
err = c.CoreV1().Pods(clientPod.Namespace).Delete(clientPod.Name, metav1.NewDeleteOptions(0))
|
err = c.CoreV1().Pods(clientPod.Namespace).Delete(clientPod.Name, metav1.NewDeleteOptions(0))
|
||||||
|
Loading…
Reference in New Issue
Block a user