Skip to content

Commit 76c098a

Browse files
committed
API change to improve VolumeGroupSnapshot restore
Change `VolumeSnapshotRefList` in `VolumeGroupSnapshotStatus` to `PVCVolumeSnapshotRefList`, allowing users to map a `VolumeSnapshot` to a specific `PersistentVolumeClaim`. Change `VolumeSnapshotContentRefList` in `VolumeGroupSnapshotContentStatus` to `PVVolumeSnapshotContentRefList`, allowing users to map a `VolumeSnapshotContent` to a specific `PersistentVolume`. This two changes allow users to map each `VolumeSnapshot` back to the original PVC it was taken from.
1 parent b906618 commit 76c098a

File tree

6 files changed

+238
-160
lines changed

6 files changed

+238
-160
lines changed

client/apis/volumegroupsnapshot/v1alpha1/types.go

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,20 @@ type VolumeGroupSnapshotStatus struct {
103103
// +optional
104104
Error *snapshotv1.VolumeSnapshotError `json:"error,omitempty" protobuf:"bytes,4,opt,name=error,casttype=VolumeSnapshotError"`
105105

106-
// VolumeSnapshotRefList is the list of volume snapshot references for this
107-
// group snapshot.
106+
// VolumeSnapshotRefList is the list of PVC and VolumeSnapshot pair that
107+
// is part of this group snapshot.
108108
// The maximum number of allowed snapshots in the group is 100.
109109
// +optional
110-
VolumeSnapshotRefList []core_v1.ObjectReference `json:"volumeSnapshotRefList,omitempty" protobuf:"bytes,5,opt,name=volumeSnapshotRefList"`
110+
PVCVolumeSnapshotRefList []PVCVolumeSnapshotPair `json:"pvcVolumeSnapshotRefList,omitempty" protobuf:"bytes,6,opt,name=pvcVolumeSnapshotRefList"`
111+
}
112+
113+
// PVCVolumeSnapshotPair defines a pair of a PVC reference and a Volume Snapshot
114+
type PVCVolumeSnapshotPair struct {
115+
// PersistentVolumeClaimRef is a reference to the PVC this pair is referring to
116+
PersistentVolumeClaimRef core_v1.ObjectReference `json:"persistentVolumeClaimRef,omitempty" protobuf:"bytes,1,opt,name=persistentVolumeClaimRef"`
117+
118+
// VolumeSnapshotRef is a reference to the VolumeSnapshot this pair is referring to
119+
VolumeSnapshotRef core_v1.ObjectReference `json:"volumeSnapshotRef,omitempty" protobuf:"bytes,1,opt,name=volumeSnapshotRef"`
111120
}
112121

113122
//+genclient
@@ -337,11 +346,21 @@ type VolumeGroupSnapshotContentStatus struct {
337346
// +optional
338347
Error *snapshotv1.VolumeSnapshotError `json:"error,omitempty" protobuf:"bytes,4,opt,name=error,casttype=VolumeSnapshotError"`
339348

340-
// VolumeSnapshotContentRefList is the list of volume snapshot content references
341-
// for this group snapshot.
349+
// PVVolumeSnapshotContentRefList is the list of pairs of PV and
350+
// VolumeSnapshotCOntent for this group snapshot
342351
// The maximum number of allowed snapshots in the group is 100.
343352
// +optional
344-
VolumeSnapshotContentRefList []core_v1.ObjectReference `json:"volumeSnapshotContentRefList,omitempty" protobuf:"bytes,5,opt,name=volumeSnapshotContentRefList"`
353+
PVVolumeSnapshotContentRefList []PVVolumeSnapshotContentPair `json:"pvVolumeSnapshotContentRefList,omitempty" protobuf:"bytes,6,opt,name=pvVolumeSnapshotContentRefList"`
354+
}
355+
356+
// PVVolumeSnapshotContentPair represent a pair of PV names and
357+
// VolumeSnapshotContent names
358+
type PVVolumeSnapshotContentPair struct {
359+
// PersistentVolumeName is the name of the persistent volume
360+
PersistentVolumeName string `json:"persistentVolumeName,omitempty" protobuf:"bytes,1,opt,name=persistentVolumeName"`
361+
362+
// VolumeSnapshotContentName is the name of the volume snapshot content resource
363+
VolumeSnapshotContentName string `json:"volumeSnapshotContentName,omitempty" protobuf:"bytes,1,opt,name=volumeSnapshotContentName"`
345364
}
346365

347366
// VolumeGroupSnapshotContentSource represents the CSI source of a group snapshot.

client/apis/volumegroupsnapshot/v1alpha1/zz_generated.deepcopy.go

Lines changed: 40 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/config/crd/groupsnapshot.storage.k8s.io_volumegroupsnapshotcontents.yaml

Lines changed: 19 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
6-
api-approved.kubernetes.io: "https://github.com/kubernetes-csi/external-snapshotter/pull/971"
6+
api-approved.kubernetes.io: "https://github.com/kubernetes-csi/external-snapshotter/pull/1068"
77
controller-gen.kubebuilder.io/version: v0.12.0
88
creationTimestamp: null
99
name: volumegroupsnapshotcontents.groupsnapshot.storage.k8s.io
@@ -227,6 +227,24 @@ spec:
227227
format: date-time
228228
type: string
229229
type: object
230+
pvVolumeSnapshotContentRefList:
231+
description: PVVolumeSnapshotContentRefList is the list of pairs of
232+
PV and VolumeSnapshotCOntent for this group snapshot The maximum
233+
number of allowed snapshots in the group is 100.
234+
items:
235+
description: PVVolumeSnapshotContentPair represent a pair of PV
236+
names and VolumeSnapshotContent names
237+
properties:
238+
persistentVolumeName:
239+
description: PersistentVolumeName is the name of the persistent
240+
volume
241+
type: string
242+
volumeSnapshotContentName:
243+
description: VolumeSnapshotContentName is the name of the volume
244+
snapshot content resource
245+
type: string
246+
type: object
247+
type: array
230248
readyToUse:
231249
description: ReadyToUse indicates if all the individual snapshots
232250
in the group are ready to be used to restore a group of volumes.
@@ -239,72 +257,6 @@ spec:
239257
system. If a storage system does not provide such an id, the CSI
240258
driver can choose to return the VolumeGroupSnapshot name.
241259
type: string
242-
volumeSnapshotContentRefList:
243-
description: VolumeSnapshotContentRefList is the list of volume snapshot
244-
content references for this group snapshot. The maximum number of
245-
allowed snapshots in the group is 100.
246-
items:
247-
description: "ObjectReference contains enough information to let
248-
you inspect or modify the referred object. --- New uses of this
249-
type are discouraged because of difficulty describing its usage
250-
when embedded in APIs. 1. Ignored fields. It includes many fields
251-
which are not generally honored. For instance, ResourceVersion
252-
and FieldPath are both very rarely valid in actual usage. 2. Invalid
253-
usage help. It is impossible to add specific help for individual
254-
usage. In most embedded usages, there are particular restrictions
255-
like, \"must refer only to types A and B\" or \"UID not honored\"
256-
or \"name must be restricted\". Those cannot be well described
257-
when embedded. 3. Inconsistent validation. Because the usages
258-
are different, the validation rules are different by usage, which
259-
makes it hard for users to predict what will happen. 4. The fields
260-
are both imprecise and overly precise. Kind is not a precise
261-
mapping to a URL. This can produce ambiguity during interpretation
262-
and require a REST mapping. In most cases, the dependency is
263-
on the group,resource tuple and the version of the actual struct
264-
is irrelevant. 5. We cannot easily change it. Because this type
265-
is embedded in many locations, updates to this type will affect
266-
numerous schemas. Don't make new APIs embed an underspecified
267-
API type they do not control. \n Instead of using this type, create
268-
a locally provided and used type that is well-focused on your
269-
reference. For example, ServiceReferences for admission registration:
270-
https://github.com/kubernetes/api/blob/release-1.17/admissionregistration/v1/types.go#L533
271-
."
272-
properties:
273-
apiVersion:
274-
description: API version of the referent.
275-
type: string
276-
fieldPath:
277-
description: 'If referring to a piece of an object instead of
278-
an entire object, this string should contain a valid JSON/Go
279-
field access statement, such as desiredState.manifest.containers[2].
280-
For example, if the object reference is to a container within
281-
a pod, this would take on a value like: "spec.containers{name}"
282-
(where "name" refers to the name of the container that triggered
283-
the event) or if no container name is specified "spec.containers[2]"
284-
(container with index 2 in this pod). This syntax is chosen
285-
only to have some well-defined way of referencing a part of
286-
an object. TODO: this design is not final and this field is
287-
subject to change in the future.'
288-
type: string
289-
kind:
290-
description: 'Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
291-
type: string
292-
name:
293-
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
294-
type: string
295-
namespace:
296-
description: 'Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/'
297-
type: string
298-
resourceVersion:
299-
description: 'Specific resourceVersion to which this reference
300-
is made, if any. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency'
301-
type: string
302-
uid:
303-
description: 'UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids'
304-
type: string
305-
type: object
306-
x-kubernetes-map-type: atomic
307-
type: array
308260
type: object
309261
required:
310262
- spec

0 commit comments

Comments
 (0)