Skip to content

Commit

Permalink
Add and set the new pvVolumeSnapshotContentList field
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardoce committed Oct 17, 2024
1 parent 6592941 commit 4f5aa74
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 8 deletions.
25 changes: 21 additions & 4 deletions client/apis/volumegroupsnapshot/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,12 @@ type VolumeGroupSnapshotContentStatus struct {
// +optional
VolumeGroupSnapshotHandle *string `json:"volumeGroupSnapshotHandle,omitempty" protobuf:"bytes,1,opt,name=volumeGroupSnapshotHandle"`

// 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,2,opt,name=volumeSnapshotHandlePairList"`

// CreationTime is the timestamp when the point-in-time group snapshot is taken
// by the underlying storage system.
// If not specified, it indicates the creation time is unknown.
Expand All @@ -341,24 +347,24 @@ type VolumeGroupSnapshotContentStatus struct {
// On Unix, the command date +%s%N returns the current time in nanoseconds
// since 1970-01-01 00:00:00 UTC.
// +optional
CreationTime *int64 `json:"creationTime,omitempty" protobuf:"varint,2,opt,name=creationTime"`
CreationTime *int64 `json:"creationTime,omitempty" protobuf:"varint,3,opt,name=creationTime"`

// ReadyToUse indicates if all the individual snapshots in the group are ready to be
// used to restore a group of volumes.
// ReadyToUse becomes true when ReadyToUse of all individual snapshots become true.
// +optional
ReadyToUse *bool `json:"readyToUse,omitempty" protobuf:"varint,3,opt,name=readyToUse"`
ReadyToUse *bool `json:"readyToUse,omitempty" protobuf:"varint,4,opt,name=readyToUse"`

// Error is the last observed error during group snapshot creation, if any.
// Upon success after retry, this error field will be cleared.
// +optional
Error *snapshotv1.VolumeSnapshotError `json:"error,omitempty" protobuf:"bytes,4,opt,name=error,casttype=VolumeSnapshotError"`
Error *snapshotv1.VolumeSnapshotError `json:"error,omitempty" protobuf:"bytes,5,opt,name=error,casttype=VolumeSnapshotError"`

// PVVolumeSnapshotContentList is the list of pairs of PV and
// VolumeSnapshotContent for this group snapshot
// The maximum number of allowed snapshots in the group is 100.
// +optional
PVVolumeSnapshotContentList []PVVolumeSnapshotContentPair `json:"pvVolumeSnapshotContentList,omitempty" protobuf:"bytes,5,opt,name=pvVolumeSnapshotContentRefList"`
PVVolumeSnapshotContentList []PVVolumeSnapshotContentPair `json:"pvVolumeSnapshotContentList,omitempty" protobuf:"bytes,6,opt,name=pvVolumeSnapshotContentRefList"`
}

// 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/v1beta1/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, crdv1beta1.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, crdv1beta1.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.

0 comments on commit 4f5aa74

Please sign in to comment.