@@ -285,20 +285,6 @@ func createUploadDisk(f *framework.Framework, name string) *v1alpha2.VirtualDisk
285285 return vd
286286}
287287
288- func retry (maxRetries int , fn func () error ) error {
289- var lastErr error
290- for attempt := 1 ; attempt <= maxRetries ; attempt ++ {
291- if err := fn (); err != nil {
292- lastErr = err
293- GinkgoWriter .Printf ("Attempt %d/%d failed: %v\n " , attempt , maxRetries , err )
294- time .Sleep (time .Duration (attempt ) * time .Second )
295- continue
296- }
297- return nil
298- }
299- return fmt .Errorf ("failed after %d attempts: %w" , maxRetries , lastErr )
300- }
301-
302288func uploadFile (f * framework.Framework , vd * v1alpha2.VirtualDisk , filePath string ) {
303289 err := f .Clients .GenericClient ().Get (context .Background (), crclient .ObjectKeyFromObject (vd ), vd )
304290 Expect (err ).NotTo (HaveOccurred ())
@@ -314,14 +300,17 @@ func uploadFile(f *framework.Framework, vd *v1alpha2.VirtualDisk, filePath strin
314300 }
315301 uploadURL := vd .Status .ImageUploadURLs .External
316302
317- // During the upload of a VirtualDisk of type 'Upload', there is a bug:
318- // when the VirtualDisk is in the 'DiskWaitForUserUpload' phase,
319- // nginx may not be ready yet and can return 413 or 503 errors.
320- // Once this bug is fixed, the retry mechanism must be removed.
321- const maxRetries = 5
322- err = retry (maxRetries , func () error {
323- return doUploadAttempt (httpClient , uploadURL , filePath )
324- })
303+ // uploaderPod, err := getUploaderPod(vd.Name, vd.Namespace, f)
304+ // Expect(err).NotTo(HaveOccurred())
305+ // untilUploaderPodReady(uploaderPod.Name, uploaderPod.Namespace, f)
306+
307+ // uploaderIngress, err := getUploaderIngress(vd.Name, vd.Namespace, f)
308+ // Expect(err).NotTo(HaveOccurred())
309+ // untilUploaderIngressReady(uploaderIngress.Name, uploaderIngress.Namespace, f)
310+
311+ // time.Sleep(1 * time.Second)
312+
313+ err = doUploadAttempt (httpClient , uploadURL , filePath )
325314 Expect (err ).NotTo (HaveOccurred (), "Upload failed" )
326315}
327316
@@ -385,3 +374,77 @@ func checkStorageVolumeDataManagerEnabled() (bool, error) {
385374
386375 return enabled != nil && * enabled , nil
387376}
377+
378+ // func getUploaderPod(vd *v1alpha2.VirtualDisk, f *framework.Framework) (*corev1.Pod, error) {
379+ // pods, err := f.Clients.KubeClient().CoreV1().Pods(vd.Namespace).List(context.Background(), metav1.ListOptions{})
380+ // if err != nil {
381+ // return nil, err
382+ // }
383+
384+ // for _, pod := range pods.Items {
385+ // for _, ref := range pod.OwnerReferences {
386+ // if ref.Kind == v1alpha2.VirtualDiskKind && ref.Name == vd.Name && strings.HasSuffix(pod.Name, string(vd.UID)) {
387+ // for _, c := range pod.Spec.Containers {
388+ // if c.Name == common.UploaderContainerName {
389+ // return &pod, nil
390+ // }
391+ // }
392+ // }
393+ // }
394+ // }
395+
396+ // return nil, fmt.Errorf("could not find uploader pod for virtual disk %s", vd.Name)
397+ // }
398+
399+ // func untilUploaderPodReady(podName, podNamespace string, f *framework.Framework) {
400+ // GinkgoHelper()
401+
402+ // Eventually(func() error {
403+ // pod, err := f.Clients.KubeClient().CoreV1().Pods(podNamespace).Get(context.Background(), podName, metav1.GetOptions{})
404+ // if err != nil {
405+ // return err
406+ // }
407+
408+ // for _, c := range pod.Status.Conditions {
409+ // if c.Type == corev1.PodReady && c.Status == corev1.ConditionTrue {
410+ // return nil
411+ // }
412+ // }
413+
414+ // return fmt.Errorf("pod %s is not ready", podName)
415+ // }).WithTimeout(framework.ShortTimeout).WithPolling(framework.PollingInterval).Should(Succeed())
416+ // }
417+
418+ // func getUploaderIngress(vd *v1alpha2.VirtualDisk, f *framework.Framework) (*netv1.Ingress, error) {
419+ // ings, err := f.Clients.KubeClient().NetworkingV1().Ingresses(vd.Namespace).List(context.Background(), metav1.ListOptions{})
420+ // if err != nil {
421+ // return nil, err
422+ // }
423+
424+ // for _, ing := range ings.Items {
425+ // for _, ref := range ing.OwnerReferences {
426+ // if ref.Kind == v1alpha2.VirtualDiskKind && ref.Name == vd.Name && strings.HasSuffix(ing.Name, string(vd.UID)) {
427+ // return &ing, nil
428+ // }
429+ // }
430+ // }
431+
432+ // return nil, fmt.Errorf("could not find uploader ingress for virtual disk %s", vd.Name)
433+ // }
434+
435+ // func untilUploaderIngressReady(ingName, ingNamespace string, f *framework.Framework) {
436+ // GinkgoHelper()
437+
438+ // Eventually(func() error {
439+ // ing, err := f.Clients.KubeClient().NetworkingV1().Ingresses(ingNamespace).Get(context.Background(), ingName, metav1.GetOptions{})
440+ // if err != nil {
441+ // return err
442+ // }
443+
444+ // if len(ing.Status.LoadBalancer.Ingress) != 0 {
445+ // return nil
446+ // }
447+
448+ // return fmt.Errorf("ingress %s is not ready", ingName)
449+ // }).WithTimeout(framework.MiddleTimeout).WithPolling(framework.PollingInterval).Should(Succeed())
450+ // }
0 commit comments