Skip to content

Commit 3316d86

Browse files
alromeroskubevirt-bot
authored and
kubevirt-bot
committed
Add check for lost target PVC in populators
Signed-off-by: Alvaro Romero <alromero@redhat.com>
1 parent 08dad81 commit 3316d86

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

pkg/controller/common/util.go

+5
Original file line numberDiff line numberDiff line change
@@ -1578,6 +1578,11 @@ func IsUnbound(pvc *corev1.PersistentVolumeClaim) bool {
15781578
return !IsBound(pvc)
15791579
}
15801580

1581+
// IsLost returns if the pvc is lost
1582+
func IsLost(pvc *corev1.PersistentVolumeClaim) bool {
1583+
return pvc != nil && pvc.Status.Phase == corev1.ClaimLost
1584+
}
1585+
15811586
// IsImageStream returns true if registry source is ImageStream
15821587
func IsImageStream(pvc *corev1.PersistentVolumeClaim) bool {
15831588
return pvc.Annotations[AnnRegistryImageStream] == "true"

pkg/controller/populators/populator-base.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -342,10 +342,10 @@ func (r *ReconcilerBase) reconcileCommon(pvc *corev1.PersistentVolumeClaim, popu
342342
return nil, err
343343
}
344344

345-
// If PVC' doesn't exist and target PVC is not bound, we should create the PVC' to start the population.
345+
// If PVC' doesn't exist and target PVC is rebindable, we should create the PVC' to start the population.
346346
// We still return nil as we'll get called again once PVC' exists.
347347
// If target PVC is bound, we don't really need to populate anything.
348-
if cc.IsUnbound(pvc) {
348+
if cc.IsUnbound(pvc) && !cc.IsLost(pvc) {
349349
_, err := r.createPVCPrime(pvc, populationSource, nodeName != "", populator.updatePVCForPopulation)
350350
if err != nil {
351351
r.recorder.Eventf(pvc, corev1.EventTypeWarning, errCreatingPVCPrime, err.Error())

pkg/controller/transfer/pvc.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func (h *pvcTransferHandler) ReconcilePending(ot *cdiv1.ObjectTransfer) (time.Du
4343
return 0, nil
4444
}
4545

46-
if cc.IsUnbound(pvc) || pvc.Status.Phase != corev1.ClaimBound {
46+
if cc.IsUnbound(pvc) {
4747
if err := h.reconciler.setAndUpdateCompleteCondition(ot, corev1.ConditionFalse, "PVC not bound", ""); err != nil {
4848
return 0, err
4949
}

0 commit comments

Comments
 (0)