Skip to content
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

Add and set the new VolumeSnapshotHandlePairList field #1169

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
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
17 changes: 17 additions & 0 deletions client/apis/volumegroupsnapshot/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,12 @@ type VolumeGroupSnapshotContentStatus struct {
// The maximum number of allowed snapshots in the group is 100.
// +optional
PVVolumeSnapshotContentList []PVVolumeSnapshotContentPair `json:"pvVolumeSnapshotContentList,omitempty" protobuf:"bytes,5,opt,name=pvVolumeSnapshotContentRefList"`

// VolumeSnapshotHandlePairList is a list of CSI "volume_id" and "snapshot_id"
// pair returned by the CSI driver to identify snapshots and their source volumes
// on the storage system.
// +optional
VolumeSnapshotHandlePairList []VolumeSnapshotHandlePair `json:"volumeSnapshotHandlePairList,omitempty" protobuf:"bytes,6,opt,name=volumeSnapshotHandlePairList"`
}

// PVVolumeSnapshotContentPair represent a pair of PV names and
Expand Down Expand Up @@ -410,3 +416,14 @@ type GroupSnapshotHandles struct {
// Required.
VolumeSnapshotHandles []string `json:"volumeSnapshotHandles" protobuf:"bytes,2,opt,name=volumeSnapshotHandles"`
}

// VolumeSnapshotHandlePair defines a pair of a source volume handle and a snapshot handle
type VolumeSnapshotHandlePair struct {
// VolumeHandle is a unique id returned by the CSI driver to identify a volume
// on the storage system
VolumeHandle string `json:"volumeHandle" protobuf:"bytes,1,opt,name=volumeHandle"`

// SnapshotHandle is a unique id returned by the CSI driver to identify a volume
// snapshot on the storage system
SnapshotHandle string `json:"snapshotHandle" protobuf:"bytes,2,opt,name=snapshotHandle"`
}
21 changes: 21 additions & 0 deletions client/apis/volumegroupsnapshot/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,30 @@ spec:
If a storage system does not provide such an id, the
CSI driver can choose to return the VolumeGroupSnapshot name.
type: string
volumeSnapshotHandlePairList:
description: |-
VolumeSnapshotHandlePairList is a list of CSI "volume_id" and "snapshot_id"
pair returned by the CSI driver to identify snapshots and their source volumes
on the storage system.
items:
description: VolumeSnapshotHandlePair defines a pair of a source
volume handle and a snapshot handle
properties:
snapshotHandle:
description: |-
SnapshotHandle is a unique id returned by the CSI driver to identify a volume
snapshot on the storage system
type: string
volumeHandle:
description: |-
VolumeHandle is a unique id returned by the CSI driver to identify a volume
on the storage system
type: string
required:
- snapshotHandle
- volumeHandle
type: object
type: array
type: object
required:
- spec
Expand Down
17 changes: 17 additions & 0 deletions pkg/sidecar-controller/groupsnapshot_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
// the handle of the volume that was snapshotted
type snapshotContentNameVolumeHandlePair struct {
snapshotContentName string
snapshotHandle string
volumeHandle string
}

Expand Down Expand Up @@ -493,6 +494,7 @@ func (ctrl *csiSnapshotSideCarController) createGroupSnapshotWrapper(groupSnapsh
}
snapshotContentLinks = append(snapshotContentLinks, snapshotContentNameVolumeHandlePair{
snapshotContentName: vsc.Name,
snapshotHandle: snapshot.SnapshotId,
volumeHandle: snapshot.SourceVolumeId,
})

Expand Down Expand Up @@ -685,7 +687,13 @@ func (ctrl *csiSnapshotSideCarController) updateGroupSnapshotContentStatus(
Name: pvName,
},
})

newStatus.VolumeSnapshotHandlePairList = append(newStatus.VolumeSnapshotHandlePairList, crdv1alpha1.VolumeSnapshotHandlePair{
VolumeHandle: snapshotContentLink.volumeHandle,
SnapshotHandle: snapshotContentLink.snapshotHandle,
})
}

updated = true
} else {
newStatus = groupSnapshotContentObj.Status.DeepCopy()
Expand Down Expand Up @@ -728,6 +736,15 @@ func (ctrl *csiSnapshotSideCarController) updateGroupSnapshotContentStatus(
}
updated = true
}
if len(newStatus.VolumeSnapshotHandlePairList) == 0 {
for _, snapshotContentLink := range snapshotContentLinks {
newStatus.VolumeSnapshotHandlePairList = append(newStatus.VolumeSnapshotHandlePairList, crdv1alpha1.VolumeSnapshotHandlePair{
VolumeHandle: snapshotContentLink.volumeHandle,
SnapshotHandle: snapshotContentLink.snapshotHandle,
})
}
updated = true
}
}

if updated {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.