Skip to content

Commit

Permalink
Prevent upload populator from hot looping prime annotation (#2991)
Browse files Browse the repository at this point in the history
This hot loop was causing the upload populator to constantly
add and remove the annotation causing the node controller to
always be outdated and never update the pvc to be bound causing
the upload test to fail randomly.

Signed-off-by: Alexander Wels <[email protected]>
Co-authored-by: Alexander Wels <[email protected]>
  • Loading branch information
kubevirt-bot and awels authored Nov 17, 2023
1 parent 33773a7 commit 89b8276
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 deletions pkg/controller/populators/upload-populator.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,17 @@ func (r *UploadPopulatorReconciler) updateUploadAnnotations(pvc *corev1.Persiste

func (r *UploadPopulatorReconciler) reconcileTargetPVC(pvc, pvcPrime *corev1.PersistentVolumeClaim) (reconcile.Result, error) {
pvcCopy := pvc.DeepCopy()
phase := pvcPrime.Annotations[cc.AnnPodPhase]

updated, err := r.updatePVCPrimeNameAnnotation(pvcCopy, pvcPrime.Name)
if updated || err != nil {
// wait for the annotation to be updated
return reconcile.Result{}, err
if phase != string(corev1.PodSucceeded) {
updated, err := r.updatePVCPrimeNameAnnotation(pvcCopy, pvcPrime.Name)
if updated || err != nil {
// wait for the annotation to be updated
return reconcile.Result{}, err
}
}

// Wait upload completes
phase := pvcPrime.Annotations[cc.AnnPodPhase]
switch phase {
case string(corev1.PodFailed):
// We'll get called later once it succeeds
Expand All @@ -163,7 +165,7 @@ func (r *UploadPopulatorReconciler) reconcileTargetPVC(pvc, pvcPrime *corev1.Per
}
}

err = r.updatePVCWithPVCPrimeAnnotations(pvcCopy, pvcPrime, r.updateUploadAnnotations)
err := r.updatePVCWithPVCPrimeAnnotations(pvcCopy, pvcPrime, r.updateUploadAnnotations)
if err != nil {
return reconcile.Result{}, err
}
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/pvc.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ func NewBlockPVCDefinition(pvcName string, size string, annotations, labels map[
func WaitForPersistentVolumeClaimPhase(clientSet *kubernetes.Clientset, namespace string, phase k8sv1.PersistentVolumeClaimPhase, pvcName string) error {
err := wait.PollImmediate(pvcPollInterval, pvcPhaseTime, func() (bool, error) {
pvc, err := clientSet.CoreV1().PersistentVolumeClaims(namespace).Get(context.TODO(), pvcName, metav1.GetOptions{})
fmt.Fprintf(ginkgo.GinkgoWriter, "INFO: Checking PVC phase: %s\n", string(pvc.Status.Phase))
fmt.Fprintf(ginkgo.GinkgoWriter, "INFO: Checking PVC phase: %s, resource version %s\n", string(pvc.Status.Phase), pvc.ResourceVersion)
if err != nil || pvc.Status.Phase != phase {
return false, err
}
Expand Down

0 comments on commit 89b8276

Please sign in to comment.