Commit 9de35403 authored by Jing Xu's avatar Jing Xu

Make sure kubelet is restarted in the storage test

In some storage tests, kubelet is stopped first and the test check node NotReady state. However, if it fails to have this state, kubelet could not be restarted because the defer function is placed after the stop kubelet command. This PR fixes this issue.
parent bc79dcfd
......@@ -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))
}
By("Stopping the kubelet.")
KubeletCommand(KStop, c, clientPod)
// This command is to make sure kubelet is started after test finishes no matter it fails or not.
defer func() {
if err != nil {
KubeletCommand(KStart, c, clientPod)
}
KubeletCommand(KStart, c, clientPod)
}()
By("Stopping the kubelet.")
KubeletCommand(KStop, c, clientPod)
By(fmt.Sprintf("Deleting Pod %q", clientPod.Name))
if forceDelete {
err = c.CoreV1().Pods(clientPod.Namespace).Delete(clientPod.Name, metav1.NewDeleteOptions(0))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment