@@ -55,8 +55,8 @@ var _ = Describe("GPUNode Controller", func() {
5555 }, timeout , interval ).Should (Succeed ())
5656
5757 By ("checking that the hypervisor pod is created" )
58+ pod := & corev1.Pod {}
5859 Eventually (func (g Gomega ) {
59- pod := & corev1.Pod {}
6060 err := k8sClient .Get (ctx , types.NamespacedName {
6161 Name : fmt .Sprintf ("hypervisor-%s" , gpuNode .Name ),
6262 Namespace : utils .CurrentNamespace (),
@@ -71,37 +71,20 @@ var _ = Describe("GPUNode Controller", func() {
7171 g .Expect (gpunode .Status .Phase ).Should (Equal (tfv1 .TensorFusionGPUNodePhaseRunning ))
7272 }, timeout , interval ).Should (Succeed ())
7373
74- tfEnv .Cleanup ()
75-
76- // By("checking that it will recreate terminated hypervisor pod")
77- // Expect(k8sClient.Delete(ctx, pod)).Should(Succeed())
78- // Eventually(func() error {
79- // return k8sClient.Get(ctx, types.NamespacedName{
80- // Name: fmt.Sprintf("hypervisor-%s", gpuNode.Name),
81- // Namespace: utils.CurrentNamespace(),
82- // }, pod)
83- // }, timeout, interval).Should(Succeed())
74+ By ("checking the hypervisor pod should be recreated when enters terminated status" )
75+ pod .Status .Phase = corev1 .PodFailed
76+ Expect (k8sClient .Status ().Update (ctx , pod )).Should (Succeed ())
77+ Eventually (func (g Gomega ) {
78+ newPod := & corev1.Pod {}
79+ err := k8sClient .Get (ctx , types.NamespacedName {
80+ Name : fmt .Sprintf ("hypervisor-%s" , gpuNode .Name ),
81+ Namespace : utils .CurrentNamespace (),
82+ }, newPod )
83+ g .Expect (err ).ShouldNot (HaveOccurred ())
84+ g .Expect (newPod .UID ).ShouldNot (Equal (pod .UID ))
85+ }, timeout , interval ).Should (Succeed ())
8486
85- // TODO: make this test pass when implement rolling udpate
86- // By("checking that the hypervisor config changed")
87- // tfc := getMockCluster(ctx)
88- // hypervisor := tfc.Spec.GPUPools[0].SpecTemplate.ComponentConfig.Hypervisor
89- // podTmpl := &corev1.PodTemplate{}
90- // err := json.Unmarshal(hypervisor.PodTemplate.Raw, podTmpl)
91- // Expect(err).NotTo(HaveOccurred())
92- // podTmpl.Template.Spec.Containers[0].Name = "foo"
93- // hypervisor.PodTemplate.Raw = lo.Must(json.Marshal(podTmpl))
94- // Expect(k8sClient.Update(ctx, tfc)).To(Succeed())
95- // Eventually(func() string {
96- // pod := &corev1.Pod{}
97- // if err = k8sClient.Get(ctx, types.NamespacedName{
98- // Name: fmt.Sprintf("hypervisor-%s", gpuNode.Name),
99- // Namespace: utils.CurrentNamespace(),
100- // }, pod); err != nil {
101- // return ""
102- // }
103- // return pod.Spec.Containers[0].Name
104- // }, timeout, interval).Should(Equal("foo"))
87+ tfEnv .Cleanup ()
10588 })
10689 })
10790})
0 commit comments