@@ -34,6 +34,7 @@ import (
3434 "sigs.k8s.io/controller-runtime/pkg/client"
3535 "sigs.k8s.io/controller-runtime/pkg/reconcile"
3636
37+ "github.com/deckhouse/virtualization-controller/pkg/common/annotations"
3738 "github.com/deckhouse/virtualization-controller/pkg/common/object"
3839 pvcspec "github.com/deckhouse/virtualization-controller/pkg/common/pvc"
3940 commonvd "github.com/deckhouse/virtualization-controller/pkg/common/vd"
@@ -594,12 +595,18 @@ func (h MigrationHandler) handleComplete(ctx context.Context, vd *v1alpha2.Virtu
594595 }
595596
596597 log .Info ("Complete migration. Delete source PersistentVolumeClaim" , slog .String ("pvc.name" , vd .Status .MigrationState .SourcePVC ), slog .String ("pvc.namespace" , vd .Namespace ))
598+
597599 err = h .deleteSourcePersistentVolumeClaim (ctx , vd )
598600 if err != nil {
599601 return err
600602 }
601603 log .Debug ("Source PersistentVolumeClaim was deleted" , slog .String ("pvc.name" , vd .Status .MigrationState .SourcePVC ), slog .String ("pvc.namespace" , vd .Namespace ))
602604
605+ // Remove quota override label from target PVC.
606+ if err := object .RemoveLabel (ctx , h .client , targetPVC , annotations .QuotaExcludeLabel ); err != nil && ! k8serrors .IsNotFound (err ) {
607+ return fmt .Errorf ("remove quota override label from target PVC: %w" , err )
608+ }
609+
603610 if sc := vd .Spec .PersistentVolumeClaim .StorageClass ; sc != nil && * sc != "" {
604611 vd .Status .StorageClassName = * sc
605612 }
@@ -655,6 +662,9 @@ func (h MigrationHandler) createTargetPersistentVolumeClaim(ctx context.Context,
655662 OwnerReferences : []metav1.OwnerReference {
656663 service .MakeControllerOwnerReference (vd ),
657664 },
665+ Labels : map [string ]string {
666+ annotations .QuotaExcludeLabel : annotations .QuotaExcludeValue ,
667+ },
658668 },
659669 Spec : ptr .Deref (
660670 pvcspec .CreateSpec (& sc .Name , size , accessMode , volumeMode ),
@@ -685,9 +695,12 @@ func (h MigrationHandler) deleteTargetPersistentVolumeClaim(ctx context.Context,
685695
686696func (h MigrationHandler ) deleteSourcePersistentVolumeClaim (ctx context.Context , vd * v1alpha2.VirtualDisk ) error {
687697 pvc , err := h .getSourcePersistentVolumeClaim (ctx , vd )
688- if pvc == nil || err != nil {
698+ if err != nil && ! k8serrors . IsNotFound ( err ) {
689699 return err
690700 }
701+ if pvc == nil {
702+ return nil
703+ }
691704
692705 return deletePersistentVolumeClaim (ctx , pvc , h .client )
693706}
0 commit comments