@@ -67,6 +67,7 @@ type VolumeSnapshotList struct {
67
67
// VolumeSnapshotSpec describes the common attributes of a volume snapshot.
68
68
type VolumeSnapshotSpec struct {
69
69
// source specifies where a snapshot will be created from.
70
+ // This field is immutable after creation.
70
71
// Required.
71
72
Source VolumeSnapshotSource `json:"source" protobuf:"bytes,1,opt,name=source"`
72
73
@@ -78,7 +79,9 @@ type VolumeSnapshotSpec struct {
78
79
VolumeSnapshotClassName * string `json:"volumeSnapshotClassName,omitempty" protobuf:"bytes,2,opt,name=volumeSnapshotClassName"`
79
80
}
80
81
81
- // VolumeSnapshotSource represents the source of a snapshot.
82
+ // VolumeSnapshotSource specifies whether the underlying snapshot should be
83
+ // dynamically taken upon creation or if a pre-existing VolumeSnapshotContent
84
+ // object should be used.
82
85
// Exactly one of its members must be set.
83
86
// Members in VolumeSnapshotSource are immutable.
84
87
// TODO(xiangqian): Add a webhook to ensure that VolumeSnapshotSource members
@@ -87,24 +90,26 @@ type VolumeSnapshotSource struct {
87
90
// persistentVolumeClaimName specifies the name of the PersistentVolumeClaim
88
91
// object in the same namespace as the VolumeSnapshot object where the
89
92
// snapshot should be dynamically taken from.
93
+ // This field is immutable once specified.
90
94
// +optional
91
95
PersistentVolumeClaimName * string `json:"persistentVolumeClaimName,omitempty" protobuf:"bytes,1,opt,name=persistentVolumeClaimName"`
92
96
93
97
// volumeSnapshotContentName specifies the name of a pre-existing VolumeSnapshotContent
94
98
// object a user asks to statically bind the VolumeSnapshot object to.
99
+ // This field is immutable once specified.
95
100
// +optional
96
101
VolumeSnapshotContentName * string `json:"volumeSnapshotContentName,omitempty" protobuf:"bytes,2,opt,name=volumeSnapshotContentName"`
97
102
}
98
103
99
104
// VolumeSnapshotStatus is the status of the VolumeSnapshot
100
105
type VolumeSnapshotStatus struct {
101
- // NOTE: All fields in VolumeSnapshotStatus are informational for user references.
102
- // Controllers MUST NOT rely on any fields programmatically.
103
-
104
106
// boundVolumeSnapshotContentName represents the name of the VolumeSnapshotContent
105
107
// object to which the VolumeSnapshot object is bound.
106
108
// If not specified, it indicates that the VolumeSnapshot object has not been
107
109
// successfully bound to a VolumeSnapshotContent object yet.
110
+ // NOTE: Specified boundVolumeSnapshotContentName alone does not mean binding
111
+ // is valid. Controllers MUST always verify bidirectional binding between
112
+ // VolumeSnapshot and VolumeSnapshotContent to avoid possible security issues.
108
113
// +optional
109
114
BoundVolumeSnapshotContentName * string `json:"boundVolumeSnapshotContentName,omitempty" protobuf:"bytes,1,opt,name=boundVolumeSnapshotContentName"`
110
115
@@ -166,6 +171,7 @@ type VolumeSnapshotClass struct {
166
171
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
167
172
168
173
// driver is the name of the storage driver that handles this VolumeSnapshotClass.
174
+ // Required.
169
175
Driver string `json:"driver" protobuf:"bytes,2,opt,name=driver"`
170
176
171
177
// parameters is a key-value map with storage driver specific parameters for creating snapshots.
@@ -215,10 +221,12 @@ type VolumeSnapshotContent struct {
215
221
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
216
222
217
223
// spec defines properties of a VolumeSnapshotContent created by the underlying storage system.
224
+ // Required.
218
225
Spec VolumeSnapshotContentSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"`
219
226
220
227
// status represents the current information of a snapshot.
221
- Status VolumeSnapshotContentStatus `json:"status" protobuf:"bytes,3,opt,name=status"`
228
+ // +optional
229
+ Status VolumeSnapshotContentStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
222
230
}
223
231
224
232
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
@@ -242,6 +250,7 @@ type VolumeSnapshotContentSpec struct {
242
250
// this VolumeSnapshotContent's name for the bidirectional binding to be valid.
243
251
// For a pre-existing VolumeSnapshotContent object, name and namespace of the
244
252
// VolumeSnapshot object MUST be provided for binding to happen.
253
+ // This field is immutable after creation.
245
254
// Required.
246
255
VolumeSnapshotRef core_v1.ObjectReference `json:"volumeSnapshotRef" protobuf:"bytes,1,opt,name=volumeSnapshotRef"`
247
256
@@ -269,23 +278,26 @@ type VolumeSnapshotContentSpec struct {
269
278
SnapshotClassName * string `json:"snapshotClassName,omitempty" protobuf:"bytes,4,opt,name=snapshotClassName"`
270
279
271
280
// source specifies from where a snapshot will be created.
281
+ // This field is immutable after creation.
272
282
// Required.
273
283
Source VolumeSnapshotContentSource `json:"source" protobuf:"bytes,5,opt,name=source"`
274
284
}
275
285
276
- // VolumeSnapshotContentSource represents the source of a snapshot.
286
+ // VolumeSnapshotContentSource represents the CSI source of a snapshot.
277
287
// Exactly one of its members must be set.
278
288
// Members in VolumeSnapshotContentSource are immutable.
279
289
// TODO(xiangqian): Add a webhook to ensure that VolumeSnapshotContentSource members
280
- // will not be updated once specified.
290
+ // will be immutable once specified.
281
291
type VolumeSnapshotContentSource struct {
282
292
// volumeHandle specifies the CSI name of the volume from which a snapshot
283
293
// should be dynamically taken from.
294
+ // This field is immutable once specified.
284
295
// +optional
285
296
VolumeHandle * string `json:"volumeHandle,omitempty" protobuf:"bytes,1,opt,name=volumeHandle"`
286
297
287
298
// snapshotHandle specifies the CSI name of a pre-existing snapshot on the
288
299
// underlying storage system.
300
+ // This field is immutable once specified.
289
301
// +optional
290
302
SnapshotHandle * string `json:"snapshotHandle,omitempty" protobuf:"bytes,2,opt,name=snapshotHandle"`
291
303
}
@@ -322,6 +334,7 @@ type VolumeSnapshotContentStatus struct {
322
334
// If not specified, it means the readiness of a snapshot is unknown.
323
335
// +optional.
324
336
ReadyToUse * bool `json:"readyToUse,omitempty" protobuf:"varint,4,opt,name=readyToUse"`
337
+
325
338
// error is the latest observed error during snapshot creation, if any.
326
339
// +optional
327
340
Error * VolumeSnapshotError `json:"error,omitempty" protobuf:"bytes,5,opt,name=error,casttype=VolumeSnapshotError"`
@@ -332,10 +345,12 @@ type VolumeSnapshotContentStatus struct {
332
345
type DeletionPolicy string
333
346
334
347
const (
335
- // volumeSnapshotContentDelete means the snapshot will be deleted from Kubernetes on release from its volume snapshot.
348
+ // volumeSnapshotContentDelete means the snapshot will be deleted from the
349
+ // underlying storage system on release from its volume snapshot.
336
350
VolumeSnapshotContentDelete DeletionPolicy = "Delete"
337
351
338
- // volumeSnapshotContentRetain means the snapshot will be left in its current state on release from its volume snapshot.
352
+ // volumeSnapshotContentRetain means the snapshot will be left in its current
353
+ // state on release from its volume snapshot.
339
354
VolumeSnapshotContentRetain DeletionPolicy = "Retain"
340
355
)
341
356
0 commit comments