Skip to content

Commit 0f88e94

Browse files
authored
Merge pull request kubernetes-csi#1068 from leonardoce/dev/update-api
API change to improve VolumeGroupSnapshot restore
2 parents bde741c + b5ab14a commit 0f88e94

File tree

9 files changed

+243
-192
lines changed

9 files changed

+243
-192
lines changed

client/apis/volumegroupsnapshot/v1alpha1/types.go

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

112-
// VolumeSnapshotRefList is the list of volume snapshot references for this
113-
// group snapshot.
112+
// VolumeSnapshotRefList is the list of PVC and VolumeSnapshot pairs that
113+
// is part of this group snapshot.
114114
// The maximum number of allowed snapshots in the group is 100.
115115
// +optional
116-
VolumeSnapshotRefList []core_v1.ObjectReference `json:"volumeSnapshotRefList,omitempty" protobuf:"bytes,5,opt,name=volumeSnapshotRefList"`
116+
PVCVolumeSnapshotRefList []PVCVolumeSnapshotPair `json:"pvcVolumeSnapshotRefList,omitempty" protobuf:"bytes,5,opt,name=pvcVolumeSnapshotRefList"`
117+
}
118+
119+
// PVCVolumeSnapshotPair defines a pair of a PVC reference and a Volume Snapshot Reference
120+
type PVCVolumeSnapshotPair struct {
121+
// PersistentVolumeClaimRef is a reference to the PVC this pair is referring to
122+
PersistentVolumeClaimRef core_v1.LocalObjectReference `json:"persistentVolumeClaimRef,omitempty" protobuf:"bytes,1,opt,name=persistentVolumeClaimRef"`
123+
124+
// VolumeSnapshotRef is a reference to the VolumeSnapshot this pair is referring to
125+
VolumeSnapshotRef core_v1.LocalObjectReference `json:"volumeSnapshotRef,omitempty" protobuf:"bytes,2,opt,name=volumeSnapshotRef"`
117126
}
118127

119128
//+genclient
@@ -345,11 +354,21 @@ type VolumeGroupSnapshotContentStatus struct {
345354
// +optional
346355
Error *snapshotv1.VolumeSnapshotError `json:"error,omitempty" protobuf:"bytes,4,opt,name=error,casttype=VolumeSnapshotError"`
347356

348-
// VolumeSnapshotContentRefList is the list of volume snapshot content references
349-
// for this group snapshot.
357+
// PVVolumeSnapshotContentList is the list of pairs of PV and
358+
// VolumeSnapshotContent for this group snapshot
350359
// The maximum number of allowed snapshots in the group is 100.
351360
// +optional
352-
VolumeSnapshotContentRefList []core_v1.ObjectReference `json:"volumeSnapshotContentRefList,omitempty" protobuf:"bytes,5,opt,name=volumeSnapshotContentRefList"`
361+
PVVolumeSnapshotContentList []PVVolumeSnapshotContentPair `json:"pvVolumeSnapshotContentList,omitempty" protobuf:"bytes,5,opt,name=pvVolumeSnapshotContentRefList"`
362+
}
363+
364+
// PVVolumeSnapshotContentPair represent a pair of PV names and
365+
// VolumeSnapshotContent names
366+
type PVVolumeSnapshotContentPair struct {
367+
// PersistentVolumeRef is a reference to the persistent volume resource
368+
PersistentVolumeRef core_v1.LocalObjectReference `json:"persistentVolumeRef,omitempty" protobuf:"bytes,1,opt,name=persistentVolumeRef"`
369+
370+
// VolumeSnapshotContentRef is a reference to the volume snapshot content resource
371+
VolumeSnapshotContentRef core_v1.LocalObjectReference `json:"volumeSnapshotContentRef,omitempty" protobuf:"bytes,2,opt,name=volumeSnapshotContentRef"`
353372
}
354373

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

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

Lines changed: 42 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: 37 additions & 68 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.15.0
88
name: volumegroupsnapshotcontents.groupsnapshot.storage.k8s.io
99
spec:
@@ -276,6 +276,42 @@ spec:
276276
format: date-time
277277
type: string
278278
type: object
279+
pvVolumeSnapshotContentList:
280+
description: |-
281+
PVVolumeSnapshotContentList is the list of pairs of PV and
282+
VolumeSnapshotContent for this group snapshot
283+
The maximum number of allowed snapshots in the group is 100.
284+
items:
285+
description: |-
286+
PVVolumeSnapshotContentPair represent a pair of PV names and
287+
VolumeSnapshotContent names
288+
properties:
289+
persistentVolumeRef:
290+
description: PersistentVolumeRef is a reference to the persistent
291+
volume resource
292+
properties:
293+
name:
294+
description: |-
295+
Name of the referent.
296+
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
297+
TODO: Add other useful fields. apiVersion, kind, uid?
298+
type: string
299+
type: object
300+
x-kubernetes-map-type: atomic
301+
volumeSnapshotContentRef:
302+
description: VolumeSnapshotContentRef is a reference to the
303+
volume snapshot content resource
304+
properties:
305+
name:
306+
description: |-
307+
Name of the referent.
308+
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
309+
TODO: Add other useful fields. apiVersion, kind, uid?
310+
type: string
311+
type: object
312+
x-kubernetes-map-type: atomic
313+
type: object
314+
type: array
279315
readyToUse:
280316
description: |-
281317
ReadyToUse indicates if all the individual snapshots in the group are ready to be
@@ -289,73 +325,6 @@ spec:
289325
If a storage system does not provide such an id, the
290326
CSI driver can choose to return the VolumeGroupSnapshot name.
291327
type: string
292-
volumeSnapshotContentRefList:
293-
description: |-
294-
VolumeSnapshotContentRefList is the list of volume snapshot content references
295-
for this group snapshot.
296-
The maximum number of allowed snapshots in the group is 100.
297-
items:
298-
description: |-
299-
ObjectReference contains enough information to let you inspect or modify the referred object.
300-
---
301-
New uses of this type are discouraged because of difficulty describing its usage when embedded in APIs.
302-
1. Ignored fields. It includes many fields which are not generally honored. For instance, ResourceVersion and FieldPath are both very rarely valid in actual usage.
303-
2. Invalid usage help. It is impossible to add specific help for individual usage. In most embedded usages, there are particular
304-
restrictions like, "must refer only to types A and B" or "UID not honored" or "name must be restricted".
305-
Those cannot be well described when embedded.
306-
3. Inconsistent validation. Because the usages are different, the validation rules are different by usage, which makes it hard for users to predict what will happen.
307-
4. The fields are both imprecise and overly precise. Kind is not a precise mapping to a URL. This can produce ambiguity
308-
during interpretation and require a REST mapping. In most cases, the dependency is on the group,resource tuple
309-
and the version of the actual struct is irrelevant.
310-
5. We cannot easily change it. Because this type is embedded in many locations, updates to this type
311-
will affect numerous schemas. Don't make new APIs embed an underspecified API type they do not control.
312-
313-
314-
Instead of using this type, create a locally provided and used type that is well-focused on your reference.
315-
For example, ServiceReferences for admission registration: https://github.com/kubernetes/api/blob/release-1.17/admissionregistration/v1/types.go#L533 .
316-
properties:
317-
apiVersion:
318-
description: API version of the referent.
319-
type: string
320-
fieldPath:
321-
description: |-
322-
If referring to a piece of an object instead of an entire object, this string
323-
should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2].
324-
For example, if the object reference is to a container within a pod, this would take on a value like:
325-
"spec.containers{name}" (where "name" refers to the name of the container that triggered
326-
the event) or if no container name is specified "spec.containers[2]" (container with
327-
index 2 in this pod). This syntax is chosen only to have some well-defined way of
328-
referencing a part of an object.
329-
TODO: this design is not final and this field is subject to change in the future.
330-
type: string
331-
kind:
332-
description: |-
333-
Kind of the referent.
334-
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
335-
type: string
336-
name:
337-
description: |-
338-
Name of the referent.
339-
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
340-
type: string
341-
namespace:
342-
description: |-
343-
Namespace of the referent.
344-
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/
345-
type: string
346-
resourceVersion:
347-
description: |-
348-
Specific resourceVersion to which this reference is made, if any.
349-
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency
350-
type: string
351-
uid:
352-
description: |-
353-
UID of the referent.
354-
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids
355-
type: string
356-
type: object
357-
x-kubernetes-map-type: atomic
358-
type: array
359328
type: object
360329
required:
361330
- spec

0 commit comments

Comments
 (0)