Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -641,18 +641,26 @@ func (h MigrationHandler) createTargetPersistentVolumeClaim(ctx context.Context,
if err != nil {
return nil, err
}
switch len(pvcs) {

var livePVCs []corev1.PersistentVolumeClaim
for _, pvc := range pvcs {
if pvc.DeletionTimestamp.IsZero() {
livePVCs = append(livePVCs, pvc)
}
}

switch len(livePVCs) {
case 1: // only source pvc exists
case 2:
for _, pvc := range pvcs {
for _, pvc := range livePVCs {
// If TargetPVC is empty, that means previous reconciliation failed and not updated TargetPVC in status.
// So, we should use pvc, that is not equal to SourcePVC.
if pvc.Name == targetPVCName || pvc.Name != sourcePVCName {
return &pvc, nil
}
}
default:
return nil, fmt.Errorf("unexpected number of pvcs: %d, please report a bug", len(pvcs))
return nil, fmt.Errorf("unexpected number of pvcs: %d, please report a bug", len(livePVCs))
}

pvc := &corev1.PersistentVolumeClaim{
Expand Down
Loading