mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-02 16:29:21 +00:00
replace c.Core with c.CoreV1; DeletePodWithWait check
This commit is contained in:
parent
5e6004c70c
commit
a192edd87f
@ -412,14 +412,32 @@ func DeletePodWithWait(f *Framework, c clientset.Interface, pod *v1.Pod) {
|
|||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
}
|
}
|
||||||
|
|
||||||
// wait for pod to terminate. Expect apierr NotFound
|
// wait for pod to terminate
|
||||||
err = f.WaitForPodTerminated(pod.Name, "")
|
err = f.WaitForPodTerminated(pod.Name, "")
|
||||||
Expect(err).To(HaveOccurred())
|
if err != nil {
|
||||||
if !apierrs.IsNotFound(err) {
|
Expect(apierrs.IsNotFound(err)).To(BeTrue(), fmt.Sprintf("Expected 'IsNotFound' error deleting pod \"%v/%v\", instead got: %v", pod.Namespace, pod.Name, err))
|
||||||
Logf("Error! Expected IsNotFound error deleting pod %q, instead got: %v", pod.Name, err)
|
Logf("Ignore \"not found\" error above")
|
||||||
Expect(apierrs.IsNotFound(err)).To(BeTrue())
|
|
||||||
}
|
}
|
||||||
Logf("Ignore \"not found\" error above. Pod %v successfully deleted", pod.Name)
|
Logf("Pod %q successfully deleted", pod.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create the test pod, wait for success, and then delete the pod.
|
||||||
|
func CreateWaitAndDeletePod(f *Framework, c clientset.Interface, ns string, claimName string) {
|
||||||
|
|
||||||
|
Logf("Creating nfs test pod")
|
||||||
|
|
||||||
|
// Make pod spec
|
||||||
|
pod := MakeWritePod(ns, claimName)
|
||||||
|
|
||||||
|
// Instantiate pod (Create)
|
||||||
|
runPod, err := c.CoreV1().Pods(ns).Create(pod)
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
Expect(runPod).NotTo(BeNil())
|
||||||
|
|
||||||
|
defer DeletePodWithWait(f, c, runPod)
|
||||||
|
|
||||||
|
// Wait for the test pod to complete its lifecycle
|
||||||
|
testPodSuccessOrFail(c, ns, runPod)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sanity check for GCE testing. Verify the persistent disk attached to the node.
|
// Sanity check for GCE testing. Verify the persistent disk attached to the node.
|
||||||
|
@ -104,7 +104,7 @@ func updateNodeLabels(c clientset.Interface, nodeNames sets.String, toAdd, toRem
|
|||||||
var node *v1.Node
|
var node *v1.Node
|
||||||
var err error
|
var err error
|
||||||
for i := 0; i < maxRetries; i++ {
|
for i := 0; i < maxRetries; i++ {
|
||||||
node, err = c.Core().Nodes().Get(nodeName, metav1.GetOptions{})
|
node, err = c.CoreV1().Nodes().Get(nodeName, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
framework.Logf("Error getting node %s: %v", nodeName, err)
|
framework.Logf("Error getting node %s: %v", nodeName, err)
|
||||||
continue
|
continue
|
||||||
@ -119,7 +119,7 @@ func updateNodeLabels(c clientset.Interface, nodeNames sets.String, toAdd, toRem
|
|||||||
delete(node.ObjectMeta.Labels, k)
|
delete(node.ObjectMeta.Labels, k)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_, err = c.Core().Nodes().Update(node)
|
_, err = c.CoreV1().Nodes().Update(node)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
framework.Logf("Error updating node %s: %v", nodeName, err)
|
framework.Logf("Error updating node %s: %v", nodeName, err)
|
||||||
} else {
|
} else {
|
||||||
@ -216,13 +216,13 @@ func createPodUsingNfs(f *framework.Framework, c clientset.Interface, ns, nfsIP,
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
rtnPod, err := c.Core().Pods(ns).Create(pod)
|
rtnPod, err := c.CoreV1().Pods(ns).Create(pod)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
err = f.WaitForPodReady(rtnPod.Name) // running & ready
|
err = f.WaitForPodReady(rtnPod.Name) // running & ready
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
rtnPod, err = c.Core().Pods(ns).Get(rtnPod.Name, metav1.GetOptions{}) // return fresh pod
|
rtnPod, err = c.CoreV1().Pods(ns).Get(rtnPod.Name, metav1.GetOptions{}) // return fresh pod
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
return rtnPod
|
return rtnPod
|
||||||
@ -443,11 +443,11 @@ var _ = framework.KubeDescribe("kubelet", func() {
|
|||||||
// fill in test slice for this context
|
// fill in test slice for this context
|
||||||
testTbl := []hostCleanupTest{
|
testTbl := []hostCleanupTest{
|
||||||
{
|
{
|
||||||
itDescr: "after deleting the nfs-server, the host should be cleaned-up when deleting sleeping pod which mounts an NFS vol",
|
itDescr: "after stopping the nfs-server and deleting the (sleeping) client pod, the NFS mount and the pod's UID directory should be removed.",
|
||||||
podCmd: "sleep 6000", // keep pod running
|
podCmd: "sleep 6000", // keep pod running
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
itDescr: "after deleting the nfs-server, the host should be cleaned-up when deleting a pod accessing the NFS vol",
|
itDescr: "after stopping the nfs-server and deleting the (active) client pod, the NFS mount and the pod's UID directory should be removed.",
|
||||||
podCmd: "while true; do echo FeFieFoFum >>/mnt/SUCCESS; sleep 1; cat /mnt/SUCCESS; done",
|
podCmd: "while true; do echo FeFieFoFum >>/mnt/SUCCESS; sleep 1; cat /mnt/SUCCESS; done",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -508,14 +508,14 @@ var _ = framework.KubeDescribe("kubelet", func() {
|
|||||||
// Addresses issue #37657.
|
// Addresses issue #37657.
|
||||||
// Note: the pod's vol mount (as a side effect) ends up being moved to /tmp
|
// Note: the pod's vol mount (as a side effect) ends up being moved to /tmp
|
||||||
// and can be unmounted via `umount -f`.
|
// and can be unmounted via `umount -f`.
|
||||||
It("move pod's uid dir and delete pod", func() {
|
It("move NFS client pod's UID directory then delete pod", func() {
|
||||||
pod = createPodUsingNfs(f, c, ns, nfsIP, "sleep 6000")
|
pod = createPodUsingNfs(f, c, ns, nfsIP, "sleep 6000")
|
||||||
|
|
||||||
By("Move pod's uid dir to /tmp")
|
By("Move pod's uid dir to /tmp")
|
||||||
movePodUidDir(c, pod)
|
movePodUidDir(c, pod)
|
||||||
|
|
||||||
By("Delete the pod mounted to the NFS volume")
|
By("Delete the pod mounted to the NFS volume")
|
||||||
deletePodWithWait(f, c, pod)
|
framework.DeletePodWithWait(f, c, pod)
|
||||||
// pod object is now stale, but is intentionally not nil
|
// pod object is now stale, but is intentionally not nil
|
||||||
// Note: the pod's nfs mount, now in /tmp, will not be unmounted
|
// Note: the pod's nfs mount, now in /tmp, will not be unmounted
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user