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 19, 2024
1 parent 6592941 commit e72f89f
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 0 deletions.
17 changes: 17 additions & 0 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,6,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 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 e72f89f

Please sign in to comment.