virtualization
virtualization copied to clipboard
feat(vd): creare pvc using volume snapshot
Description
Reviewer's Guide
Introduce 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 VolumeSnapshot
sequenceDiagram
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 types
classDiagram
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
| Change | Details | Files |
|---|---|---|
| Branch HTTP data source import to use volume snapshots |
|
pkg/controller/vi/internal/source/http.go |
| Add CreateVolumeSnapshot method to disk service |
|
pkg/controller/service/disk_service.go |
| Skip standard VirtualDisk steps when using snapshots |
|
pkg/controller/vd/internal/source/step/create_dv_from_vi_step.gopkg/controller/vd/internal/source/step/ensure_node_placement.gopkg/controller/vd/internal/source/step/wait_for_dv_step.go |
| Register new step for PVC creation from snapshots |
|
pkg/controller/vd/internal/source/object_ref_vi.go |
| Implement CreatePVCFromVSStep for VolumeSnapshot support |
|
pkg/controller/vd/internal/source/step/create_pvc_from_vs_step.go |
Tips and commands
Interacting with Sourcery
-
Trigger a new review: Comment
@sourcery-ai reviewon the pull request. - Continue discussions: Reply directly to Sourcery's review comments.
-
Generate a GitHub issue from a review comment: Ask Sourcery to create an
issue from a review comment by replying to it. You can also reply to a
review comment with
@sourcery-ai issueto create an issue from it. -
Generate a pull request title: Write
@sourcery-aianywhere in the pull request title to generate a title at any time. You can also comment@sourcery-ai titleon the pull request to (re-)generate the title at any time. -
Generate a pull request summary: Write
@sourcery-ai summaryanywhere in the pull request body to generate a PR summary at any time exactly where you want it. You can also comment@sourcery-ai summaryon the pull request to (re-)generate the summary at any time. -
Generate reviewer's guide: Comment
@sourcery-ai guideon the pull request to (re-)generate the reviewer's guide at any time. -
Resolve all Sourcery comments: Comment
@sourcery-ai resolveon the pull request to resolve all Sourcery comments. Useful if you've already addressed all the comments and don't want to see them anymore. -
Dismiss all Sourcery reviews: Comment
@sourcery-ai dismisson the pull request to dismiss all existing Sourcery reviews. Especially useful if you want to start fresh with a new review - don't forget to comment@sourcery-ai reviewto trigger a new review!
Customizing Your Experience
Access your dashboard to:
- Enable or disable review features such as the Sourcery-generated pull request summary, the reviewer's guide, and others.
- Change the review language.
- Add, remove or edit custom review instructions.
- Adjust other review settings.
Getting Help
- Contact our support team for questions or feedback.
- Visit our documentation for detailed guides and information.
- Keep in touch with the Sourcery team by following us on X/Twitter, LinkedIn or GitHub.