diff --git a/client/apis/volumegroupsnapshot/v1alpha1/types.go b/client/apis/volumegroupsnapshot/v1alpha1/types.go index 445a2ee01..e5b5b095c 100644 --- a/client/apis/volumegroupsnapshot/v1alpha1/types.go +++ b/client/apis/volumegroupsnapshot/v1alpha1/types.go @@ -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 @@ -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"` +} diff --git a/client/apis/volumegroupsnapshot/v1alpha1/zz_generated.deepcopy.go b/client/apis/volumegroupsnapshot/v1alpha1/zz_generated.deepcopy.go index dd58419d9..82895edea 100644 --- a/client/apis/volumegroupsnapshot/v1alpha1/zz_generated.deepcopy.go +++ b/client/apis/volumegroupsnapshot/v1alpha1/zz_generated.deepcopy.go @@ -324,6 +324,11 @@ func (in *VolumeGroupSnapshotContentStatus) DeepCopyInto(out *VolumeGroupSnapsho *out = make([]PVVolumeSnapshotContentPair, len(*in)) copy(*out, *in) } + if in.VolumeSnapshotHandlePairList != nil { + in, out := &in.VolumeSnapshotHandlePairList, &out.VolumeSnapshotHandlePairList + *out = make([]VolumeSnapshotHandlePair, len(*in)) + copy(*out, *in) + } return } @@ -457,3 +462,19 @@ func (in *VolumeGroupSnapshotStatus) DeepCopy() *VolumeGroupSnapshotStatus { in.DeepCopyInto(out) return out } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VolumeSnapshotHandlePair) DeepCopyInto(out *VolumeSnapshotHandlePair) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeSnapshotHandlePair. +func (in *VolumeSnapshotHandlePair) DeepCopy() *VolumeSnapshotHandlePair { + if in == nil { + return nil + } + out := new(VolumeSnapshotHandlePair) + in.DeepCopyInto(out) + return out +} diff --git a/client/config/crd/groupsnapshot.storage.k8s.io_volumegroupsnapshotcontents.yaml b/client/config/crd/groupsnapshot.storage.k8s.io_volumegroupsnapshotcontents.yaml index 28584e56b..dcfa3bc27 100644 --- a/client/config/crd/groupsnapshot.storage.k8s.io_volumegroupsnapshotcontents.yaml +++ b/client/config/crd/groupsnapshot.storage.k8s.io_volumegroupsnapshotcontents.yaml @@ -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 diff --git a/pkg/sidecar-controller/groupsnapshot_helper.go b/pkg/sidecar-controller/groupsnapshot_helper.go index 58c44f4ff..e586fe6ae 100644 --- a/pkg/sidecar-controller/groupsnapshot_helper.go +++ b/pkg/sidecar-controller/groupsnapshot_helper.go @@ -39,6 +39,7 @@ import ( // the handle of the volume that was snapshotted type snapshotContentNameVolumeHandlePair struct { snapshotContentName string + snapshotHandle string volumeHandle string } @@ -493,6 +494,7 @@ func (ctrl *csiSnapshotSideCarController) createGroupSnapshotWrapper(groupSnapsh } snapshotContentLinks = append(snapshotContentLinks, snapshotContentNameVolumeHandlePair{ snapshotContentName: vsc.Name, + snapshotHandle: snapshot.SnapshotId, volumeHandle: snapshot.SourceVolumeId, }) @@ -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() @@ -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 { diff --git a/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1alpha1/types.go b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1alpha1/types.go index 445a2ee01..e5b5b095c 100644 --- a/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1alpha1/types.go +++ b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1alpha1/types.go @@ -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 @@ -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"` +} diff --git a/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1alpha1/zz_generated.deepcopy.go b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1alpha1/zz_generated.deepcopy.go index dd58419d9..82895edea 100644 --- a/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1alpha1/zz_generated.deepcopy.go +++ b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1alpha1/zz_generated.deepcopy.go @@ -324,6 +324,11 @@ func (in *VolumeGroupSnapshotContentStatus) DeepCopyInto(out *VolumeGroupSnapsho *out = make([]PVVolumeSnapshotContentPair, len(*in)) copy(*out, *in) } + if in.VolumeSnapshotHandlePairList != nil { + in, out := &in.VolumeSnapshotHandlePairList, &out.VolumeSnapshotHandlePairList + *out = make([]VolumeSnapshotHandlePair, len(*in)) + copy(*out, *in) + } return } @@ -457,3 +462,19 @@ func (in *VolumeGroupSnapshotStatus) DeepCopy() *VolumeGroupSnapshotStatus { in.DeepCopyInto(out) return out } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VolumeSnapshotHandlePair) DeepCopyInto(out *VolumeSnapshotHandlePair) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeSnapshotHandlePair. +func (in *VolumeSnapshotHandlePair) DeepCopy() *VolumeSnapshotHandlePair { + if in == nil { + return nil + } + out := new(VolumeSnapshotHandlePair) + in.DeepCopyInto(out) + return out +}