Update to API for static group volume snapshots

This commit is contained in:
Raunak Pradip Shah
2023-12-05 14:22:02 -08:00
parent b44a6b006e
commit bffa5ae25f
4 changed files with 72 additions and 15 deletions

View File

@@ -354,10 +354,27 @@ type VolumeGroupSnapshotContentSource struct {
// +optional // +optional
PersistentVolumeNames []string `json:"persistentVolumeNames,omitempty" protobuf:"bytes,1,opt,name=persistentVolumeNames"` PersistentVolumeNames []string `json:"persistentVolumeNames,omitempty" protobuf:"bytes,1,opt,name=persistentVolumeNames"`
// GroupSnapshotHandleSource specifies the CSI "group_snapshot_id" of a pre-existing
// group snapshot and a list of CSI "snapshot_id" of pre-existing snapshots
// on the underlying storage system for which a Kubernetes object
// representation was (or should be) created.
// This field is immutable.
// +optional
GroupSnapshotHandleSource *VolumeGroupSnapshotHandleSource `json:"groupSnapshotHandleSource,omitempty" protobuf:"bytes,2,opt,name=groupSnapshotHandleSource"`
}
type VolumeGroupSnapshotHandleSource struct {
// VolumeGroupSnapshotHandle specifies the CSI "group_snapshot_id" of a pre-existing // VolumeGroupSnapshotHandle specifies the CSI "group_snapshot_id" of a pre-existing
// group snapshot on the underlying storage system for which a Kubernetes object // group snapshot on the underlying storage system for which a Kubernetes object
// representation was (or should be) created. // representation was (or should be) created.
// This field is immutable. // This field is immutable.
// +optional // Required.
VolumeGroupSnapshotHandle *string `json:"volumeGroupSnapshotHandle,omitempty" protobuf:"bytes,2,opt,name=volumeGroupSnapshotHandle"` VolumeGroupSnapshotHandle string `json:"volumeGroupSnapshotHandle" protobuf:"bytes,1,opt,name=volumeGroupSnapshotHandle"`
// VolumeSnapshotHandles is a list of CSI "snapshot_id" of pre-existing
// snapshots on the underlying storage system for which Kubernetes objects
// representation were (or should be) created.
// This field is immutable.
// Required.
VolumeSnapshotHandles []string `json:"volumeSnapshotHandles" protobuf:"bytes,2,opt,name=volumeSnapshotHandles"`
} }

View File

@@ -198,10 +198,10 @@ func (in *VolumeGroupSnapshotContentSource) DeepCopyInto(out *VolumeGroupSnapsho
*out = make([]string, len(*in)) *out = make([]string, len(*in))
copy(*out, *in) copy(*out, *in)
} }
if in.VolumeGroupSnapshotHandle != nil { if in.GroupSnapshotHandleSource != nil {
in, out := &in.VolumeGroupSnapshotHandle, &out.VolumeGroupSnapshotHandle in, out := &in.GroupSnapshotHandleSource, &out.GroupSnapshotHandleSource
*out = new(string) *out = new(VolumeGroupSnapshotHandleSource)
**out = **in (*in).DeepCopyInto(*out)
} }
return return
} }
@@ -280,6 +280,27 @@ func (in *VolumeGroupSnapshotContentStatus) DeepCopy() *VolumeGroupSnapshotConte
return out return out
} }
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *VolumeGroupSnapshotHandleSource) DeepCopyInto(out *VolumeGroupSnapshotHandleSource) {
*out = *in
if in.VolumeSnapshotHandles != nil {
in, out := &in.VolumeSnapshotHandles, &out.VolumeSnapshotHandles
*out = make([]string, len(*in))
copy(*out, *in)
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeGroupSnapshotHandleSource.
func (in *VolumeGroupSnapshotHandleSource) DeepCopy() *VolumeGroupSnapshotHandleSource {
if in == nil {
return nil
}
out := new(VolumeGroupSnapshotHandleSource)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *VolumeGroupSnapshotList) DeepCopyInto(out *VolumeGroupSnapshotList) { func (in *VolumeGroupSnapshotList) DeepCopyInto(out *VolumeGroupSnapshotList) {
*out = *in *out = *in

View File

@@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition kind: CustomResourceDefinition
metadata: metadata:
annotations: annotations:
api-approved.kubernetes.io: "https://github.com/kubernetes-csi/external-snapshotter/pull/814" api-approved.kubernetes.io: "https://github.com/kubernetes-csi/external-snapshotter/pull/971"
controller-gen.kubebuilder.io/version: v0.12.0 controller-gen.kubebuilder.io/version: v0.12.0
creationTimestamp: null creationTimestamp: null
name: volumegroupsnapshotcontents.groupsnapshot.storage.k8s.io name: volumegroupsnapshotcontents.groupsnapshot.storage.k8s.io
@@ -104,6 +104,31 @@ spec:
dynamically provisioned or already exists, and just requires a Kubernetes dynamically provisioned or already exists, and just requires a Kubernetes
object representation. This field is immutable after creation. Required. object representation. This field is immutable after creation. Required.
properties: properties:
groupSnapshotHandleSource:
description: GroupSnapshotHandleSource specifies the CSI "group_snapshot_id"
of a pre-existing group snapshot and a list of CSI "snapshot_id"
of pre-existing snapshots on the underlying storage system for
which a Kubernetes object representation was (or should be)
created. This field is immutable.
properties:
volumeGroupSnapshotHandle:
description: VolumeGroupSnapshotHandle specifies the CSI "group_snapshot_id"
of a pre-existing group snapshot on the underlying storage
system for which a Kubernetes object representation was
(or should be) created. This field is immutable. Required.
type: string
volumeSnapshotHandles:
description: VolumeSnapshotHandles is a list of CSI "snapshot_id"
of pre-existing snapshots on the underlying storage system
for which Kubernetes objects representation were (or should
be) created. This field is immutable. Required.
items:
type: string
type: array
required:
- volumeGroupSnapshotHandle
- volumeSnapshotHandles
type: object
persistentVolumeNames: persistentVolumeNames:
description: PersistentVolumeNames is a list of names of PersistentVolumes description: PersistentVolumeNames is a list of names of PersistentVolumes
to be snapshotted together. It is specified for dynamic provisioning to be snapshotted together. It is specified for dynamic provisioning
@@ -111,16 +136,10 @@ spec:
items: items:
type: string type: string
type: array type: array
volumeGroupSnapshotHandle:
description: VolumeGroupSnapshotHandle specifies the CSI "group_snapshot_id"
of a pre-existing group snapshot on the underlying storage system
for which a Kubernetes object representation was (or should
be) created. This field is immutable.
type: string
type: object type: object
oneOf: oneOf:
- required: ["persistentVolumeNames"] - required: ["persistentVolumeNames"]
- required: ["volumeGroupSnapshotHandle"] - required: ["groupSnapshotHandleSource"]
volumeGroupSnapshotClassName: volumeGroupSnapshotClassName:
description: VolumeGroupSnapshotClassName is the name of the VolumeGroupSnapshotClass description: VolumeGroupSnapshotClassName is the name of the VolumeGroupSnapshotClass
from which this group snapshot was (or will be) created. Note that from which this group snapshot was (or will be) created. Note that

View File

@@ -1161,7 +1161,7 @@ func (ctrl *csiSnapshotCommonController) processGroupSnapshotWithDeletionTimesta
// Delete the individual snapshots part of the group snapshot // Delete the individual snapshots part of the group snapshot
for _, snapshot := range groupSnapshot.Status.VolumeSnapshotRefList { for _, snapshot := range groupSnapshot.Status.VolumeSnapshotRefList {
err := ctrl.clientset.SnapshotV1().VolumeSnapshots(snapshot.Namespace).Delete(context.TODO(), snapshot.Name, metav1.DeleteOptions{}) err := ctrl.clientset.SnapshotV1().VolumeSnapshots(snapshot.Namespace).Delete(context.TODO(), snapshot.Name, metav1.DeleteOptions{})
if err != nil { if err != nil && !apierrs.IsNotFound(err) {
msg := fmt.Sprintf("failed to delete snapshot API object %s/%s part of group snapshot %s: %v", snapshot.Namespace, snapshot.Name, utils.GroupSnapshotKey(groupSnapshot), err) msg := fmt.Sprintf("failed to delete snapshot API object %s/%s part of group snapshot %s: %v", snapshot.Namespace, snapshot.Name, utils.GroupSnapshotKey(groupSnapshot), err)
klog.Error(msg) klog.Error(msg)
ctrl.eventRecorder.Event(groupSnapshot, v1.EventTypeWarning, "SnapshotDeleteError", msg) ctrl.eventRecorder.Event(groupSnapshot, v1.EventTypeWarning, "SnapshotDeleteError", msg)