- 
                Notifications
    
You must be signed in to change notification settings  - Fork 2
 
feat(vd): creare pvc using volume snapshot #1619
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
          
Reviewer's GuideIntroduce optional volume snapshot–based provisioning for HTTP data sources and VirtualDisk creation when the annotation 'virtualization.deckhouse.io/use-volume-snapshot' is set, including snapshot lifecycle management and PVC creation from snapshots. Sequence diagram for VirtualDisk creation using VolumeSnapshotsequenceDiagram
    participant VD as VirtualDisk Controller
    participant VI as VirtualImage
    participant VS as VolumeSnapshot
    participant PVC as PersistentVolumeClaim
    participant K8s as Kubernetes API
    VD->>VI: Check for 'use-volume-snapshot' annotation
    alt Annotation present
        VD->>VI: Fetch VirtualImage
        VI->>VS: Fetch VolumeSnapshot (by PVC name)
        alt VolumeSnapshot not found
            VI->>VS: Create VolumeSnapshot
            VI->>VD: Requeue until snapshot ready
        else VolumeSnapshot found
            VI->>VS: Check ReadyToUse status
            alt Not ready
                VI->>VD: Requeue until snapshot ready
            else Ready
                VD->>PVC: Create PVC from VolumeSnapshot
                PVC->>K8s: Request PVC creation
                K8s-->>PVC: PVC created
            end
        end
    else Annotation not present
        VD->>PVC: Standard PVC creation flow
    end
    Class diagram for CreatePVCFromVSStep and related typesclassDiagram
    class CreatePVCFromVSStep {
        - pvc: PersistentVolumeClaim
        - client: Client
        - cb: ConditionBuilder
        + Take(ctx, vd): (*reconcile.Result, error)
        + buildPVC(vd, vs): *PersistentVolumeClaim
        + addOriginalMetadata(vd, vs)
    }
    class VirtualDisk {
        + Annotations: map[string]string
        + Labels: map[string]string
        + Status: VirtualDiskStatus
        + Spec: VirtualDiskSpec
    }
    class VolumeSnapshot {
        + Status: VolumeSnapshotStatus
        + Annotations: map[string]string
    }
    class PersistentVolumeClaim {
        + Name: string
        + Namespace: string
        + OwnerReferences: []OwnerReference
        + Spec: PersistentVolumeClaimSpec
    }
    CreatePVCFromVSStep --> VirtualDisk
    CreatePVCFromVSStep --> VolumeSnapshot
    CreatePVCFromVSStep --> PersistentVolumeClaim
    File-Level Changes
 Tips and commandsInteracting with Sourcery
 Customizing Your ExperienceAccess your dashboard to: 
 Getting Help
  | 
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there - I've reviewed your changes - here's some feedback:
- The CreateVolumeSnapshot method’s bound-state check seems reversed (it errors when PVC is Bound) – flip the condition or message to only snapshot after PVC is Bound.
 - There are many scattered checks for the use-volume-snapshot annotation; extract this into a shared helper/constant to reduce duplication and improve maintainability.
 - Guard against nil on vs.Status or ReadyToUse pointer (the && check can panic and should treat nil as not ready) to prevent dereference errors.
 
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The CreateVolumeSnapshot method’s bound-state check seems reversed (it errors when PVC is Bound) – flip the condition or message to only snapshot after PVC is Bound.
- There are many scattered checks for the use-volume-snapshot annotation; extract this into a shared helper/constant to reduce duplication and improve maintainability.
- Guard against nil on vs.Status or ReadyToUse pointer (the && check can panic and should treat nil as not ready) to prevent dereference errors.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
dfcbfe0    to
    05c28fb      
    Compare
  
    Signed-off-by: Isteb4k <dmitry.rakitin@flant.com>
Signed-off-by: Isteb4k <dmitry.rakitin@flant.com>
05c28fb    to
    2ba1f4c      
    Compare
  
    Signed-off-by: Isteb4k <dmitry.rakitin@flant.com> Signed-off-by: Maksim Fedotov <maksim.fedotov@flant.com> feat(vd): create pvc using volume snapshot Signed-off-by: Isteb4k <dmitry.rakitin@flant.com> Signed-off-by: Maksim Fedotov <maksim.fedotov@flant.com>
Signed-off-by: Isteb4k <dmitry.rakitin@flant.com> Signed-off-by: Maksim Fedotov <maksim.fedotov@flant.com> feat(vd): create pvc using volume snapshot Signed-off-by: Isteb4k <dmitry.rakitin@flant.com> Signed-off-by: Maksim Fedotov <maksim.fedotov@flant.com>
Description