From b5e139d9def11501ba1ac2c15a73ebabae5b3370 Mon Sep 17 00:00:00 2001 From: Raunak Pradip Shah Date: Wed, 8 Mar 2023 10:44:21 +0530 Subject: [PATCH] Add Source to volumegroupsnapshot --- .../volumegroupsnapshot/v1alpha1/types.go | 46 +++++-- .../v1alpha1/zz_generated.deepcopy.go | 24 +++- ...ge.k8s.io_volumegroupsnapshotcontents.yaml | 11 +- ...t.storage.k8s.io_volumegroupsnapshots.yaml | 118 ++++++++++-------- .../volumegroupsnapshot/v1alpha1/types.go | 45 +++++-- .../v1alpha1/zz_generated.deepcopy.go | 24 +++- 6 files changed, 183 insertions(+), 85 deletions(-) diff --git a/client/apis/volumegroupsnapshot/v1alpha1/types.go b/client/apis/volumegroupsnapshot/v1alpha1/types.go index b961dd9a..351a2ae1 100644 --- a/client/apis/volumegroupsnapshot/v1alpha1/types.go +++ b/client/apis/volumegroupsnapshot/v1alpha1/types.go @@ -25,6 +25,26 @@ import ( // VolumeGroupSnapshotSpec defines the desired state of VolumeGroupSnapshot type VolumeGroupSnapshotSpec struct { + // Source specifies where a group snapshot will be created from. + // This field is immutable after creation. + // Required. + Source VolumeGroupSnapshotSource `json:"source" protobuf:"bytes,1,opt,name=source"` + + // VolumeGroupSnapshotClassName is the name of the VolumeGroupSnapshotClass + // requested by the VolumeGroupSnapshot. + // VolumeGroupSnapshotClassName may be left nil to indicate that the default + // class will be used. + // Empty string is not allowed for this field. + // +optional + VolumeGroupSnapshotClassName *string `json:"volumeGroupSnapshotClassName,omitempty" protobuf:"bytes,2,opt,name=volumeGroupSnapshotClassName"` +} + +// VolumeGroupSnapshotSource specifies whether the underlying group snapshot should be +// dynamically taken upon creation or if a pre-existing VolumeGroupSnapshotContent +// object should be used. +// Exactly one of its members must be set. +// Members in VolumeGroupSnapshotSource are immutable. +type VolumeGroupSnapshotSource struct { // Selector is a label query over PersistentVolumeClaims that are to be grouped // together for snapshotting. // This labelSelector will be used to match the label added to a PVC. @@ -35,13 +55,13 @@ type VolumeGroupSnapshotSpec struct { // Required. Selector metav1.LabelSelector `json:"selector" protobuf:"bytes,1,opt,name=selector"` - // VolumeGroupSnapshotClassName is the name of the VolumeGroupSnapshotClass - // requested by the VolumeGroupSnapshot. - // VolumeGroupSnapshotClassName may be left nil to indicate that the default - // class will be used. - // Empty string is not allowed for this field. + // VolumeGroupSnapshotContentName specifies the name of a pre-existing VolumeGroupSnapshotContent + // object representing an existing volume group snapshot. + // This field should be set if the volume group snapshot already exists and + // only needs a representation in Kubernetes. + // This field is immutable. // +optional - VolumeGroupSnapshotClassName *string `json:"volumeGroupSnapshotClassName,omitempty" protobuf:"bytes,2,opt,name=volumeGroupSnapshotClassName"` + VolumeGroupSnapshotContentName *string `json:"volumeGroupSnapshotContentName,omitempty" protobuf:"bytes,2,opt,name=volumeGroupSnapshotContentName"` } // VolumeGroupSnapshotStatus defines the observed state of VolumeGroupSnapshot @@ -61,6 +81,9 @@ type VolumeGroupSnapshotStatus struct { // by the underlying storage system. // If not specified, it may indicate that the creation time of the group snapshot // is unknown. + // The format of this field is a Unix nanoseconds time encoded as an int64. + // On Unix, the command date +%s%N returns the current time in nanoseconds + // since 1970-01-01 00:00:00 UTC. // +optional CreationTime *metav1.Time `json:"creationTime,omitempty" protobuf:"bytes,2,opt,name=creationTime"` @@ -68,9 +91,6 @@ type VolumeGroupSnapshotStatus struct { // to be used to restore a volume. // ReadyToUse becomes true when ReadyToUse of all individual snapshots become true. // If not specified, it means the readiness of a group snapshot is unknown. - // The format of this field is a Unix nanoseconds time encoded as an int64. - // On Unix, the command date +%s%N returns the current time in nanoseconds - // since 1970-01-01 00:00:00 UTC. // +optional ReadyToUse *bool `json:"readyToUse,omitempty" protobuf:"varint,3,opt,name=readyToUse"` @@ -284,16 +304,16 @@ type VolumeGroupSnapshotContentStatus struct { // 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. + // If not specified, it means the readiness of a group snapshot is unknown. + // The format of this field is a Unix nanoseconds time encoded as an int64. + // 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"` // ReadyToUse indicates if all the individual snapshots in the group are ready to be // used to restore a volume. // ReadyToUse becomes true when ReadyToUse of all individual snapshots become true. - // If not specified, it means the readiness of a group snapshot is unknown. - // The format of this field is a Unix nanoseconds time encoded as an int64. - // On Unix, the command date +%s%N returns the current time in nanoseconds - // since 1970-01-01 00:00:00 UTC. // +optional ReadyToUse *bool `json:"readyToUse,omitempty" protobuf:"varint,3,opt,name=readyToUse"` diff --git a/client/apis/volumegroupsnapshot/v1alpha1/zz_generated.deepcopy.go b/client/apis/volumegroupsnapshot/v1alpha1/zz_generated.deepcopy.go index 03d172fc..b15906fe 100644 --- a/client/apis/volumegroupsnapshot/v1alpha1/zz_generated.deepcopy.go +++ b/client/apis/volumegroupsnapshot/v1alpha1/zz_generated.deepcopy.go @@ -314,9 +314,31 @@ func (in *VolumeGroupSnapshotList) DeepCopyObject() runtime.Object { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *VolumeGroupSnapshotSpec) DeepCopyInto(out *VolumeGroupSnapshotSpec) { +func (in *VolumeGroupSnapshotSource) DeepCopyInto(out *VolumeGroupSnapshotSource) { *out = *in in.Selector.DeepCopyInto(&out.Selector) + if in.VolumeGroupSnapshotContentName != nil { + in, out := &in.VolumeGroupSnapshotContentName, &out.VolumeGroupSnapshotContentName + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeGroupSnapshotSource. +func (in *VolumeGroupSnapshotSource) DeepCopy() *VolumeGroupSnapshotSource { + if in == nil { + return nil + } + out := new(VolumeGroupSnapshotSource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VolumeGroupSnapshotSpec) DeepCopyInto(out *VolumeGroupSnapshotSpec) { + *out = *in + in.Source.DeepCopyInto(&out.Source) if in.VolumeGroupSnapshotClassName != nil { in, out := &in.VolumeGroupSnapshotClassName, &out.VolumeGroupSnapshotClassName *out = new(string) diff --git a/client/config/crd/groupsnapshot.storage.k8s.io_volumegroupsnapshotcontents.yaml b/client/config/crd/groupsnapshot.storage.k8s.io_volumegroupsnapshotcontents.yaml index 7edb4329..2e18f920 100644 --- a/client/config/crd/groupsnapshot.storage.k8s.io_volumegroupsnapshotcontents.yaml +++ b/client/config/crd/groupsnapshot.storage.k8s.io_volumegroupsnapshotcontents.yaml @@ -149,7 +149,11 @@ spec: creationTime: description: 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. + specified, it indicates the creation time is unknown. If not specified, + it means the readiness of a group snapshot is unknown. The format + of this field is a Unix nanoseconds time encoded as an int64. On + Unix, the command date +%s%N returns the current time in nanoseconds + since 1970-01-01 00:00:00 UTC. format: int64 type: integer error: @@ -171,10 +175,7 @@ spec: description: ReadyToUse indicates if all the individual snapshots in the group are ready to be used to restore a volume. ReadyToUse becomes true when ReadyToUse of all individual snapshots become - true. If not specified, it means the readiness of a group snapshot - is unknown. The format of this field is a Unix nanoseconds time - encoded as an int64. On Unix, the command date +%s%N returns the - current time in nanoseconds since 1970-01-01 00:00:00 UTC. + true. type: boolean volumeGroupSnapshotHandle: description: VolumeGroupSnapshotHandle is a unique id returned by diff --git a/client/config/crd/groupsnapshot.storage.k8s.io_volumegroupsnapshots.yaml b/client/config/crd/groupsnapshot.storage.k8s.io_volumegroupsnapshots.yaml index 10ff2f25..f2863e47 100644 --- a/client/config/crd/groupsnapshot.storage.k8s.io_volumegroupsnapshots.yaml +++ b/client/config/crd/groupsnapshot.storage.k8s.io_volumegroupsnapshots.yaml @@ -38,57 +38,71 @@ spec: description: Spec defines the desired characteristics of a group snapshot requested by a user. Required. properties: - selector: - description: Selector is a label query over PersistentVolumeClaims - that are to be grouped together for snapshotting. This labelSelector - will be used to match the label added to a PVC. If the label is - added or removed to a volume after a group snapshot is created, - the existing group snapshots won't be modified. Once a VolumeGroupSnapshotContent - is created and the sidecar starts to process it, the volume list - will not change with retries. Required. + source: + description: Source specifies where a group snapshot will be created + from. This field is immutable after creation. Required. properties: - matchExpressions: - description: matchExpressions is a list of label selector requirements. - The requirements are ANDed. - items: - description: A label selector requirement is a selector that - contains values, a key, and an operator that relates the key - and values. - properties: - key: - description: key is the label key that the selector applies - to. + selector: + description: Selector is a label query over PersistentVolumeClaims + that are to be grouped together for snapshotting. This labelSelector + will be used to match the label added to a PVC. If the label + is added or removed to a volume after a group snapshot is created, + the existing group snapshots won't be modified. Once a VolumeGroupSnapshotContent + is created and the sidecar starts to process it, the volume + list will not change with retries. Required. + properties: + matchExpressions: + description: matchExpressions is a list of label selector + requirements. The requirements are ANDed. + items: + description: A label selector requirement is a selector + that contains values, a key, and an operator that relates + the key and values. + properties: + key: + description: key is the label key that the selector + applies to. + type: string + operator: + description: operator represents a key's relationship + to a set of values. Valid operators are In, NotIn, + Exists and DoesNotExist. + type: string + values: + description: values is an array of string values. If + the operator is In or NotIn, the values array must + be non-empty. If the operator is Exists or DoesNotExist, + the values array must be empty. This array is replaced + during a strategic merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: type: string - operator: - description: operator represents a key's relationship to - a set of values. Valid operators are In, NotIn, Exists - and DoesNotExist. - type: string - values: - description: values is an array of string values. If the - operator is In or NotIn, the values array must be non-empty. - If the operator is Exists or DoesNotExist, the values - array must be empty. This array is replaced during a strategic - merge patch. - items: - type: string - type: array - required: - - key - - operator - type: object - type: array - matchLabels: - additionalProperties: - type: string - description: matchLabels is a map of {key,value} pairs. A single - {key,value} in the matchLabels map is equivalent to an element - of matchExpressions, whose key field is "key", the operator - is "In", and the values array contains only "value". The requirements - are ANDed. + description: matchLabels is a map of {key,value} pairs. A + single {key,value} in the matchLabels map is equivalent + to an element of matchExpressions, whose key field is "key", + the operator is "In", and the values array contains only + "value". The requirements are ANDed. + type: object type: object + x-kubernetes-map-type: atomic + volumeGroupSnapshotContentName: + description: volumeGroupSnapshotContentName specifies the name + of a pre-existing VolumeGroupSnapshotContent object representing + an existing volume group snapshot. This field should be set + if the volume group snapshot already exists and only needs a + representation in Kubernetes. This field is immutable. + type: string + required: + - selector type: object - x-kubernetes-map-type: atomic volumeGroupSnapshotClassName: description: VolumeGroupSnapshotClassName is the name of the VolumeGroupSnapshotClass requested by the VolumeGroupSnapshot. VolumeGroupSnapshotClassName @@ -96,7 +110,7 @@ spec: Empty string is not allowed for this field. type: string required: - - selector + - source type: object status: description: Status represents the current information of a group snapshot. @@ -119,7 +133,9 @@ spec: description: CreationTime is the timestamp when the point-in-time group snapshot is taken by the underlying storage system. If not specified, it may indicate that the creation time of the group snapshot - is unknown. + is unknown. The format of this field is a Unix nanoseconds time + encoded as an int64. On Unix, the command date +%s%N returns the + current time in nanoseconds since 1970-01-01 00:00:00 UTC. format: date-time type: string error: @@ -146,9 +162,7 @@ spec: in the group are ready to be used to restore a volume. ReadyToUse becomes true when ReadyToUse of all individual snapshots become true. If not specified, it means the readiness of a group snapshot - is unknown. The format of this field is a Unix nanoseconds time - encoded as an int64. On Unix, the command date +%s%N returns the - current time in nanoseconds since 1970-01-01 00:00:00 UTC. + is unknown. type: boolean volumeSnapshotRefList: description: VolumeSnapshotRefList is the list of volume snapshot diff --git a/vendor/github.com/kubernetes-csi/external-snapshotter/client/v6/apis/volumegroupsnapshot/v1alpha1/types.go b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v6/apis/volumegroupsnapshot/v1alpha1/types.go index b961dd9a..e0b4d0ab 100644 --- a/vendor/github.com/kubernetes-csi/external-snapshotter/client/v6/apis/volumegroupsnapshot/v1alpha1/types.go +++ b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v6/apis/volumegroupsnapshot/v1alpha1/types.go @@ -25,6 +25,26 @@ import ( // VolumeGroupSnapshotSpec defines the desired state of VolumeGroupSnapshot type VolumeGroupSnapshotSpec struct { + // Source specifies where a group snapshot will be created from. + // This field is immutable after creation. + // Required. + Source VolumeGroupSnapshotSource `json:"source" protobuf:"bytes,1,opt,name=source"` + + // VolumeGroupSnapshotClassName is the name of the VolumeGroupSnapshotClass + // requested by the VolumeGroupSnapshot. + // VolumeGroupSnapshotClassName may be left nil to indicate that the default + // class will be used. + // Empty string is not allowed for this field. + // +optional + VolumeGroupSnapshotClassName *string `json:"volumeGroupSnapshotClassName,omitempty" protobuf:"bytes,2,opt,name=volumeGroupSnapshotClassName"` +} + +// VolumeGroupSnapshotSource specifies whether the underlying group snapshot should be +// dynamically taken upon creation or if a pre-existing VolumeGroupSnapshotContent +// object should be used. +// Exactly one of its members must be set. +// Members in VolumeGroupSnapshotSource are immutable. +type VolumeGroupSnapshotSource struct { // Selector is a label query over PersistentVolumeClaims that are to be grouped // together for snapshotting. // This labelSelector will be used to match the label added to a PVC. @@ -35,13 +55,12 @@ type VolumeGroupSnapshotSpec struct { // Required. Selector metav1.LabelSelector `json:"selector" protobuf:"bytes,1,opt,name=selector"` - // VolumeGroupSnapshotClassName is the name of the VolumeGroupSnapshotClass - // requested by the VolumeGroupSnapshot. - // VolumeGroupSnapshotClassName may be left nil to indicate that the default - // class will be used. - // Empty string is not allowed for this field. + // volumeGroupSnapshotContentName specifies the name of a pre-existing VolumeGroupSnapshotContent + // object representing an existing volume group snapshot. + // This field should be set if the volume group snapshot already exists and only needs a representation in Kubernetes. + // This field is immutable. // +optional - VolumeGroupSnapshotClassName *string `json:"volumeGroupSnapshotClassName,omitempty" protobuf:"bytes,2,opt,name=volumeGroupSnapshotClassName"` + VolumeGroupSnapshotContentName *string `json:"volumeGroupSnapshotContentName,omitempty" protobuf:"bytes,2,opt,name=volumeGroupSnapshotContentName"` } // VolumeGroupSnapshotStatus defines the observed state of VolumeGroupSnapshot @@ -61,6 +80,9 @@ type VolumeGroupSnapshotStatus struct { // by the underlying storage system. // If not specified, it may indicate that the creation time of the group snapshot // is unknown. + // The format of this field is a Unix nanoseconds time encoded as an int64. + // On Unix, the command date +%s%N returns the current time in nanoseconds + // since 1970-01-01 00:00:00 UTC. // +optional CreationTime *metav1.Time `json:"creationTime,omitempty" protobuf:"bytes,2,opt,name=creationTime"` @@ -68,9 +90,6 @@ type VolumeGroupSnapshotStatus struct { // to be used to restore a volume. // ReadyToUse becomes true when ReadyToUse of all individual snapshots become true. // If not specified, it means the readiness of a group snapshot is unknown. - // The format of this field is a Unix nanoseconds time encoded as an int64. - // On Unix, the command date +%s%N returns the current time in nanoseconds - // since 1970-01-01 00:00:00 UTC. // +optional ReadyToUse *bool `json:"readyToUse,omitempty" protobuf:"varint,3,opt,name=readyToUse"` @@ -284,16 +303,16 @@ type VolumeGroupSnapshotContentStatus struct { // 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. + // If not specified, it means the readiness of a group snapshot is unknown. + // The format of this field is a Unix nanoseconds time encoded as an int64. + // 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"` // ReadyToUse indicates if all the individual snapshots in the group are ready to be // used to restore a volume. // ReadyToUse becomes true when ReadyToUse of all individual snapshots become true. - // If not specified, it means the readiness of a group snapshot is unknown. - // The format of this field is a Unix nanoseconds time encoded as an int64. - // On Unix, the command date +%s%N returns the current time in nanoseconds - // since 1970-01-01 00:00:00 UTC. // +optional ReadyToUse *bool `json:"readyToUse,omitempty" protobuf:"varint,3,opt,name=readyToUse"` diff --git a/vendor/github.com/kubernetes-csi/external-snapshotter/client/v6/apis/volumegroupsnapshot/v1alpha1/zz_generated.deepcopy.go b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v6/apis/volumegroupsnapshot/v1alpha1/zz_generated.deepcopy.go index 03d172fc..b15906fe 100644 --- a/vendor/github.com/kubernetes-csi/external-snapshotter/client/v6/apis/volumegroupsnapshot/v1alpha1/zz_generated.deepcopy.go +++ b/vendor/github.com/kubernetes-csi/external-snapshotter/client/v6/apis/volumegroupsnapshot/v1alpha1/zz_generated.deepcopy.go @@ -314,9 +314,31 @@ func (in *VolumeGroupSnapshotList) DeepCopyObject() runtime.Object { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *VolumeGroupSnapshotSpec) DeepCopyInto(out *VolumeGroupSnapshotSpec) { +func (in *VolumeGroupSnapshotSource) DeepCopyInto(out *VolumeGroupSnapshotSource) { *out = *in in.Selector.DeepCopyInto(&out.Selector) + if in.VolumeGroupSnapshotContentName != nil { + in, out := &in.VolumeGroupSnapshotContentName, &out.VolumeGroupSnapshotContentName + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeGroupSnapshotSource. +func (in *VolumeGroupSnapshotSource) DeepCopy() *VolumeGroupSnapshotSource { + if in == nil { + return nil + } + out := new(VolumeGroupSnapshotSource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VolumeGroupSnapshotSpec) DeepCopyInto(out *VolumeGroupSnapshotSpec) { + *out = *in + in.Source.DeepCopyInto(&out.Source) if in.VolumeGroupSnapshotClassName != nil { in, out := &in.VolumeGroupSnapshotClassName, &out.VolumeGroupSnapshotClassName *out = new(string)