Skip to content

Commit 33b4e61

Browse files
authored
Merge pull request #1169 from leonardoce/add-pvvscontentlist
Add and set the new VolumeSnapshotHandlePairList field
2 parents 7e7fea2 + 3c2c470 commit 33b4e61

File tree

6 files changed

+117
-0
lines changed

6 files changed

+117
-0
lines changed

client/apis/volumegroupsnapshot/v1alpha1/types.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,12 @@ type VolumeGroupSnapshotContentStatus struct {
359359
// The maximum number of allowed snapshots in the group is 100.
360360
// +optional
361361
PVVolumeSnapshotContentList []PVVolumeSnapshotContentPair `json:"pvVolumeSnapshotContentList,omitempty" protobuf:"bytes,5,opt,name=pvVolumeSnapshotContentRefList"`
362+
363+
// VolumeSnapshotHandlePairList is a list of CSI "volume_id" and "snapshot_id"
364+
// pair returned by the CSI driver to identify snapshots and their source volumes
365+
// on the storage system.
366+
// +optional
367+
VolumeSnapshotHandlePairList []VolumeSnapshotHandlePair `json:"volumeSnapshotHandlePairList,omitempty" protobuf:"bytes,6,opt,name=volumeSnapshotHandlePairList"`
362368
}
363369

364370
// PVVolumeSnapshotContentPair represent a pair of PV names and
@@ -410,3 +416,14 @@ type GroupSnapshotHandles struct {
410416
// Required.
411417
VolumeSnapshotHandles []string `json:"volumeSnapshotHandles" protobuf:"bytes,2,opt,name=volumeSnapshotHandles"`
412418
}
419+
420+
// VolumeSnapshotHandlePair defines a pair of a source volume handle and a snapshot handle
421+
type VolumeSnapshotHandlePair struct {
422+
// VolumeHandle is a unique id returned by the CSI driver to identify a volume
423+
// on the storage system
424+
VolumeHandle string `json:"volumeHandle" protobuf:"bytes,1,opt,name=volumeHandle"`
425+
426+
// SnapshotHandle is a unique id returned by the CSI driver to identify a volume
427+
// snapshot on the storage system
428+
SnapshotHandle string `json:"snapshotHandle" protobuf:"bytes,2,opt,name=snapshotHandle"`
429+
}

client/apis/volumegroupsnapshot/v1alpha1/zz_generated.deepcopy.go

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/config/crd/groupsnapshot.storage.k8s.io_volumegroupsnapshotcontents.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,30 @@ spec:
325325
If a storage system does not provide such an id, the
326326
CSI driver can choose to return the VolumeGroupSnapshot name.
327327
type: string
328+
volumeSnapshotHandlePairList:
329+
description: |-
330+
VolumeSnapshotHandlePairList is a list of CSI "volume_id" and "snapshot_id"
331+
pair returned by the CSI driver to identify snapshots and their source volumes
332+
on the storage system.
333+
items:
334+
description: VolumeSnapshotHandlePair defines a pair of a source
335+
volume handle and a snapshot handle
336+
properties:
337+
snapshotHandle:
338+
description: |-
339+
SnapshotHandle is a unique id returned by the CSI driver to identify a volume
340+
snapshot on the storage system
341+
type: string
342+
volumeHandle:
343+
description: |-
344+
VolumeHandle is a unique id returned by the CSI driver to identify a volume
345+
on the storage system
346+
type: string
347+
required:
348+
- snapshotHandle
349+
- volumeHandle
350+
type: object
351+
type: array
328352
type: object
329353
required:
330354
- spec

pkg/sidecar-controller/groupsnapshot_helper.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import (
3939
// the handle of the volume that was snapshotted
4040
type snapshotContentNameVolumeHandlePair struct {
4141
snapshotContentName string
42+
snapshotHandle string
4243
volumeHandle string
4344
}
4445

@@ -493,6 +494,7 @@ func (ctrl *csiSnapshotSideCarController) createGroupSnapshotWrapper(groupSnapsh
493494
}
494495
snapshotContentLinks = append(snapshotContentLinks, snapshotContentNameVolumeHandlePair{
495496
snapshotContentName: vsc.Name,
497+
snapshotHandle: snapshot.SnapshotId,
496498
volumeHandle: snapshot.SourceVolumeId,
497499
})
498500

@@ -685,7 +687,13 @@ func (ctrl *csiSnapshotSideCarController) updateGroupSnapshotContentStatus(
685687
Name: pvName,
686688
},
687689
})
690+
691+
newStatus.VolumeSnapshotHandlePairList = append(newStatus.VolumeSnapshotHandlePairList, crdv1alpha1.VolumeSnapshotHandlePair{
692+
VolumeHandle: snapshotContentLink.volumeHandle,
693+
SnapshotHandle: snapshotContentLink.snapshotHandle,
694+
})
688695
}
696+
689697
updated = true
690698
} else {
691699
newStatus = groupSnapshotContentObj.Status.DeepCopy()
@@ -728,6 +736,15 @@ func (ctrl *csiSnapshotSideCarController) updateGroupSnapshotContentStatus(
728736
}
729737
updated = true
730738
}
739+
if len(newStatus.VolumeSnapshotHandlePairList) == 0 {
740+
for _, snapshotContentLink := range snapshotContentLinks {
741+
newStatus.VolumeSnapshotHandlePairList = append(newStatus.VolumeSnapshotHandlePairList, crdv1alpha1.VolumeSnapshotHandlePair{
742+
VolumeHandle: snapshotContentLink.volumeHandle,
743+
SnapshotHandle: snapshotContentLink.snapshotHandle,
744+
})
745+
}
746+
updated = true
747+
}
731748
}
732749

733750
if updated {

vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1alpha1/types.go

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1alpha1/zz_generated.deepcopy.go

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)