diff --git a/client/apis/volumegroupsnapshot/v1beta1/types.go b/client/apis/volumegroupsnapshot/v1beta1/types.go index cbe15776c..7f46f5509 100644 --- a/client/apis/volumegroupsnapshot/v1beta1/types.go +++ b/client/apis/volumegroupsnapshot/v1beta1/types.go @@ -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. @@ -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 @@ -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/v1beta1/zz_generated.deepcopy.go b/client/apis/volumegroupsnapshot/v1beta1/zz_generated.deepcopy.go index 21b082084..6be7c4939 100644 --- a/client/apis/volumegroupsnapshot/v1beta1/zz_generated.deepcopy.go +++ b/client/apis/volumegroupsnapshot/v1beta1/zz_generated.deepcopy.go @@ -304,6 +304,11 @@ func (in *VolumeGroupSnapshotContentStatus) DeepCopyInto(out *VolumeGroupSnapsho *out = new(string) **out = **in } + if in.VolumeSnapshotHandlePairList != nil { + in, out := &in.VolumeSnapshotHandlePairList, &out.VolumeSnapshotHandlePairList + *out = make([]VolumeSnapshotHandlePair, len(*in)) + copy(*out, *in) + } if in.CreationTime != nil { in, out := &in.CreationTime, &out.CreationTime *out = new(int64) @@ -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 d5f035f54..029a637b3 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 12790e7c9..b8966b597 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, crdv1beta1.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, crdv1beta1.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/v1beta1/types.go b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1beta1/types.go index cbe15776c..7f46f5509 100644 --- a/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1beta1/types.go +++ b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1beta1/types.go @@ -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. @@ -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 @@ -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/v1beta1/zz_generated.deepcopy.go b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1beta1/zz_generated.deepcopy.go index 21b082084..6be7c4939 100644 --- a/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1beta1/zz_generated.deepcopy.go +++ b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1beta1/zz_generated.deepcopy.go @@ -304,6 +304,11 @@ func (in *VolumeGroupSnapshotContentStatus) DeepCopyInto(out *VolumeGroupSnapsho *out = new(string) **out = **in } + if in.VolumeSnapshotHandlePairList != nil { + in, out := &in.VolumeSnapshotHandlePairList, &out.VolumeSnapshotHandlePairList + *out = make([]VolumeSnapshotHandlePair, len(*in)) + copy(*out, *in) + } if in.CreationTime != nil { in, out := &in.CreationTime, &out.CreationTime *out = new(int64) @@ -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 +}