From 038d92c50cdcc5842b423d6e22e6cc723b928519 Mon Sep 17 00:00:00 2001 From: Xing Yang Date: Thu, 11 Jul 2019 12:32:07 -0700 Subject: [PATCH 01/11] Update VolumeSnapshot CRD version to v1beta --- cmd/csi-snapshotter/create_crd.go | 2 +- cmd/csi-snapshotter/main.go | 6 +- ....storage.k8s.io_volumesnapshotclasses.yaml | 59 ++++++ ...storage.k8s.io_volumesnapshotcontents.yaml | 170 ++++++++++++++++++ ...apshot.storage.k8s.io_volumesnapshots.yaml | 121 +++++++++++++ hack/update-generated-code.sh | 2 +- .../{v1alpha1 => v1beta1}/doc.go | 2 +- .../{v1alpha1 => v1beta1}/register.go | 4 +- .../{v1alpha1 => v1beta1}/types.go | 2 +- .../zz_generated.deepcopy.go | 6 +- pkg/client/clientset/versioned/clientset.go | 18 +- .../versioned/fake/clientset_generated.go | 10 +- .../clientset/versioned/fake/register.go | 4 +- .../clientset/versioned/scheme/register.go | 4 +- .../{v1alpha1 => v1beta1}/doc.go | 2 +- .../{v1alpha1 => v1beta1}/fake/doc.go | 0 .../fake/fake_volumesnapshot.go | 50 +++--- .../fake/fake_volumesnapshot_client.go | 12 +- .../fake/fake_volumesnapshotclass.go | 44 ++--- .../fake/fake_volumesnapshotcontent.go | 44 ++--- .../generated_expansion.go | 2 +- .../{v1alpha1 => v1beta1}/volumesnapshot.go | 42 ++--- .../volumesnapshot_client.go | 36 ++-- .../volumesnapshotclass.go | 36 ++-- .../volumesnapshotcontent.go | 36 ++-- .../informers/externalversions/generic.go | 16 +- .../volumesnapshot/interface.go | 12 +- .../{v1alpha1 => v1beta1}/interface.go | 2 +- .../{v1alpha1 => v1beta1}/volumesnapshot.go | 20 +-- .../volumesnapshotclass.go | 20 +-- .../volumesnapshotcontent.go | 20 +-- .../expansion_generated.go | 2 +- .../{v1alpha1 => v1beta1}/volumesnapshot.go | 24 +-- .../volumesnapshotclass.go | 18 +- .../volumesnapshotcontent.go | 18 +- pkg/controller/csi_handler.go | 2 +- pkg/controller/framework_test.go | 14 +- pkg/controller/snapshot_controller.go | 30 ++-- pkg/controller/snapshot_controller_base.go | 6 +- pkg/controller/snapshot_controller_test.go | 2 +- pkg/controller/snapshot_create_test.go | 4 +- pkg/controller/snapshot_delete_test.go | 4 +- pkg/controller/snapshot_ready_test.go | 2 +- pkg/controller/util.go | 2 +- pkg/controller/util_test.go | 2 +- 45 files changed, 642 insertions(+), 292 deletions(-) create mode 100644 config/crd/snapshot.storage.k8s.io_volumesnapshotclasses.yaml create mode 100644 config/crd/snapshot.storage.k8s.io_volumesnapshotcontents.yaml create mode 100644 config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml rename pkg/apis/volumesnapshot/{v1alpha1 => v1beta1}/doc.go (97%) rename pkg/apis/volumesnapshot/{v1alpha1 => v1beta1}/register.go (98%) rename pkg/apis/volumesnapshot/{v1alpha1 => v1beta1}/types.go (99%) rename pkg/apis/volumesnapshot/{v1alpha1 => v1beta1}/zz_generated.deepcopy.go (99%) rename pkg/client/clientset/versioned/typed/volumesnapshot/{v1alpha1 => v1beta1}/doc.go (97%) rename pkg/client/clientset/versioned/typed/volumesnapshot/{v1alpha1 => v1beta1}/fake/doc.go (100%) rename pkg/client/clientset/versioned/typed/volumesnapshot/{v1alpha1 => v1beta1}/fake/fake_volumesnapshot.go (70%) rename pkg/client/clientset/versioned/typed/volumesnapshot/{v1alpha1 => v1beta1}/fake/fake_volumesnapshot_client.go (66%) rename pkg/client/clientset/versioned/typed/volumesnapshot/{v1alpha1 => v1beta1}/fake/fake_volumesnapshotclass.go (72%) rename pkg/client/clientset/versioned/typed/volumesnapshot/{v1alpha1 => v1beta1}/fake/fake_volumesnapshotcontent.go (71%) rename pkg/client/clientset/versioned/typed/volumesnapshot/{v1alpha1 => v1beta1}/generated_expansion.go (97%) rename pkg/client/clientset/versioned/typed/volumesnapshot/{v1alpha1 => v1beta1}/volumesnapshot.go (77%) rename pkg/client/clientset/versioned/typed/volumesnapshot/{v1alpha1 => v1beta1}/volumesnapshot_client.go (61%) rename pkg/client/clientset/versioned/typed/volumesnapshot/{v1alpha1 => v1beta1}/volumesnapshotclass.go (79%) rename pkg/client/clientset/versioned/typed/volumesnapshot/{v1alpha1 => v1beta1}/volumesnapshotcontent.go (80%) rename pkg/client/informers/externalversions/volumesnapshot/{v1alpha1 => v1beta1}/interface.go (99%) rename pkg/client/informers/externalversions/volumesnapshot/{v1alpha1 => v1beta1}/volumesnapshot.go (81%) rename pkg/client/informers/externalversions/volumesnapshot/{v1alpha1 => v1beta1}/volumesnapshotclass.go (81%) rename pkg/client/informers/externalversions/volumesnapshot/{v1alpha1 => v1beta1}/volumesnapshotcontent.go (81%) rename pkg/client/listers/volumesnapshot/{v1alpha1 => v1beta1}/expansion_generated.go (98%) rename pkg/client/listers/volumesnapshot/{v1alpha1 => v1beta1}/volumesnapshot.go (79%) rename pkg/client/listers/volumesnapshot/{v1alpha1 => v1beta1}/volumesnapshotclass.go (75%) rename pkg/client/listers/volumesnapshot/{v1alpha1 => v1beta1}/volumesnapshotcontent.go (74%) diff --git a/cmd/csi-snapshotter/create_crd.go b/cmd/csi-snapshotter/create_crd.go index 0460f691f..36fb8ae8d 100644 --- a/cmd/csi-snapshotter/create_crd.go +++ b/cmd/csi-snapshotter/create_crd.go @@ -16,7 +16,7 @@ package main import ( "reflect" - crdv1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + crdv1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" apiextensionsclient "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" apierrors "k8s.io/apimachinery/pkg/api/errors" diff --git a/cmd/csi-snapshotter/main.go b/cmd/csi-snapshotter/main.go index df1b11663..6e6b3cdc7 100644 --- a/cmd/csi-snapshotter/main.go +++ b/cmd/csi-snapshotter/main.go @@ -185,9 +185,9 @@ func main() { snapClient, kubeClient, *snapshotterName, - factory.Snapshot().V1alpha1().VolumeSnapshots(), - factory.Snapshot().V1alpha1().VolumeSnapshotContents(), - factory.Snapshot().V1alpha1().VolumeSnapshotClasses(), + factory.Snapshot().V1beta1().VolumeSnapshots(), + factory.Snapshot().V1beta1().VolumeSnapshotContents(), + factory.Snapshot().V1beta1().VolumeSnapshotClasses(), coreFactory.Core().V1().PersistentVolumeClaims(), *createSnapshotContentRetryCount, *createSnapshotContentInterval, diff --git a/config/crd/snapshot.storage.k8s.io_volumesnapshotclasses.yaml b/config/crd/snapshot.storage.k8s.io_volumesnapshotclasses.yaml new file mode 100644 index 000000000..f4e83af9f --- /dev/null +++ b/config/crd/snapshot.storage.k8s.io_volumesnapshotclasses.yaml @@ -0,0 +1,59 @@ + +--- +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + creationTimestamp: null + name: volumesnapshotclasses.snapshot.storage.k8s.io +spec: + group: snapshot.storage.k8s.io + names: + kind: VolumeSnapshotClass + plural: volumesnapshotclasses + scope: "" + version: v1beta1 + versions: + - name: v1beta1 + schema: + openAPIV3Schema: + description: VolumeSnapshotClass describes the parameters used by storage + system when provisioning VolumeSnapshots from PVCs. The name of a VolumeSnapshotClass + object is significant, and is how users can request a particular class. + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources' + type: string + deletionPolicy: + description: 'Optional: what happens to a snapshot content when released + from its snapshot. The default policy is Delete if not specified.' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds' + type: string + metadata: + description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata' + type: object + parameters: + additionalProperties: + type: string + description: Parameters holds parameters for the snapshotter. These values + are opaque to the system and are passed directly to the snapshotter. + type: object + snapshotter: + description: Snapshotter is the driver expected to handle this VolumeSnapshotClass. + type: string + required: + - snapshotter + type: object + served: true + storage: true +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] diff --git a/config/crd/snapshot.storage.k8s.io_volumesnapshotcontents.yaml b/config/crd/snapshot.storage.k8s.io_volumesnapshotcontents.yaml new file mode 100644 index 000000000..5b9b8379a --- /dev/null +++ b/config/crd/snapshot.storage.k8s.io_volumesnapshotcontents.yaml @@ -0,0 +1,170 @@ + +--- +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + creationTimestamp: null + name: volumesnapshotcontents.snapshot.storage.k8s.io +spec: + group: snapshot.storage.k8s.io + names: + kind: VolumeSnapshotContent + plural: volumesnapshotcontents + scope: "" + version: v1beta1 + versions: + - name: v1beta1 + schema: + openAPIV3Schema: + description: VolumeSnapshotContent represents the actual "on-disk" snapshot + object + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds' + type: string + metadata: + description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata' + type: object + spec: + description: Spec represents the desired state of the snapshot content + properties: + csiVolumeSnapshotSource: + description: CSI (Container Storage Interface) represents storage + that handled by an external CSI Volume Driver (Alpha feature). + properties: + creationTime: + description: Timestamp when the point-in-time snapshot is taken + on the storage system. This timestamp will be generated by the + CSI volume driver after the snapshot is cut. The format of this + field should be 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. This field is + required in the CSI spec but optional here to support static + binding. + format: int64 + type: integer + driver: + description: Driver is the name of the driver to use for this + snapshot. This MUST be the same name returned by the CSI GetPluginName() + call for that driver. Required. + type: string + restoreSize: + description: When restoring volume from the snapshot, the volume + size should be equal to or larger than the RestoreSize if it + is specified. If RestoreSize is set to nil, it means that the + storage plugin does not have this information available. + format: int64 + type: integer + snapshotHandle: + description: SnapshotHandle is the unique snapshot id returned + by the CSI volume plugin’s CreateSnapshot to refer to the snapshot + on all subsequent calls. Required. + type: string + required: + - driver + - snapshotHandle + type: object + deletionPolicy: + description: 'Optional: what happens to a snapshot content when released + from its snapshot. It will be set to Delete by default if not specified' + type: string + persistentVolumeRef: + description: PersistentVolumeRef represents the PersistentVolume that + the snapshot has been taken from. It becomes non-nil when VolumeSnapshot + and VolumeSnapshotContent are bound. + properties: + apiVersion: + description: API version of the referent. + type: string + fieldPath: + description: 'If referring to a piece of an object instead of + an entire object, this string should contain a valid JSON/Go + field access statement, such as desiredState.manifest.containers[2]. + For example, if the object reference is to a container within + a pod, this would take on a value like: "spec.containers{name}" + (where "name" refers to the name of the container that triggered + the event) or if no container name is specified "spec.containers[2]" + (container with index 2 in this pod). This syntax is chosen + only to have some well-defined way of referencing a part of + an object. TODO: this design is not final and this field is + subject to change in the future.' + type: string + kind: + description: 'Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds' + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names' + type: string + namespace: + description: 'Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/' + type: string + resourceVersion: + description: 'Specific resourceVersion to which this reference + is made, if any. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#concurrency-control-and-consistency' + type: string + uid: + description: 'UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids' + type: string + type: object + snapshotClassName: + description: Name of the VolumeSnapshotClass used by the VolumeSnapshot. + If not specified, a default snapshot class will be used if it is + available. + type: string + volumeSnapshotRef: + description: VolumeSnapshotRef is part of bi-directional binding between + VolumeSnapshot and VolumeSnapshotContent. It becomes non-nil when + bound. + properties: + apiVersion: + description: API version of the referent. + type: string + fieldPath: + description: 'If referring to a piece of an object instead of + an entire object, this string should contain a valid JSON/Go + field access statement, such as desiredState.manifest.containers[2]. + For example, if the object reference is to a container within + a pod, this would take on a value like: "spec.containers{name}" + (where "name" refers to the name of the container that triggered + the event) or if no container name is specified "spec.containers[2]" + (container with index 2 in this pod). This syntax is chosen + only to have some well-defined way of referencing a part of + an object. TODO: this design is not final and this field is + subject to change in the future.' + type: string + kind: + description: 'Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds' + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names' + type: string + namespace: + description: 'Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/' + type: string + resourceVersion: + description: 'Specific resourceVersion to which this reference + is made, if any. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#concurrency-control-and-consistency' + type: string + uid: + description: 'UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids' + type: string + type: object + type: object + required: + - spec + type: object + served: true + storage: true +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] diff --git a/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml b/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml new file mode 100644 index 000000000..7b4182456 --- /dev/null +++ b/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml @@ -0,0 +1,121 @@ + +--- +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + creationTimestamp: null + name: volumesnapshots.snapshot.storage.k8s.io +spec: + group: snapshot.storage.k8s.io + names: + kind: VolumeSnapshot + plural: volumesnapshots + scope: "" + version: v1beta1 + versions: + - name: v1beta1 + schema: + openAPIV3Schema: + description: VolumeSnapshot is a user's request for taking a snapshot. Upon + successful creation of the actual snapshot by the volume provider it is + bound to the corresponding VolumeSnapshotContent. Only the VolumeSnapshot + object is accessible to the user in the namespace. + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds' + type: string + metadata: + description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata' + type: object + spec: + description: Spec defines the desired characteristics of a snapshot requested + by a user. + properties: + snapshotClassName: + description: Name of the VolumeSnapshotClass used by the VolumeSnapshot. + If not specified, a default snapshot class will be used if it is + available. + type: string + snapshotContentName: + description: SnapshotContentName binds the VolumeSnapshot object with + the VolumeSnapshotContent + type: string + source: + description: Source has the information about where the snapshot is + created from. In Alpha version, only PersistentVolumeClaim is supported + as the source. If not specified, user can create VolumeSnapshotContent + and bind it with VolumeSnapshot manually. + properties: + apiGroup: + description: APIGroup is the group for the resource being referenced. + If APIGroup is not specified, the specified Kind must be in + the core API group. For any other third-party types, APIGroup + is required. + type: string + kind: + description: Kind is the type of resource being referenced + type: string + name: + description: Name is the name of resource being referenced + type: string + required: + - kind + - name + type: object + type: object + status: + description: Status represents the latest observed state of the snapshot + properties: + creationTime: + description: CreationTime is the time the snapshot was successfully + created. If it is set, it means the snapshot was created; Otherwise + the snapshot was not created. + format: date-time + type: string + error: + description: The last error encountered during create snapshot operation, + if any. This field must only be set by the entity completing the + create snapshot operation, i.e. the external-snapshotter. + properties: + message: + description: String detailing the error encountered during Attach + or Detach operation. This string may be logged, so it should + not contain sensitive information. + type: string + time: + description: Time the error was encountered. + format: date-time + type: string + type: object + readyToUse: + description: ReadyToUse is set to true only if the snapshot is ready + to use (e.g., finish uploading if there is an uploading phase) and + also VolumeSnapshot and its VolumeSnapshotContent bind correctly + with each other. If any of the above condition is not true, ReadyToUse + is set to false + type: boolean + restoreSize: + description: When restoring volume from the snapshot, the volume size + should be equal to or larger than the RestoreSize if it is specified. + If RestoreSize is set to nil, it means that the storage plugin does + not have this information available. + type: string + type: object + required: + - spec + type: object + served: true + storage: true +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] diff --git a/hack/update-generated-code.sh b/hack/update-generated-code.sh index f48150d77..d682028f2 100755 --- a/hack/update-generated-code.sh +++ b/hack/update-generated-code.sh @@ -29,7 +29,7 @@ CODEGEN_PKG=${CODEGEN_PKG:-$(cd ${SCRIPT_ROOT}; ls -d -1 ./vendor/k8s.io/code-ge # instead of the $GOPATH directly. For normal projects this can be dropped. ${CODEGEN_PKG}/generate-groups.sh "deepcopy,client,informer,lister" \ github.com/kubernetes-csi/external-snapshotter/pkg/client github.com/kubernetes-csi/external-snapshotter/pkg/apis \ - volumesnapshot:v1alpha1 \ + volumesnapshot:v1beta1 \ --go-header-file ${SCRIPT_ROOT}/hack/boilerplate.go.txt # To use your own boilerplate text use: diff --git a/pkg/apis/volumesnapshot/v1alpha1/doc.go b/pkg/apis/volumesnapshot/v1beta1/doc.go similarity index 97% rename from pkg/apis/volumesnapshot/v1alpha1/doc.go rename to pkg/apis/volumesnapshot/v1beta1/doc.go index 90642a58b..d8a1f5dad 100644 --- a/pkg/apis/volumesnapshot/v1alpha1/doc.go +++ b/pkg/apis/volumesnapshot/v1beta1/doc.go @@ -17,4 +17,4 @@ limitations under the License. // +k8s:deepcopy-gen=package // +groupName=snapshot.storage.k8s.io -package v1alpha1 +package v1beta1 diff --git a/pkg/apis/volumesnapshot/v1alpha1/register.go b/pkg/apis/volumesnapshot/v1beta1/register.go similarity index 98% rename from pkg/apis/volumesnapshot/v1alpha1/register.go rename to pkg/apis/volumesnapshot/v1beta1/register.go index e7c38b6ba..91f451424 100644 --- a/pkg/apis/volumesnapshot/v1alpha1/register.go +++ b/pkg/apis/volumesnapshot/v1beta1/register.go @@ -11,7 +11,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1alpha1 +package v1beta1 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -28,7 +28,7 @@ var ( // AddToScheme adds to scheme AddToScheme = SchemeBuilder.AddToScheme // SchemeGroupVersion is the group version used to register these objects. - SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"} + SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1beta1"} ) // Resource takes an unqualified resource and returns a Group-qualified GroupResource. diff --git a/pkg/apis/volumesnapshot/v1alpha1/types.go b/pkg/apis/volumesnapshot/v1beta1/types.go similarity index 99% rename from pkg/apis/volumesnapshot/v1alpha1/types.go rename to pkg/apis/volumesnapshot/v1beta1/types.go index 65c1aafaa..2fb0b8e75 100644 --- a/pkg/apis/volumesnapshot/v1alpha1/types.go +++ b/pkg/apis/volumesnapshot/v1beta1/types.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1alpha1 +package v1beta1 import ( core_v1 "k8s.io/api/core/v1" diff --git a/pkg/apis/volumesnapshot/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/volumesnapshot/v1beta1/zz_generated.deepcopy.go similarity index 99% rename from pkg/apis/volumesnapshot/v1alpha1/zz_generated.deepcopy.go rename to pkg/apis/volumesnapshot/v1beta1/zz_generated.deepcopy.go index 38db004a8..5bc2c2028 100644 --- a/pkg/apis/volumesnapshot/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/volumesnapshot/v1beta1/zz_generated.deepcopy.go @@ -18,11 +18,11 @@ limitations under the License. // Code generated by deepcopy-gen. DO NOT EDIT. -package v1alpha1 +package v1beta1 import ( v1 "k8s.io/api/core/v1" - v1beta1 "k8s.io/api/storage/v1beta1" + storagev1beta1 "k8s.io/api/storage/v1beta1" runtime "k8s.io/apimachinery/pkg/runtime" ) @@ -342,7 +342,7 @@ func (in *VolumeSnapshotStatus) DeepCopyInto(out *VolumeSnapshotStatus) { } if in.Error != nil { in, out := &in.Error, &out.Error - *out = new(v1beta1.VolumeError) + *out = new(storagev1beta1.VolumeError) (*in).DeepCopyInto(*out) } return diff --git a/pkg/client/clientset/versioned/clientset.go b/pkg/client/clientset/versioned/clientset.go index 5bcff9985..25be21b49 100644 --- a/pkg/client/clientset/versioned/clientset.go +++ b/pkg/client/clientset/versioned/clientset.go @@ -19,7 +19,7 @@ limitations under the License. package versioned import ( - snapshotv1alpha1 "github.com/kubernetes-csi/external-snapshotter/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1" + snapshotv1beta1 "github.com/kubernetes-csi/external-snapshotter/pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1" discovery "k8s.io/client-go/discovery" rest "k8s.io/client-go/rest" flowcontrol "k8s.io/client-go/util/flowcontrol" @@ -27,19 +27,19 @@ import ( type Interface interface { Discovery() discovery.DiscoveryInterface - SnapshotV1alpha1() snapshotv1alpha1.SnapshotV1alpha1Interface + SnapshotV1beta1() snapshotv1beta1.SnapshotV1beta1Interface } // Clientset contains the clients for groups. Each group has exactly one // version included in a Clientset. type Clientset struct { *discovery.DiscoveryClient - snapshotV1alpha1 *snapshotv1alpha1.SnapshotV1alpha1Client + snapshotV1beta1 *snapshotv1beta1.SnapshotV1beta1Client } -// SnapshotV1alpha1 retrieves the SnapshotV1alpha1Client -func (c *Clientset) SnapshotV1alpha1() snapshotv1alpha1.SnapshotV1alpha1Interface { - return c.snapshotV1alpha1 +// SnapshotV1beta1 retrieves the SnapshotV1beta1Client +func (c *Clientset) SnapshotV1beta1() snapshotv1beta1.SnapshotV1beta1Interface { + return c.snapshotV1beta1 } // Discovery retrieves the DiscoveryClient @@ -58,7 +58,7 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { } var cs Clientset var err error - cs.snapshotV1alpha1, err = snapshotv1alpha1.NewForConfig(&configShallowCopy) + cs.snapshotV1beta1, err = snapshotv1beta1.NewForConfig(&configShallowCopy) if err != nil { return nil, err } @@ -74,7 +74,7 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { // panics if there is an error in the config. func NewForConfigOrDie(c *rest.Config) *Clientset { var cs Clientset - cs.snapshotV1alpha1 = snapshotv1alpha1.NewForConfigOrDie(c) + cs.snapshotV1beta1 = snapshotv1beta1.NewForConfigOrDie(c) cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) return &cs @@ -83,7 +83,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset { // New creates a new Clientset for the given RESTClient. func New(c rest.Interface) *Clientset { var cs Clientset - cs.snapshotV1alpha1 = snapshotv1alpha1.New(c) + cs.snapshotV1beta1 = snapshotv1beta1.New(c) cs.DiscoveryClient = discovery.NewDiscoveryClient(c) return &cs diff --git a/pkg/client/clientset/versioned/fake/clientset_generated.go b/pkg/client/clientset/versioned/fake/clientset_generated.go index 0c5b82937..b05e85ea7 100644 --- a/pkg/client/clientset/versioned/fake/clientset_generated.go +++ b/pkg/client/clientset/versioned/fake/clientset_generated.go @@ -20,8 +20,8 @@ package fake import ( clientset "github.com/kubernetes-csi/external-snapshotter/pkg/client/clientset/versioned" - snapshotv1alpha1 "github.com/kubernetes-csi/external-snapshotter/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1" - fakesnapshotv1alpha1 "github.com/kubernetes-csi/external-snapshotter/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/fake" + snapshotv1beta1 "github.com/kubernetes-csi/external-snapshotter/pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1" + fakesnapshotv1beta1 "github.com/kubernetes-csi/external-snapshotter/pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/fake" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/watch" "k8s.io/client-go/discovery" @@ -71,7 +71,7 @@ func (c *Clientset) Discovery() discovery.DiscoveryInterface { var _ clientset.Interface = &Clientset{} -// SnapshotV1alpha1 retrieves the SnapshotV1alpha1Client -func (c *Clientset) SnapshotV1alpha1() snapshotv1alpha1.SnapshotV1alpha1Interface { - return &fakesnapshotv1alpha1.FakeSnapshotV1alpha1{Fake: &c.Fake} +// SnapshotV1beta1 retrieves the SnapshotV1beta1Client +func (c *Clientset) SnapshotV1beta1() snapshotv1beta1.SnapshotV1beta1Interface { + return &fakesnapshotv1beta1.FakeSnapshotV1beta1{Fake: &c.Fake} } diff --git a/pkg/client/clientset/versioned/fake/register.go b/pkg/client/clientset/versioned/fake/register.go index 903889fd9..4c92bf112 100644 --- a/pkg/client/clientset/versioned/fake/register.go +++ b/pkg/client/clientset/versioned/fake/register.go @@ -19,7 +19,7 @@ limitations under the License. package fake import ( - snapshotv1alpha1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + snapshotv1beta1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -31,7 +31,7 @@ var scheme = runtime.NewScheme() var codecs = serializer.NewCodecFactory(scheme) var parameterCodec = runtime.NewParameterCodec(scheme) var localSchemeBuilder = runtime.SchemeBuilder{ - snapshotv1alpha1.AddToScheme, + snapshotv1beta1.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition diff --git a/pkg/client/clientset/versioned/scheme/register.go b/pkg/client/clientset/versioned/scheme/register.go index 46efa8fe5..296f7fa70 100644 --- a/pkg/client/clientset/versioned/scheme/register.go +++ b/pkg/client/clientset/versioned/scheme/register.go @@ -19,7 +19,7 @@ limitations under the License. package scheme import ( - snapshotv1alpha1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + snapshotv1beta1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -31,7 +31,7 @@ var Scheme = runtime.NewScheme() var Codecs = serializer.NewCodecFactory(Scheme) var ParameterCodec = runtime.NewParameterCodec(Scheme) var localSchemeBuilder = runtime.SchemeBuilder{ - snapshotv1alpha1.AddToScheme, + snapshotv1beta1.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition diff --git a/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/doc.go b/pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/doc.go similarity index 97% rename from pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/doc.go rename to pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/doc.go index 9752e759c..305440eb2 100644 --- a/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/doc.go +++ b/pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/doc.go @@ -17,4 +17,4 @@ limitations under the License. // Code generated by client-gen. DO NOT EDIT. // This package has the automatically generated typed clients. -package v1alpha1 +package v1beta1 diff --git a/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/fake/doc.go b/pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/fake/doc.go similarity index 100% rename from pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/fake/doc.go rename to pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/fake/doc.go diff --git a/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/fake/fake_volumesnapshot.go b/pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/fake/fake_volumesnapshot.go similarity index 70% rename from pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/fake/fake_volumesnapshot.go rename to pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/fake/fake_volumesnapshot.go index 05016a1a2..72faad7d8 100644 --- a/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/fake/fake_volumesnapshot.go +++ b/pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/fake/fake_volumesnapshot.go @@ -19,7 +19,7 @@ limitations under the License. package fake import ( - v1alpha1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + v1beta1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -30,29 +30,29 @@ import ( // FakeVolumeSnapshots implements VolumeSnapshotInterface type FakeVolumeSnapshots struct { - Fake *FakeSnapshotV1alpha1 + Fake *FakeSnapshotV1beta1 ns string } -var volumesnapshotsResource = schema.GroupVersionResource{Group: "snapshot.storage.k8s.io", Version: "v1alpha1", Resource: "volumesnapshots"} +var volumesnapshotsResource = schema.GroupVersionResource{Group: "snapshot.storage.k8s.io", Version: "v1beta1", Resource: "volumesnapshots"} -var volumesnapshotsKind = schema.GroupVersionKind{Group: "snapshot.storage.k8s.io", Version: "v1alpha1", Kind: "VolumeSnapshot"} +var volumesnapshotsKind = schema.GroupVersionKind{Group: "snapshot.storage.k8s.io", Version: "v1beta1", Kind: "VolumeSnapshot"} // Get takes name of the volumeSnapshot, and returns the corresponding volumeSnapshot object, and an error if there is any. -func (c *FakeVolumeSnapshots) Get(name string, options v1.GetOptions) (result *v1alpha1.VolumeSnapshot, err error) { +func (c *FakeVolumeSnapshots) Get(name string, options v1.GetOptions) (result *v1beta1.VolumeSnapshot, err error) { obj, err := c.Fake. - Invokes(testing.NewGetAction(volumesnapshotsResource, c.ns, name), &v1alpha1.VolumeSnapshot{}) + Invokes(testing.NewGetAction(volumesnapshotsResource, c.ns, name), &v1beta1.VolumeSnapshot{}) if obj == nil { return nil, err } - return obj.(*v1alpha1.VolumeSnapshot), err + return obj.(*v1beta1.VolumeSnapshot), err } // List takes label and field selectors, and returns the list of VolumeSnapshots that match those selectors. -func (c *FakeVolumeSnapshots) List(opts v1.ListOptions) (result *v1alpha1.VolumeSnapshotList, err error) { +func (c *FakeVolumeSnapshots) List(opts v1.ListOptions) (result *v1beta1.VolumeSnapshotList, err error) { obj, err := c.Fake. - Invokes(testing.NewListAction(volumesnapshotsResource, volumesnapshotsKind, c.ns, opts), &v1alpha1.VolumeSnapshotList{}) + Invokes(testing.NewListAction(volumesnapshotsResource, volumesnapshotsKind, c.ns, opts), &v1beta1.VolumeSnapshotList{}) if obj == nil { return nil, err @@ -62,8 +62,8 @@ func (c *FakeVolumeSnapshots) List(opts v1.ListOptions) (result *v1alpha1.Volume if label == nil { label = labels.Everything() } - list := &v1alpha1.VolumeSnapshotList{ListMeta: obj.(*v1alpha1.VolumeSnapshotList).ListMeta} - for _, item := range obj.(*v1alpha1.VolumeSnapshotList).Items { + list := &v1beta1.VolumeSnapshotList{ListMeta: obj.(*v1beta1.VolumeSnapshotList).ListMeta} + for _, item := range obj.(*v1beta1.VolumeSnapshotList).Items { if label.Matches(labels.Set(item.Labels)) { list.Items = append(list.Items, item) } @@ -79,43 +79,43 @@ func (c *FakeVolumeSnapshots) Watch(opts v1.ListOptions) (watch.Interface, error } // Create takes the representation of a volumeSnapshot and creates it. Returns the server's representation of the volumeSnapshot, and an error, if there is any. -func (c *FakeVolumeSnapshots) Create(volumeSnapshot *v1alpha1.VolumeSnapshot) (result *v1alpha1.VolumeSnapshot, err error) { +func (c *FakeVolumeSnapshots) Create(volumeSnapshot *v1beta1.VolumeSnapshot) (result *v1beta1.VolumeSnapshot, err error) { obj, err := c.Fake. - Invokes(testing.NewCreateAction(volumesnapshotsResource, c.ns, volumeSnapshot), &v1alpha1.VolumeSnapshot{}) + Invokes(testing.NewCreateAction(volumesnapshotsResource, c.ns, volumeSnapshot), &v1beta1.VolumeSnapshot{}) if obj == nil { return nil, err } - return obj.(*v1alpha1.VolumeSnapshot), err + return obj.(*v1beta1.VolumeSnapshot), err } // Update takes the representation of a volumeSnapshot and updates it. Returns the server's representation of the volumeSnapshot, and an error, if there is any. -func (c *FakeVolumeSnapshots) Update(volumeSnapshot *v1alpha1.VolumeSnapshot) (result *v1alpha1.VolumeSnapshot, err error) { +func (c *FakeVolumeSnapshots) Update(volumeSnapshot *v1beta1.VolumeSnapshot) (result *v1beta1.VolumeSnapshot, err error) { obj, err := c.Fake. - Invokes(testing.NewUpdateAction(volumesnapshotsResource, c.ns, volumeSnapshot), &v1alpha1.VolumeSnapshot{}) + Invokes(testing.NewUpdateAction(volumesnapshotsResource, c.ns, volumeSnapshot), &v1beta1.VolumeSnapshot{}) if obj == nil { return nil, err } - return obj.(*v1alpha1.VolumeSnapshot), err + return obj.(*v1beta1.VolumeSnapshot), err } // UpdateStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeVolumeSnapshots) UpdateStatus(volumeSnapshot *v1alpha1.VolumeSnapshot) (*v1alpha1.VolumeSnapshot, error) { +func (c *FakeVolumeSnapshots) UpdateStatus(volumeSnapshot *v1beta1.VolumeSnapshot) (*v1beta1.VolumeSnapshot, error) { obj, err := c.Fake. - Invokes(testing.NewUpdateSubresourceAction(volumesnapshotsResource, "status", c.ns, volumeSnapshot), &v1alpha1.VolumeSnapshot{}) + Invokes(testing.NewUpdateSubresourceAction(volumesnapshotsResource, "status", c.ns, volumeSnapshot), &v1beta1.VolumeSnapshot{}) if obj == nil { return nil, err } - return obj.(*v1alpha1.VolumeSnapshot), err + return obj.(*v1beta1.VolumeSnapshot), err } // Delete takes name of the volumeSnapshot and deletes it. Returns an error if one occurs. func (c *FakeVolumeSnapshots) Delete(name string, options *v1.DeleteOptions) error { _, err := c.Fake. - Invokes(testing.NewDeleteAction(volumesnapshotsResource, c.ns, name), &v1alpha1.VolumeSnapshot{}) + Invokes(testing.NewDeleteAction(volumesnapshotsResource, c.ns, name), &v1beta1.VolumeSnapshot{}) return err } @@ -124,17 +124,17 @@ func (c *FakeVolumeSnapshots) Delete(name string, options *v1.DeleteOptions) err func (c *FakeVolumeSnapshots) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { action := testing.NewDeleteCollectionAction(volumesnapshotsResource, c.ns, listOptions) - _, err := c.Fake.Invokes(action, &v1alpha1.VolumeSnapshotList{}) + _, err := c.Fake.Invokes(action, &v1beta1.VolumeSnapshotList{}) return err } // Patch applies the patch and returns the patched volumeSnapshot. -func (c *FakeVolumeSnapshots) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.VolumeSnapshot, err error) { +func (c *FakeVolumeSnapshots) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.VolumeSnapshot, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(volumesnapshotsResource, c.ns, name, pt, data, subresources...), &v1alpha1.VolumeSnapshot{}) + Invokes(testing.NewPatchSubresourceAction(volumesnapshotsResource, c.ns, name, pt, data, subresources...), &v1beta1.VolumeSnapshot{}) if obj == nil { return nil, err } - return obj.(*v1alpha1.VolumeSnapshot), err + return obj.(*v1beta1.VolumeSnapshot), err } diff --git a/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/fake/fake_volumesnapshot_client.go b/pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/fake/fake_volumesnapshot_client.go similarity index 66% rename from pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/fake/fake_volumesnapshot_client.go rename to pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/fake/fake_volumesnapshot_client.go index 6c8b11a57..56f7a0dd1 100644 --- a/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/fake/fake_volumesnapshot_client.go +++ b/pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/fake/fake_volumesnapshot_client.go @@ -19,30 +19,30 @@ limitations under the License. package fake import ( - v1alpha1 "github.com/kubernetes-csi/external-snapshotter/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1" + v1beta1 "github.com/kubernetes-csi/external-snapshotter/pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1" rest "k8s.io/client-go/rest" testing "k8s.io/client-go/testing" ) -type FakeSnapshotV1alpha1 struct { +type FakeSnapshotV1beta1 struct { *testing.Fake } -func (c *FakeSnapshotV1alpha1) VolumeSnapshots(namespace string) v1alpha1.VolumeSnapshotInterface { +func (c *FakeSnapshotV1beta1) VolumeSnapshots(namespace string) v1beta1.VolumeSnapshotInterface { return &FakeVolumeSnapshots{c, namespace} } -func (c *FakeSnapshotV1alpha1) VolumeSnapshotClasses() v1alpha1.VolumeSnapshotClassInterface { +func (c *FakeSnapshotV1beta1) VolumeSnapshotClasses() v1beta1.VolumeSnapshotClassInterface { return &FakeVolumeSnapshotClasses{c} } -func (c *FakeSnapshotV1alpha1) VolumeSnapshotContents() v1alpha1.VolumeSnapshotContentInterface { +func (c *FakeSnapshotV1beta1) VolumeSnapshotContents() v1beta1.VolumeSnapshotContentInterface { return &FakeVolumeSnapshotContents{c} } // RESTClient returns a RESTClient that is used to communicate // with API server by this client implementation. -func (c *FakeSnapshotV1alpha1) RESTClient() rest.Interface { +func (c *FakeSnapshotV1beta1) RESTClient() rest.Interface { var ret *rest.RESTClient return ret } diff --git a/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/fake/fake_volumesnapshotclass.go b/pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/fake/fake_volumesnapshotclass.go similarity index 72% rename from pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/fake/fake_volumesnapshotclass.go rename to pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/fake/fake_volumesnapshotclass.go index 5c756b20b..bd4013c39 100644 --- a/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/fake/fake_volumesnapshotclass.go +++ b/pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/fake/fake_volumesnapshotclass.go @@ -19,7 +19,7 @@ limitations under the License. package fake import ( - v1alpha1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + v1beta1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -30,27 +30,27 @@ import ( // FakeVolumeSnapshotClasses implements VolumeSnapshotClassInterface type FakeVolumeSnapshotClasses struct { - Fake *FakeSnapshotV1alpha1 + Fake *FakeSnapshotV1beta1 } -var volumesnapshotclassesResource = schema.GroupVersionResource{Group: "snapshot.storage.k8s.io", Version: "v1alpha1", Resource: "volumesnapshotclasses"} +var volumesnapshotclassesResource = schema.GroupVersionResource{Group: "snapshot.storage.k8s.io", Version: "v1beta1", Resource: "volumesnapshotclasses"} -var volumesnapshotclassesKind = schema.GroupVersionKind{Group: "snapshot.storage.k8s.io", Version: "v1alpha1", Kind: "VolumeSnapshotClass"} +var volumesnapshotclassesKind = schema.GroupVersionKind{Group: "snapshot.storage.k8s.io", Version: "v1beta1", Kind: "VolumeSnapshotClass"} // Get takes name of the volumeSnapshotClass, and returns the corresponding volumeSnapshotClass object, and an error if there is any. -func (c *FakeVolumeSnapshotClasses) Get(name string, options v1.GetOptions) (result *v1alpha1.VolumeSnapshotClass, err error) { +func (c *FakeVolumeSnapshotClasses) Get(name string, options v1.GetOptions) (result *v1beta1.VolumeSnapshotClass, err error) { obj, err := c.Fake. - Invokes(testing.NewRootGetAction(volumesnapshotclassesResource, name), &v1alpha1.VolumeSnapshotClass{}) + Invokes(testing.NewRootGetAction(volumesnapshotclassesResource, name), &v1beta1.VolumeSnapshotClass{}) if obj == nil { return nil, err } - return obj.(*v1alpha1.VolumeSnapshotClass), err + return obj.(*v1beta1.VolumeSnapshotClass), err } // List takes label and field selectors, and returns the list of VolumeSnapshotClasses that match those selectors. -func (c *FakeVolumeSnapshotClasses) List(opts v1.ListOptions) (result *v1alpha1.VolumeSnapshotClassList, err error) { +func (c *FakeVolumeSnapshotClasses) List(opts v1.ListOptions) (result *v1beta1.VolumeSnapshotClassList, err error) { obj, err := c.Fake. - Invokes(testing.NewRootListAction(volumesnapshotclassesResource, volumesnapshotclassesKind, opts), &v1alpha1.VolumeSnapshotClassList{}) + Invokes(testing.NewRootListAction(volumesnapshotclassesResource, volumesnapshotclassesKind, opts), &v1beta1.VolumeSnapshotClassList{}) if obj == nil { return nil, err } @@ -59,8 +59,8 @@ func (c *FakeVolumeSnapshotClasses) List(opts v1.ListOptions) (result *v1alpha1. if label == nil { label = labels.Everything() } - list := &v1alpha1.VolumeSnapshotClassList{ListMeta: obj.(*v1alpha1.VolumeSnapshotClassList).ListMeta} - for _, item := range obj.(*v1alpha1.VolumeSnapshotClassList).Items { + list := &v1beta1.VolumeSnapshotClassList{ListMeta: obj.(*v1beta1.VolumeSnapshotClassList).ListMeta} + for _, item := range obj.(*v1beta1.VolumeSnapshotClassList).Items { if label.Matches(labels.Set(item.Labels)) { list.Items = append(list.Items, item) } @@ -75,29 +75,29 @@ func (c *FakeVolumeSnapshotClasses) Watch(opts v1.ListOptions) (watch.Interface, } // Create takes the representation of a volumeSnapshotClass and creates it. Returns the server's representation of the volumeSnapshotClass, and an error, if there is any. -func (c *FakeVolumeSnapshotClasses) Create(volumeSnapshotClass *v1alpha1.VolumeSnapshotClass) (result *v1alpha1.VolumeSnapshotClass, err error) { +func (c *FakeVolumeSnapshotClasses) Create(volumeSnapshotClass *v1beta1.VolumeSnapshotClass) (result *v1beta1.VolumeSnapshotClass, err error) { obj, err := c.Fake. - Invokes(testing.NewRootCreateAction(volumesnapshotclassesResource, volumeSnapshotClass), &v1alpha1.VolumeSnapshotClass{}) + Invokes(testing.NewRootCreateAction(volumesnapshotclassesResource, volumeSnapshotClass), &v1beta1.VolumeSnapshotClass{}) if obj == nil { return nil, err } - return obj.(*v1alpha1.VolumeSnapshotClass), err + return obj.(*v1beta1.VolumeSnapshotClass), err } // Update takes the representation of a volumeSnapshotClass and updates it. Returns the server's representation of the volumeSnapshotClass, and an error, if there is any. -func (c *FakeVolumeSnapshotClasses) Update(volumeSnapshotClass *v1alpha1.VolumeSnapshotClass) (result *v1alpha1.VolumeSnapshotClass, err error) { +func (c *FakeVolumeSnapshotClasses) Update(volumeSnapshotClass *v1beta1.VolumeSnapshotClass) (result *v1beta1.VolumeSnapshotClass, err error) { obj, err := c.Fake. - Invokes(testing.NewRootUpdateAction(volumesnapshotclassesResource, volumeSnapshotClass), &v1alpha1.VolumeSnapshotClass{}) + Invokes(testing.NewRootUpdateAction(volumesnapshotclassesResource, volumeSnapshotClass), &v1beta1.VolumeSnapshotClass{}) if obj == nil { return nil, err } - return obj.(*v1alpha1.VolumeSnapshotClass), err + return obj.(*v1beta1.VolumeSnapshotClass), err } // Delete takes name of the volumeSnapshotClass and deletes it. Returns an error if one occurs. func (c *FakeVolumeSnapshotClasses) Delete(name string, options *v1.DeleteOptions) error { _, err := c.Fake. - Invokes(testing.NewRootDeleteAction(volumesnapshotclassesResource, name), &v1alpha1.VolumeSnapshotClass{}) + Invokes(testing.NewRootDeleteAction(volumesnapshotclassesResource, name), &v1beta1.VolumeSnapshotClass{}) return err } @@ -105,16 +105,16 @@ func (c *FakeVolumeSnapshotClasses) Delete(name string, options *v1.DeleteOption func (c *FakeVolumeSnapshotClasses) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { action := testing.NewRootDeleteCollectionAction(volumesnapshotclassesResource, listOptions) - _, err := c.Fake.Invokes(action, &v1alpha1.VolumeSnapshotClassList{}) + _, err := c.Fake.Invokes(action, &v1beta1.VolumeSnapshotClassList{}) return err } // Patch applies the patch and returns the patched volumeSnapshotClass. -func (c *FakeVolumeSnapshotClasses) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.VolumeSnapshotClass, err error) { +func (c *FakeVolumeSnapshotClasses) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.VolumeSnapshotClass, err error) { obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceAction(volumesnapshotclassesResource, name, pt, data, subresources...), &v1alpha1.VolumeSnapshotClass{}) + Invokes(testing.NewRootPatchSubresourceAction(volumesnapshotclassesResource, name, pt, data, subresources...), &v1beta1.VolumeSnapshotClass{}) if obj == nil { return nil, err } - return obj.(*v1alpha1.VolumeSnapshotClass), err + return obj.(*v1beta1.VolumeSnapshotClass), err } diff --git a/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/fake/fake_volumesnapshotcontent.go b/pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/fake/fake_volumesnapshotcontent.go similarity index 71% rename from pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/fake/fake_volumesnapshotcontent.go rename to pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/fake/fake_volumesnapshotcontent.go index f646d1d9d..3593a8448 100644 --- a/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/fake/fake_volumesnapshotcontent.go +++ b/pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/fake/fake_volumesnapshotcontent.go @@ -19,7 +19,7 @@ limitations under the License. package fake import ( - v1alpha1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + v1beta1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -30,27 +30,27 @@ import ( // FakeVolumeSnapshotContents implements VolumeSnapshotContentInterface type FakeVolumeSnapshotContents struct { - Fake *FakeSnapshotV1alpha1 + Fake *FakeSnapshotV1beta1 } -var volumesnapshotcontentsResource = schema.GroupVersionResource{Group: "snapshot.storage.k8s.io", Version: "v1alpha1", Resource: "volumesnapshotcontents"} +var volumesnapshotcontentsResource = schema.GroupVersionResource{Group: "snapshot.storage.k8s.io", Version: "v1beta1", Resource: "volumesnapshotcontents"} -var volumesnapshotcontentsKind = schema.GroupVersionKind{Group: "snapshot.storage.k8s.io", Version: "v1alpha1", Kind: "VolumeSnapshotContent"} +var volumesnapshotcontentsKind = schema.GroupVersionKind{Group: "snapshot.storage.k8s.io", Version: "v1beta1", Kind: "VolumeSnapshotContent"} // Get takes name of the volumeSnapshotContent, and returns the corresponding volumeSnapshotContent object, and an error if there is any. -func (c *FakeVolumeSnapshotContents) Get(name string, options v1.GetOptions) (result *v1alpha1.VolumeSnapshotContent, err error) { +func (c *FakeVolumeSnapshotContents) Get(name string, options v1.GetOptions) (result *v1beta1.VolumeSnapshotContent, err error) { obj, err := c.Fake. - Invokes(testing.NewRootGetAction(volumesnapshotcontentsResource, name), &v1alpha1.VolumeSnapshotContent{}) + Invokes(testing.NewRootGetAction(volumesnapshotcontentsResource, name), &v1beta1.VolumeSnapshotContent{}) if obj == nil { return nil, err } - return obj.(*v1alpha1.VolumeSnapshotContent), err + return obj.(*v1beta1.VolumeSnapshotContent), err } // List takes label and field selectors, and returns the list of VolumeSnapshotContents that match those selectors. -func (c *FakeVolumeSnapshotContents) List(opts v1.ListOptions) (result *v1alpha1.VolumeSnapshotContentList, err error) { +func (c *FakeVolumeSnapshotContents) List(opts v1.ListOptions) (result *v1beta1.VolumeSnapshotContentList, err error) { obj, err := c.Fake. - Invokes(testing.NewRootListAction(volumesnapshotcontentsResource, volumesnapshotcontentsKind, opts), &v1alpha1.VolumeSnapshotContentList{}) + Invokes(testing.NewRootListAction(volumesnapshotcontentsResource, volumesnapshotcontentsKind, opts), &v1beta1.VolumeSnapshotContentList{}) if obj == nil { return nil, err } @@ -59,8 +59,8 @@ func (c *FakeVolumeSnapshotContents) List(opts v1.ListOptions) (result *v1alpha1 if label == nil { label = labels.Everything() } - list := &v1alpha1.VolumeSnapshotContentList{ListMeta: obj.(*v1alpha1.VolumeSnapshotContentList).ListMeta} - for _, item := range obj.(*v1alpha1.VolumeSnapshotContentList).Items { + list := &v1beta1.VolumeSnapshotContentList{ListMeta: obj.(*v1beta1.VolumeSnapshotContentList).ListMeta} + for _, item := range obj.(*v1beta1.VolumeSnapshotContentList).Items { if label.Matches(labels.Set(item.Labels)) { list.Items = append(list.Items, item) } @@ -75,29 +75,29 @@ func (c *FakeVolumeSnapshotContents) Watch(opts v1.ListOptions) (watch.Interface } // Create takes the representation of a volumeSnapshotContent and creates it. Returns the server's representation of the volumeSnapshotContent, and an error, if there is any. -func (c *FakeVolumeSnapshotContents) Create(volumeSnapshotContent *v1alpha1.VolumeSnapshotContent) (result *v1alpha1.VolumeSnapshotContent, err error) { +func (c *FakeVolumeSnapshotContents) Create(volumeSnapshotContent *v1beta1.VolumeSnapshotContent) (result *v1beta1.VolumeSnapshotContent, err error) { obj, err := c.Fake. - Invokes(testing.NewRootCreateAction(volumesnapshotcontentsResource, volumeSnapshotContent), &v1alpha1.VolumeSnapshotContent{}) + Invokes(testing.NewRootCreateAction(volumesnapshotcontentsResource, volumeSnapshotContent), &v1beta1.VolumeSnapshotContent{}) if obj == nil { return nil, err } - return obj.(*v1alpha1.VolumeSnapshotContent), err + return obj.(*v1beta1.VolumeSnapshotContent), err } // Update takes the representation of a volumeSnapshotContent and updates it. Returns the server's representation of the volumeSnapshotContent, and an error, if there is any. -func (c *FakeVolumeSnapshotContents) Update(volumeSnapshotContent *v1alpha1.VolumeSnapshotContent) (result *v1alpha1.VolumeSnapshotContent, err error) { +func (c *FakeVolumeSnapshotContents) Update(volumeSnapshotContent *v1beta1.VolumeSnapshotContent) (result *v1beta1.VolumeSnapshotContent, err error) { obj, err := c.Fake. - Invokes(testing.NewRootUpdateAction(volumesnapshotcontentsResource, volumeSnapshotContent), &v1alpha1.VolumeSnapshotContent{}) + Invokes(testing.NewRootUpdateAction(volumesnapshotcontentsResource, volumeSnapshotContent), &v1beta1.VolumeSnapshotContent{}) if obj == nil { return nil, err } - return obj.(*v1alpha1.VolumeSnapshotContent), err + return obj.(*v1beta1.VolumeSnapshotContent), err } // Delete takes name of the volumeSnapshotContent and deletes it. Returns an error if one occurs. func (c *FakeVolumeSnapshotContents) Delete(name string, options *v1.DeleteOptions) error { _, err := c.Fake. - Invokes(testing.NewRootDeleteAction(volumesnapshotcontentsResource, name), &v1alpha1.VolumeSnapshotContent{}) + Invokes(testing.NewRootDeleteAction(volumesnapshotcontentsResource, name), &v1beta1.VolumeSnapshotContent{}) return err } @@ -105,16 +105,16 @@ func (c *FakeVolumeSnapshotContents) Delete(name string, options *v1.DeleteOptio func (c *FakeVolumeSnapshotContents) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { action := testing.NewRootDeleteCollectionAction(volumesnapshotcontentsResource, listOptions) - _, err := c.Fake.Invokes(action, &v1alpha1.VolumeSnapshotContentList{}) + _, err := c.Fake.Invokes(action, &v1beta1.VolumeSnapshotContentList{}) return err } // Patch applies the patch and returns the patched volumeSnapshotContent. -func (c *FakeVolumeSnapshotContents) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.VolumeSnapshotContent, err error) { +func (c *FakeVolumeSnapshotContents) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.VolumeSnapshotContent, err error) { obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceAction(volumesnapshotcontentsResource, name, pt, data, subresources...), &v1alpha1.VolumeSnapshotContent{}) + Invokes(testing.NewRootPatchSubresourceAction(volumesnapshotcontentsResource, name, pt, data, subresources...), &v1beta1.VolumeSnapshotContent{}) if obj == nil { return nil, err } - return obj.(*v1alpha1.VolumeSnapshotContent), err + return obj.(*v1beta1.VolumeSnapshotContent), err } diff --git a/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/generated_expansion.go b/pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/generated_expansion.go similarity index 97% rename from pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/generated_expansion.go rename to pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/generated_expansion.go index 9b641f106..3ed3d11f2 100644 --- a/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/generated_expansion.go +++ b/pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/generated_expansion.go @@ -16,7 +16,7 @@ limitations under the License. // Code generated by client-gen. DO NOT EDIT. -package v1alpha1 +package v1beta1 type VolumeSnapshotExpansion interface{} diff --git a/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/volumesnapshot.go b/pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/volumesnapshot.go similarity index 77% rename from pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/volumesnapshot.go rename to pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/volumesnapshot.go index a2f80805a..f9ef41512 100644 --- a/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/volumesnapshot.go +++ b/pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/volumesnapshot.go @@ -16,12 +16,12 @@ limitations under the License. // Code generated by client-gen. DO NOT EDIT. -package v1alpha1 +package v1beta1 import ( "time" - v1alpha1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + v1beta1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" scheme "github.com/kubernetes-csi/external-snapshotter/pkg/client/clientset/versioned/scheme" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" types "k8s.io/apimachinery/pkg/types" @@ -37,15 +37,15 @@ type VolumeSnapshotsGetter interface { // VolumeSnapshotInterface has methods to work with VolumeSnapshot resources. type VolumeSnapshotInterface interface { - Create(*v1alpha1.VolumeSnapshot) (*v1alpha1.VolumeSnapshot, error) - Update(*v1alpha1.VolumeSnapshot) (*v1alpha1.VolumeSnapshot, error) - UpdateStatus(*v1alpha1.VolumeSnapshot) (*v1alpha1.VolumeSnapshot, error) + Create(*v1beta1.VolumeSnapshot) (*v1beta1.VolumeSnapshot, error) + Update(*v1beta1.VolumeSnapshot) (*v1beta1.VolumeSnapshot, error) + UpdateStatus(*v1beta1.VolumeSnapshot) (*v1beta1.VolumeSnapshot, error) Delete(name string, options *v1.DeleteOptions) error DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error - Get(name string, options v1.GetOptions) (*v1alpha1.VolumeSnapshot, error) - List(opts v1.ListOptions) (*v1alpha1.VolumeSnapshotList, error) + Get(name string, options v1.GetOptions) (*v1beta1.VolumeSnapshot, error) + List(opts v1.ListOptions) (*v1beta1.VolumeSnapshotList, error) Watch(opts v1.ListOptions) (watch.Interface, error) - Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.VolumeSnapshot, err error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.VolumeSnapshot, err error) VolumeSnapshotExpansion } @@ -56,7 +56,7 @@ type volumeSnapshots struct { } // newVolumeSnapshots returns a VolumeSnapshots -func newVolumeSnapshots(c *SnapshotV1alpha1Client, namespace string) *volumeSnapshots { +func newVolumeSnapshots(c *SnapshotV1beta1Client, namespace string) *volumeSnapshots { return &volumeSnapshots{ client: c.RESTClient(), ns: namespace, @@ -64,8 +64,8 @@ func newVolumeSnapshots(c *SnapshotV1alpha1Client, namespace string) *volumeSnap } // Get takes name of the volumeSnapshot, and returns the corresponding volumeSnapshot object, and an error if there is any. -func (c *volumeSnapshots) Get(name string, options v1.GetOptions) (result *v1alpha1.VolumeSnapshot, err error) { - result = &v1alpha1.VolumeSnapshot{} +func (c *volumeSnapshots) Get(name string, options v1.GetOptions) (result *v1beta1.VolumeSnapshot, err error) { + result = &v1beta1.VolumeSnapshot{} err = c.client.Get(). Namespace(c.ns). Resource("volumesnapshots"). @@ -77,12 +77,12 @@ func (c *volumeSnapshots) Get(name string, options v1.GetOptions) (result *v1alp } // List takes label and field selectors, and returns the list of VolumeSnapshots that match those selectors. -func (c *volumeSnapshots) List(opts v1.ListOptions) (result *v1alpha1.VolumeSnapshotList, err error) { +func (c *volumeSnapshots) List(opts v1.ListOptions) (result *v1beta1.VolumeSnapshotList, err error) { var timeout time.Duration if opts.TimeoutSeconds != nil { timeout = time.Duration(*opts.TimeoutSeconds) * time.Second } - result = &v1alpha1.VolumeSnapshotList{} + result = &v1beta1.VolumeSnapshotList{} err = c.client.Get(). Namespace(c.ns). Resource("volumesnapshots"). @@ -109,8 +109,8 @@ func (c *volumeSnapshots) Watch(opts v1.ListOptions) (watch.Interface, error) { } // Create takes the representation of a volumeSnapshot and creates it. Returns the server's representation of the volumeSnapshot, and an error, if there is any. -func (c *volumeSnapshots) Create(volumeSnapshot *v1alpha1.VolumeSnapshot) (result *v1alpha1.VolumeSnapshot, err error) { - result = &v1alpha1.VolumeSnapshot{} +func (c *volumeSnapshots) Create(volumeSnapshot *v1beta1.VolumeSnapshot) (result *v1beta1.VolumeSnapshot, err error) { + result = &v1beta1.VolumeSnapshot{} err = c.client.Post(). Namespace(c.ns). Resource("volumesnapshots"). @@ -121,8 +121,8 @@ func (c *volumeSnapshots) Create(volumeSnapshot *v1alpha1.VolumeSnapshot) (resul } // Update takes the representation of a volumeSnapshot and updates it. Returns the server's representation of the volumeSnapshot, and an error, if there is any. -func (c *volumeSnapshots) Update(volumeSnapshot *v1alpha1.VolumeSnapshot) (result *v1alpha1.VolumeSnapshot, err error) { - result = &v1alpha1.VolumeSnapshot{} +func (c *volumeSnapshots) Update(volumeSnapshot *v1beta1.VolumeSnapshot) (result *v1beta1.VolumeSnapshot, err error) { + result = &v1beta1.VolumeSnapshot{} err = c.client.Put(). Namespace(c.ns). Resource("volumesnapshots"). @@ -136,8 +136,8 @@ func (c *volumeSnapshots) Update(volumeSnapshot *v1alpha1.VolumeSnapshot) (resul // UpdateStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *volumeSnapshots) UpdateStatus(volumeSnapshot *v1alpha1.VolumeSnapshot) (result *v1alpha1.VolumeSnapshot, err error) { - result = &v1alpha1.VolumeSnapshot{} +func (c *volumeSnapshots) UpdateStatus(volumeSnapshot *v1beta1.VolumeSnapshot) (result *v1beta1.VolumeSnapshot, err error) { + result = &v1beta1.VolumeSnapshot{} err = c.client.Put(). Namespace(c.ns). Resource("volumesnapshots"). @@ -177,8 +177,8 @@ func (c *volumeSnapshots) DeleteCollection(options *v1.DeleteOptions, listOption } // Patch applies the patch and returns the patched volumeSnapshot. -func (c *volumeSnapshots) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.VolumeSnapshot, err error) { - result = &v1alpha1.VolumeSnapshot{} +func (c *volumeSnapshots) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.VolumeSnapshot, err error) { + result = &v1beta1.VolumeSnapshot{} err = c.client.Patch(pt). Namespace(c.ns). Resource("volumesnapshots"). diff --git a/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/volumesnapshot_client.go b/pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/volumesnapshot_client.go similarity index 61% rename from pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/volumesnapshot_client.go rename to pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/volumesnapshot_client.go index ba06f6576..574860496 100644 --- a/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/volumesnapshot_client.go +++ b/pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/volumesnapshot_client.go @@ -16,41 +16,41 @@ limitations under the License. // Code generated by client-gen. DO NOT EDIT. -package v1alpha1 +package v1beta1 import ( - v1alpha1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + v1beta1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" "github.com/kubernetes-csi/external-snapshotter/pkg/client/clientset/versioned/scheme" serializer "k8s.io/apimachinery/pkg/runtime/serializer" rest "k8s.io/client-go/rest" ) -type SnapshotV1alpha1Interface interface { +type SnapshotV1beta1Interface interface { RESTClient() rest.Interface VolumeSnapshotsGetter VolumeSnapshotClassesGetter VolumeSnapshotContentsGetter } -// SnapshotV1alpha1Client is used to interact with features provided by the snapshot.storage.k8s.io group. -type SnapshotV1alpha1Client struct { +// SnapshotV1beta1Client is used to interact with features provided by the snapshot.storage.k8s.io group. +type SnapshotV1beta1Client struct { restClient rest.Interface } -func (c *SnapshotV1alpha1Client) VolumeSnapshots(namespace string) VolumeSnapshotInterface { +func (c *SnapshotV1beta1Client) VolumeSnapshots(namespace string) VolumeSnapshotInterface { return newVolumeSnapshots(c, namespace) } -func (c *SnapshotV1alpha1Client) VolumeSnapshotClasses() VolumeSnapshotClassInterface { +func (c *SnapshotV1beta1Client) VolumeSnapshotClasses() VolumeSnapshotClassInterface { return newVolumeSnapshotClasses(c) } -func (c *SnapshotV1alpha1Client) VolumeSnapshotContents() VolumeSnapshotContentInterface { +func (c *SnapshotV1beta1Client) VolumeSnapshotContents() VolumeSnapshotContentInterface { return newVolumeSnapshotContents(c) } -// NewForConfig creates a new SnapshotV1alpha1Client for the given config. -func NewForConfig(c *rest.Config) (*SnapshotV1alpha1Client, error) { +// NewForConfig creates a new SnapshotV1beta1Client for the given config. +func NewForConfig(c *rest.Config) (*SnapshotV1beta1Client, error) { config := *c if err := setConfigDefaults(&config); err != nil { return nil, err @@ -59,12 +59,12 @@ func NewForConfig(c *rest.Config) (*SnapshotV1alpha1Client, error) { if err != nil { return nil, err } - return &SnapshotV1alpha1Client{client}, nil + return &SnapshotV1beta1Client{client}, nil } -// NewForConfigOrDie creates a new SnapshotV1alpha1Client for the given config and +// NewForConfigOrDie creates a new SnapshotV1beta1Client for the given config and // panics if there is an error in the config. -func NewForConfigOrDie(c *rest.Config) *SnapshotV1alpha1Client { +func NewForConfigOrDie(c *rest.Config) *SnapshotV1beta1Client { client, err := NewForConfig(c) if err != nil { panic(err) @@ -72,13 +72,13 @@ func NewForConfigOrDie(c *rest.Config) *SnapshotV1alpha1Client { return client } -// New creates a new SnapshotV1alpha1Client for the given RESTClient. -func New(c rest.Interface) *SnapshotV1alpha1Client { - return &SnapshotV1alpha1Client{c} +// New creates a new SnapshotV1beta1Client for the given RESTClient. +func New(c rest.Interface) *SnapshotV1beta1Client { + return &SnapshotV1beta1Client{c} } func setConfigDefaults(config *rest.Config) error { - gv := v1alpha1.SchemeGroupVersion + gv := v1beta1.SchemeGroupVersion config.GroupVersion = &gv config.APIPath = "/apis" config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: scheme.Codecs} @@ -92,7 +92,7 @@ func setConfigDefaults(config *rest.Config) error { // RESTClient returns a RESTClient that is used to communicate // with API server by this client implementation. -func (c *SnapshotV1alpha1Client) RESTClient() rest.Interface { +func (c *SnapshotV1beta1Client) RESTClient() rest.Interface { if c == nil { return nil } diff --git a/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/volumesnapshotclass.go b/pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/volumesnapshotclass.go similarity index 79% rename from pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/volumesnapshotclass.go rename to pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/volumesnapshotclass.go index 8b788df4a..4a8e1d324 100644 --- a/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/volumesnapshotclass.go +++ b/pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/volumesnapshotclass.go @@ -16,12 +16,12 @@ limitations under the License. // Code generated by client-gen. DO NOT EDIT. -package v1alpha1 +package v1beta1 import ( "time" - v1alpha1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + v1beta1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" scheme "github.com/kubernetes-csi/external-snapshotter/pkg/client/clientset/versioned/scheme" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" types "k8s.io/apimachinery/pkg/types" @@ -37,14 +37,14 @@ type VolumeSnapshotClassesGetter interface { // VolumeSnapshotClassInterface has methods to work with VolumeSnapshotClass resources. type VolumeSnapshotClassInterface interface { - Create(*v1alpha1.VolumeSnapshotClass) (*v1alpha1.VolumeSnapshotClass, error) - Update(*v1alpha1.VolumeSnapshotClass) (*v1alpha1.VolumeSnapshotClass, error) + Create(*v1beta1.VolumeSnapshotClass) (*v1beta1.VolumeSnapshotClass, error) + Update(*v1beta1.VolumeSnapshotClass) (*v1beta1.VolumeSnapshotClass, error) Delete(name string, options *v1.DeleteOptions) error DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error - Get(name string, options v1.GetOptions) (*v1alpha1.VolumeSnapshotClass, error) - List(opts v1.ListOptions) (*v1alpha1.VolumeSnapshotClassList, error) + Get(name string, options v1.GetOptions) (*v1beta1.VolumeSnapshotClass, error) + List(opts v1.ListOptions) (*v1beta1.VolumeSnapshotClassList, error) Watch(opts v1.ListOptions) (watch.Interface, error) - Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.VolumeSnapshotClass, err error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.VolumeSnapshotClass, err error) VolumeSnapshotClassExpansion } @@ -54,15 +54,15 @@ type volumeSnapshotClasses struct { } // newVolumeSnapshotClasses returns a VolumeSnapshotClasses -func newVolumeSnapshotClasses(c *SnapshotV1alpha1Client) *volumeSnapshotClasses { +func newVolumeSnapshotClasses(c *SnapshotV1beta1Client) *volumeSnapshotClasses { return &volumeSnapshotClasses{ client: c.RESTClient(), } } // Get takes name of the volumeSnapshotClass, and returns the corresponding volumeSnapshotClass object, and an error if there is any. -func (c *volumeSnapshotClasses) Get(name string, options v1.GetOptions) (result *v1alpha1.VolumeSnapshotClass, err error) { - result = &v1alpha1.VolumeSnapshotClass{} +func (c *volumeSnapshotClasses) Get(name string, options v1.GetOptions) (result *v1beta1.VolumeSnapshotClass, err error) { + result = &v1beta1.VolumeSnapshotClass{} err = c.client.Get(). Resource("volumesnapshotclasses"). Name(name). @@ -73,12 +73,12 @@ func (c *volumeSnapshotClasses) Get(name string, options v1.GetOptions) (result } // List takes label and field selectors, and returns the list of VolumeSnapshotClasses that match those selectors. -func (c *volumeSnapshotClasses) List(opts v1.ListOptions) (result *v1alpha1.VolumeSnapshotClassList, err error) { +func (c *volumeSnapshotClasses) List(opts v1.ListOptions) (result *v1beta1.VolumeSnapshotClassList, err error) { var timeout time.Duration if opts.TimeoutSeconds != nil { timeout = time.Duration(*opts.TimeoutSeconds) * time.Second } - result = &v1alpha1.VolumeSnapshotClassList{} + result = &v1beta1.VolumeSnapshotClassList{} err = c.client.Get(). Resource("volumesnapshotclasses"). VersionedParams(&opts, scheme.ParameterCodec). @@ -103,8 +103,8 @@ func (c *volumeSnapshotClasses) Watch(opts v1.ListOptions) (watch.Interface, err } // Create takes the representation of a volumeSnapshotClass and creates it. Returns the server's representation of the volumeSnapshotClass, and an error, if there is any. -func (c *volumeSnapshotClasses) Create(volumeSnapshotClass *v1alpha1.VolumeSnapshotClass) (result *v1alpha1.VolumeSnapshotClass, err error) { - result = &v1alpha1.VolumeSnapshotClass{} +func (c *volumeSnapshotClasses) Create(volumeSnapshotClass *v1beta1.VolumeSnapshotClass) (result *v1beta1.VolumeSnapshotClass, err error) { + result = &v1beta1.VolumeSnapshotClass{} err = c.client.Post(). Resource("volumesnapshotclasses"). Body(volumeSnapshotClass). @@ -114,8 +114,8 @@ func (c *volumeSnapshotClasses) Create(volumeSnapshotClass *v1alpha1.VolumeSnaps } // Update takes the representation of a volumeSnapshotClass and updates it. Returns the server's representation of the volumeSnapshotClass, and an error, if there is any. -func (c *volumeSnapshotClasses) Update(volumeSnapshotClass *v1alpha1.VolumeSnapshotClass) (result *v1alpha1.VolumeSnapshotClass, err error) { - result = &v1alpha1.VolumeSnapshotClass{} +func (c *volumeSnapshotClasses) Update(volumeSnapshotClass *v1beta1.VolumeSnapshotClass) (result *v1beta1.VolumeSnapshotClass, err error) { + result = &v1beta1.VolumeSnapshotClass{} err = c.client.Put(). Resource("volumesnapshotclasses"). Name(volumeSnapshotClass.Name). @@ -151,8 +151,8 @@ func (c *volumeSnapshotClasses) DeleteCollection(options *v1.DeleteOptions, list } // Patch applies the patch and returns the patched volumeSnapshotClass. -func (c *volumeSnapshotClasses) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.VolumeSnapshotClass, err error) { - result = &v1alpha1.VolumeSnapshotClass{} +func (c *volumeSnapshotClasses) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.VolumeSnapshotClass, err error) { + result = &v1beta1.VolumeSnapshotClass{} err = c.client.Patch(pt). Resource("volumesnapshotclasses"). SubResource(subresources...). diff --git a/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/volumesnapshotcontent.go b/pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/volumesnapshotcontent.go similarity index 80% rename from pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/volumesnapshotcontent.go rename to pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/volumesnapshotcontent.go index e393ccdfe..5f5e3d7a6 100644 --- a/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/volumesnapshotcontent.go +++ b/pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/volumesnapshotcontent.go @@ -16,12 +16,12 @@ limitations under the License. // Code generated by client-gen. DO NOT EDIT. -package v1alpha1 +package v1beta1 import ( "time" - v1alpha1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + v1beta1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" scheme "github.com/kubernetes-csi/external-snapshotter/pkg/client/clientset/versioned/scheme" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" types "k8s.io/apimachinery/pkg/types" @@ -37,14 +37,14 @@ type VolumeSnapshotContentsGetter interface { // VolumeSnapshotContentInterface has methods to work with VolumeSnapshotContent resources. type VolumeSnapshotContentInterface interface { - Create(*v1alpha1.VolumeSnapshotContent) (*v1alpha1.VolumeSnapshotContent, error) - Update(*v1alpha1.VolumeSnapshotContent) (*v1alpha1.VolumeSnapshotContent, error) + Create(*v1beta1.VolumeSnapshotContent) (*v1beta1.VolumeSnapshotContent, error) + Update(*v1beta1.VolumeSnapshotContent) (*v1beta1.VolumeSnapshotContent, error) Delete(name string, options *v1.DeleteOptions) error DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error - Get(name string, options v1.GetOptions) (*v1alpha1.VolumeSnapshotContent, error) - List(opts v1.ListOptions) (*v1alpha1.VolumeSnapshotContentList, error) + Get(name string, options v1.GetOptions) (*v1beta1.VolumeSnapshotContent, error) + List(opts v1.ListOptions) (*v1beta1.VolumeSnapshotContentList, error) Watch(opts v1.ListOptions) (watch.Interface, error) - Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.VolumeSnapshotContent, err error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.VolumeSnapshotContent, err error) VolumeSnapshotContentExpansion } @@ -54,15 +54,15 @@ type volumeSnapshotContents struct { } // newVolumeSnapshotContents returns a VolumeSnapshotContents -func newVolumeSnapshotContents(c *SnapshotV1alpha1Client) *volumeSnapshotContents { +func newVolumeSnapshotContents(c *SnapshotV1beta1Client) *volumeSnapshotContents { return &volumeSnapshotContents{ client: c.RESTClient(), } } // Get takes name of the volumeSnapshotContent, and returns the corresponding volumeSnapshotContent object, and an error if there is any. -func (c *volumeSnapshotContents) Get(name string, options v1.GetOptions) (result *v1alpha1.VolumeSnapshotContent, err error) { - result = &v1alpha1.VolumeSnapshotContent{} +func (c *volumeSnapshotContents) Get(name string, options v1.GetOptions) (result *v1beta1.VolumeSnapshotContent, err error) { + result = &v1beta1.VolumeSnapshotContent{} err = c.client.Get(). Resource("volumesnapshotcontents"). Name(name). @@ -73,12 +73,12 @@ func (c *volumeSnapshotContents) Get(name string, options v1.GetOptions) (result } // List takes label and field selectors, and returns the list of VolumeSnapshotContents that match those selectors. -func (c *volumeSnapshotContents) List(opts v1.ListOptions) (result *v1alpha1.VolumeSnapshotContentList, err error) { +func (c *volumeSnapshotContents) List(opts v1.ListOptions) (result *v1beta1.VolumeSnapshotContentList, err error) { var timeout time.Duration if opts.TimeoutSeconds != nil { timeout = time.Duration(*opts.TimeoutSeconds) * time.Second } - result = &v1alpha1.VolumeSnapshotContentList{} + result = &v1beta1.VolumeSnapshotContentList{} err = c.client.Get(). Resource("volumesnapshotcontents"). VersionedParams(&opts, scheme.ParameterCodec). @@ -103,8 +103,8 @@ func (c *volumeSnapshotContents) Watch(opts v1.ListOptions) (watch.Interface, er } // Create takes the representation of a volumeSnapshotContent and creates it. Returns the server's representation of the volumeSnapshotContent, and an error, if there is any. -func (c *volumeSnapshotContents) Create(volumeSnapshotContent *v1alpha1.VolumeSnapshotContent) (result *v1alpha1.VolumeSnapshotContent, err error) { - result = &v1alpha1.VolumeSnapshotContent{} +func (c *volumeSnapshotContents) Create(volumeSnapshotContent *v1beta1.VolumeSnapshotContent) (result *v1beta1.VolumeSnapshotContent, err error) { + result = &v1beta1.VolumeSnapshotContent{} err = c.client.Post(). Resource("volumesnapshotcontents"). Body(volumeSnapshotContent). @@ -114,8 +114,8 @@ func (c *volumeSnapshotContents) Create(volumeSnapshotContent *v1alpha1.VolumeSn } // Update takes the representation of a volumeSnapshotContent and updates it. Returns the server's representation of the volumeSnapshotContent, and an error, if there is any. -func (c *volumeSnapshotContents) Update(volumeSnapshotContent *v1alpha1.VolumeSnapshotContent) (result *v1alpha1.VolumeSnapshotContent, err error) { - result = &v1alpha1.VolumeSnapshotContent{} +func (c *volumeSnapshotContents) Update(volumeSnapshotContent *v1beta1.VolumeSnapshotContent) (result *v1beta1.VolumeSnapshotContent, err error) { + result = &v1beta1.VolumeSnapshotContent{} err = c.client.Put(). Resource("volumesnapshotcontents"). Name(volumeSnapshotContent.Name). @@ -151,8 +151,8 @@ func (c *volumeSnapshotContents) DeleteCollection(options *v1.DeleteOptions, lis } // Patch applies the patch and returns the patched volumeSnapshotContent. -func (c *volumeSnapshotContents) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.VolumeSnapshotContent, err error) { - result = &v1alpha1.VolumeSnapshotContent{} +func (c *volumeSnapshotContents) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.VolumeSnapshotContent, err error) { + result = &v1beta1.VolumeSnapshotContent{} err = c.client.Patch(pt). Resource("volumesnapshotcontents"). SubResource(subresources...). diff --git a/pkg/client/informers/externalversions/generic.go b/pkg/client/informers/externalversions/generic.go index 193942d0e..abf7d5fa8 100644 --- a/pkg/client/informers/externalversions/generic.go +++ b/pkg/client/informers/externalversions/generic.go @@ -21,7 +21,7 @@ package externalversions import ( "fmt" - v1alpha1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + v1beta1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" schema "k8s.io/apimachinery/pkg/runtime/schema" cache "k8s.io/client-go/tools/cache" ) @@ -52,13 +52,13 @@ func (f *genericInformer) Lister() cache.GenericLister { // TODO extend this to unknown resources with a client pool func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { switch resource { - // Group=snapshot.storage.k8s.io, Version=v1alpha1 - case v1alpha1.SchemeGroupVersion.WithResource("volumesnapshots"): - return &genericInformer{resource: resource.GroupResource(), informer: f.Snapshot().V1alpha1().VolumeSnapshots().Informer()}, nil - case v1alpha1.SchemeGroupVersion.WithResource("volumesnapshotclasses"): - return &genericInformer{resource: resource.GroupResource(), informer: f.Snapshot().V1alpha1().VolumeSnapshotClasses().Informer()}, nil - case v1alpha1.SchemeGroupVersion.WithResource("volumesnapshotcontents"): - return &genericInformer{resource: resource.GroupResource(), informer: f.Snapshot().V1alpha1().VolumeSnapshotContents().Informer()}, nil + // Group=snapshot.storage.k8s.io, Version=v1beta1 + case v1beta1.SchemeGroupVersion.WithResource("volumesnapshots"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Snapshot().V1beta1().VolumeSnapshots().Informer()}, nil + case v1beta1.SchemeGroupVersion.WithResource("volumesnapshotclasses"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Snapshot().V1beta1().VolumeSnapshotClasses().Informer()}, nil + case v1beta1.SchemeGroupVersion.WithResource("volumesnapshotcontents"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Snapshot().V1beta1().VolumeSnapshotContents().Informer()}, nil } diff --git a/pkg/client/informers/externalversions/volumesnapshot/interface.go b/pkg/client/informers/externalversions/volumesnapshot/interface.go index ba406ea94..874ea3dc1 100644 --- a/pkg/client/informers/externalversions/volumesnapshot/interface.go +++ b/pkg/client/informers/externalversions/volumesnapshot/interface.go @@ -20,13 +20,13 @@ package snapshot import ( internalinterfaces "github.com/kubernetes-csi/external-snapshotter/pkg/client/informers/externalversions/internalinterfaces" - v1alpha1 "github.com/kubernetes-csi/external-snapshotter/pkg/client/informers/externalversions/volumesnapshot/v1alpha1" + v1beta1 "github.com/kubernetes-csi/external-snapshotter/pkg/client/informers/externalversions/volumesnapshot/v1beta1" ) // Interface provides access to each of this group's versions. type Interface interface { - // V1alpha1 provides access to shared informers for resources in V1alpha1. - V1alpha1() v1alpha1.Interface + // V1beta1 provides access to shared informers for resources in V1beta1. + V1beta1() v1beta1.Interface } type group struct { @@ -40,7 +40,7 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} } -// V1alpha1 returns a new v1alpha1.Interface. -func (g *group) V1alpha1() v1alpha1.Interface { - return v1alpha1.New(g.factory, g.namespace, g.tweakListOptions) +// V1beta1 returns a new v1beta1.Interface. +func (g *group) V1beta1() v1beta1.Interface { + return v1beta1.New(g.factory, g.namespace, g.tweakListOptions) } diff --git a/pkg/client/informers/externalversions/volumesnapshot/v1alpha1/interface.go b/pkg/client/informers/externalversions/volumesnapshot/v1beta1/interface.go similarity index 99% rename from pkg/client/informers/externalversions/volumesnapshot/v1alpha1/interface.go rename to pkg/client/informers/externalversions/volumesnapshot/v1beta1/interface.go index ded10e911..ecccf563e 100644 --- a/pkg/client/informers/externalversions/volumesnapshot/v1alpha1/interface.go +++ b/pkg/client/informers/externalversions/volumesnapshot/v1beta1/interface.go @@ -16,7 +16,7 @@ limitations under the License. // Code generated by informer-gen. DO NOT EDIT. -package v1alpha1 +package v1beta1 import ( internalinterfaces "github.com/kubernetes-csi/external-snapshotter/pkg/client/informers/externalversions/internalinterfaces" diff --git a/pkg/client/informers/externalversions/volumesnapshot/v1alpha1/volumesnapshot.go b/pkg/client/informers/externalversions/volumesnapshot/v1beta1/volumesnapshot.go similarity index 81% rename from pkg/client/informers/externalversions/volumesnapshot/v1alpha1/volumesnapshot.go rename to pkg/client/informers/externalversions/volumesnapshot/v1beta1/volumesnapshot.go index babb79b87..211b6f5f1 100644 --- a/pkg/client/informers/externalversions/volumesnapshot/v1alpha1/volumesnapshot.go +++ b/pkg/client/informers/externalversions/volumesnapshot/v1beta1/volumesnapshot.go @@ -16,15 +16,15 @@ limitations under the License. // Code generated by informer-gen. DO NOT EDIT. -package v1alpha1 +package v1beta1 import ( time "time" - volumesnapshotv1alpha1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + volumesnapshotv1beta1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" versioned "github.com/kubernetes-csi/external-snapshotter/pkg/client/clientset/versioned" internalinterfaces "github.com/kubernetes-csi/external-snapshotter/pkg/client/informers/externalversions/internalinterfaces" - v1alpha1 "github.com/kubernetes-csi/external-snapshotter/pkg/client/listers/volumesnapshot/v1alpha1" + v1beta1 "github.com/kubernetes-csi/external-snapshotter/pkg/client/listers/volumesnapshot/v1beta1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" watch "k8s.io/apimachinery/pkg/watch" @@ -35,7 +35,7 @@ import ( // VolumeSnapshots. type VolumeSnapshotInformer interface { Informer() cache.SharedIndexInformer - Lister() v1alpha1.VolumeSnapshotLister + Lister() v1beta1.VolumeSnapshotLister } type volumeSnapshotInformer struct { @@ -61,16 +61,16 @@ func NewFilteredVolumeSnapshotInformer(client versioned.Interface, namespace str if tweakListOptions != nil { tweakListOptions(&options) } - return client.SnapshotV1alpha1().VolumeSnapshots(namespace).List(options) + return client.SnapshotV1beta1().VolumeSnapshots(namespace).List(options) }, WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.SnapshotV1alpha1().VolumeSnapshots(namespace).Watch(options) + return client.SnapshotV1beta1().VolumeSnapshots(namespace).Watch(options) }, }, - &volumesnapshotv1alpha1.VolumeSnapshot{}, + &volumesnapshotv1beta1.VolumeSnapshot{}, resyncPeriod, indexers, ) @@ -81,9 +81,9 @@ func (f *volumeSnapshotInformer) defaultInformer(client versioned.Interface, res } func (f *volumeSnapshotInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&volumesnapshotv1alpha1.VolumeSnapshot{}, f.defaultInformer) + return f.factory.InformerFor(&volumesnapshotv1beta1.VolumeSnapshot{}, f.defaultInformer) } -func (f *volumeSnapshotInformer) Lister() v1alpha1.VolumeSnapshotLister { - return v1alpha1.NewVolumeSnapshotLister(f.Informer().GetIndexer()) +func (f *volumeSnapshotInformer) Lister() v1beta1.VolumeSnapshotLister { + return v1beta1.NewVolumeSnapshotLister(f.Informer().GetIndexer()) } diff --git a/pkg/client/informers/externalversions/volumesnapshot/v1alpha1/volumesnapshotclass.go b/pkg/client/informers/externalversions/volumesnapshot/v1beta1/volumesnapshotclass.go similarity index 81% rename from pkg/client/informers/externalversions/volumesnapshot/v1alpha1/volumesnapshotclass.go rename to pkg/client/informers/externalversions/volumesnapshot/v1beta1/volumesnapshotclass.go index 0026e5572..800e12428 100644 --- a/pkg/client/informers/externalversions/volumesnapshot/v1alpha1/volumesnapshotclass.go +++ b/pkg/client/informers/externalversions/volumesnapshot/v1beta1/volumesnapshotclass.go @@ -16,15 +16,15 @@ limitations under the License. // Code generated by informer-gen. DO NOT EDIT. -package v1alpha1 +package v1beta1 import ( time "time" - volumesnapshotv1alpha1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + volumesnapshotv1beta1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" versioned "github.com/kubernetes-csi/external-snapshotter/pkg/client/clientset/versioned" internalinterfaces "github.com/kubernetes-csi/external-snapshotter/pkg/client/informers/externalversions/internalinterfaces" - v1alpha1 "github.com/kubernetes-csi/external-snapshotter/pkg/client/listers/volumesnapshot/v1alpha1" + v1beta1 "github.com/kubernetes-csi/external-snapshotter/pkg/client/listers/volumesnapshot/v1beta1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" watch "k8s.io/apimachinery/pkg/watch" @@ -35,7 +35,7 @@ import ( // VolumeSnapshotClasses. type VolumeSnapshotClassInformer interface { Informer() cache.SharedIndexInformer - Lister() v1alpha1.VolumeSnapshotClassLister + Lister() v1beta1.VolumeSnapshotClassLister } type volumeSnapshotClassInformer struct { @@ -60,16 +60,16 @@ func NewFilteredVolumeSnapshotClassInformer(client versioned.Interface, resyncPe if tweakListOptions != nil { tweakListOptions(&options) } - return client.SnapshotV1alpha1().VolumeSnapshotClasses().List(options) + return client.SnapshotV1beta1().VolumeSnapshotClasses().List(options) }, WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.SnapshotV1alpha1().VolumeSnapshotClasses().Watch(options) + return client.SnapshotV1beta1().VolumeSnapshotClasses().Watch(options) }, }, - &volumesnapshotv1alpha1.VolumeSnapshotClass{}, + &volumesnapshotv1beta1.VolumeSnapshotClass{}, resyncPeriod, indexers, ) @@ -80,9 +80,9 @@ func (f *volumeSnapshotClassInformer) defaultInformer(client versioned.Interface } func (f *volumeSnapshotClassInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&volumesnapshotv1alpha1.VolumeSnapshotClass{}, f.defaultInformer) + return f.factory.InformerFor(&volumesnapshotv1beta1.VolumeSnapshotClass{}, f.defaultInformer) } -func (f *volumeSnapshotClassInformer) Lister() v1alpha1.VolumeSnapshotClassLister { - return v1alpha1.NewVolumeSnapshotClassLister(f.Informer().GetIndexer()) +func (f *volumeSnapshotClassInformer) Lister() v1beta1.VolumeSnapshotClassLister { + return v1beta1.NewVolumeSnapshotClassLister(f.Informer().GetIndexer()) } diff --git a/pkg/client/informers/externalversions/volumesnapshot/v1alpha1/volumesnapshotcontent.go b/pkg/client/informers/externalversions/volumesnapshot/v1beta1/volumesnapshotcontent.go similarity index 81% rename from pkg/client/informers/externalversions/volumesnapshot/v1alpha1/volumesnapshotcontent.go rename to pkg/client/informers/externalversions/volumesnapshot/v1beta1/volumesnapshotcontent.go index 2b34344d5..835292145 100644 --- a/pkg/client/informers/externalversions/volumesnapshot/v1alpha1/volumesnapshotcontent.go +++ b/pkg/client/informers/externalversions/volumesnapshot/v1beta1/volumesnapshotcontent.go @@ -16,15 +16,15 @@ limitations under the License. // Code generated by informer-gen. DO NOT EDIT. -package v1alpha1 +package v1beta1 import ( time "time" - volumesnapshotv1alpha1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + volumesnapshotv1beta1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" versioned "github.com/kubernetes-csi/external-snapshotter/pkg/client/clientset/versioned" internalinterfaces "github.com/kubernetes-csi/external-snapshotter/pkg/client/informers/externalversions/internalinterfaces" - v1alpha1 "github.com/kubernetes-csi/external-snapshotter/pkg/client/listers/volumesnapshot/v1alpha1" + v1beta1 "github.com/kubernetes-csi/external-snapshotter/pkg/client/listers/volumesnapshot/v1beta1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" watch "k8s.io/apimachinery/pkg/watch" @@ -35,7 +35,7 @@ import ( // VolumeSnapshotContents. type VolumeSnapshotContentInformer interface { Informer() cache.SharedIndexInformer - Lister() v1alpha1.VolumeSnapshotContentLister + Lister() v1beta1.VolumeSnapshotContentLister } type volumeSnapshotContentInformer struct { @@ -60,16 +60,16 @@ func NewFilteredVolumeSnapshotContentInformer(client versioned.Interface, resync if tweakListOptions != nil { tweakListOptions(&options) } - return client.SnapshotV1alpha1().VolumeSnapshotContents().List(options) + return client.SnapshotV1beta1().VolumeSnapshotContents().List(options) }, WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.SnapshotV1alpha1().VolumeSnapshotContents().Watch(options) + return client.SnapshotV1beta1().VolumeSnapshotContents().Watch(options) }, }, - &volumesnapshotv1alpha1.VolumeSnapshotContent{}, + &volumesnapshotv1beta1.VolumeSnapshotContent{}, resyncPeriod, indexers, ) @@ -80,9 +80,9 @@ func (f *volumeSnapshotContentInformer) defaultInformer(client versioned.Interfa } func (f *volumeSnapshotContentInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&volumesnapshotv1alpha1.VolumeSnapshotContent{}, f.defaultInformer) + return f.factory.InformerFor(&volumesnapshotv1beta1.VolumeSnapshotContent{}, f.defaultInformer) } -func (f *volumeSnapshotContentInformer) Lister() v1alpha1.VolumeSnapshotContentLister { - return v1alpha1.NewVolumeSnapshotContentLister(f.Informer().GetIndexer()) +func (f *volumeSnapshotContentInformer) Lister() v1beta1.VolumeSnapshotContentLister { + return v1beta1.NewVolumeSnapshotContentLister(f.Informer().GetIndexer()) } diff --git a/pkg/client/listers/volumesnapshot/v1alpha1/expansion_generated.go b/pkg/client/listers/volumesnapshot/v1beta1/expansion_generated.go similarity index 98% rename from pkg/client/listers/volumesnapshot/v1alpha1/expansion_generated.go rename to pkg/client/listers/volumesnapshot/v1beta1/expansion_generated.go index f92624ed7..100865bcb 100644 --- a/pkg/client/listers/volumesnapshot/v1alpha1/expansion_generated.go +++ b/pkg/client/listers/volumesnapshot/v1beta1/expansion_generated.go @@ -16,7 +16,7 @@ limitations under the License. // Code generated by lister-gen. DO NOT EDIT. -package v1alpha1 +package v1beta1 // VolumeSnapshotListerExpansion allows custom methods to be added to // VolumeSnapshotLister. diff --git a/pkg/client/listers/volumesnapshot/v1alpha1/volumesnapshot.go b/pkg/client/listers/volumesnapshot/v1beta1/volumesnapshot.go similarity index 79% rename from pkg/client/listers/volumesnapshot/v1alpha1/volumesnapshot.go rename to pkg/client/listers/volumesnapshot/v1beta1/volumesnapshot.go index ffa8f16d8..4309a30e6 100644 --- a/pkg/client/listers/volumesnapshot/v1alpha1/volumesnapshot.go +++ b/pkg/client/listers/volumesnapshot/v1beta1/volumesnapshot.go @@ -16,10 +16,10 @@ limitations under the License. // Code generated by lister-gen. DO NOT EDIT. -package v1alpha1 +package v1beta1 import ( - v1alpha1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + v1beta1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" "k8s.io/client-go/tools/cache" @@ -28,7 +28,7 @@ import ( // VolumeSnapshotLister helps list VolumeSnapshots. type VolumeSnapshotLister interface { // List lists all VolumeSnapshots in the indexer. - List(selector labels.Selector) (ret []*v1alpha1.VolumeSnapshot, err error) + List(selector labels.Selector) (ret []*v1beta1.VolumeSnapshot, err error) // VolumeSnapshots returns an object that can list and get VolumeSnapshots. VolumeSnapshots(namespace string) VolumeSnapshotNamespaceLister VolumeSnapshotListerExpansion @@ -45,9 +45,9 @@ func NewVolumeSnapshotLister(indexer cache.Indexer) VolumeSnapshotLister { } // List lists all VolumeSnapshots in the indexer. -func (s *volumeSnapshotLister) List(selector labels.Selector) (ret []*v1alpha1.VolumeSnapshot, err error) { +func (s *volumeSnapshotLister) List(selector labels.Selector) (ret []*v1beta1.VolumeSnapshot, err error) { err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.VolumeSnapshot)) + ret = append(ret, m.(*v1beta1.VolumeSnapshot)) }) return ret, err } @@ -60,9 +60,9 @@ func (s *volumeSnapshotLister) VolumeSnapshots(namespace string) VolumeSnapshotN // VolumeSnapshotNamespaceLister helps list and get VolumeSnapshots. type VolumeSnapshotNamespaceLister interface { // List lists all VolumeSnapshots in the indexer for a given namespace. - List(selector labels.Selector) (ret []*v1alpha1.VolumeSnapshot, err error) + List(selector labels.Selector) (ret []*v1beta1.VolumeSnapshot, err error) // Get retrieves the VolumeSnapshot from the indexer for a given namespace and name. - Get(name string) (*v1alpha1.VolumeSnapshot, error) + Get(name string) (*v1beta1.VolumeSnapshot, error) VolumeSnapshotNamespaceListerExpansion } @@ -74,21 +74,21 @@ type volumeSnapshotNamespaceLister struct { } // List lists all VolumeSnapshots in the indexer for a given namespace. -func (s volumeSnapshotNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.VolumeSnapshot, err error) { +func (s volumeSnapshotNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.VolumeSnapshot, err error) { err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.VolumeSnapshot)) + ret = append(ret, m.(*v1beta1.VolumeSnapshot)) }) return ret, err } // Get retrieves the VolumeSnapshot from the indexer for a given namespace and name. -func (s volumeSnapshotNamespaceLister) Get(name string) (*v1alpha1.VolumeSnapshot, error) { +func (s volumeSnapshotNamespaceLister) Get(name string) (*v1beta1.VolumeSnapshot, error) { obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) if err != nil { return nil, err } if !exists { - return nil, errors.NewNotFound(v1alpha1.Resource("volumesnapshot"), name) + return nil, errors.NewNotFound(v1beta1.Resource("volumesnapshot"), name) } - return obj.(*v1alpha1.VolumeSnapshot), nil + return obj.(*v1beta1.VolumeSnapshot), nil } diff --git a/pkg/client/listers/volumesnapshot/v1alpha1/volumesnapshotclass.go b/pkg/client/listers/volumesnapshot/v1beta1/volumesnapshotclass.go similarity index 75% rename from pkg/client/listers/volumesnapshot/v1alpha1/volumesnapshotclass.go rename to pkg/client/listers/volumesnapshot/v1beta1/volumesnapshotclass.go index 505d397bf..2d56d5d54 100644 --- a/pkg/client/listers/volumesnapshot/v1alpha1/volumesnapshotclass.go +++ b/pkg/client/listers/volumesnapshot/v1beta1/volumesnapshotclass.go @@ -16,10 +16,10 @@ limitations under the License. // Code generated by lister-gen. DO NOT EDIT. -package v1alpha1 +package v1beta1 import ( - v1alpha1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + v1beta1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" "k8s.io/client-go/tools/cache" @@ -28,9 +28,9 @@ import ( // VolumeSnapshotClassLister helps list VolumeSnapshotClasses. type VolumeSnapshotClassLister interface { // List lists all VolumeSnapshotClasses in the indexer. - List(selector labels.Selector) (ret []*v1alpha1.VolumeSnapshotClass, err error) + List(selector labels.Selector) (ret []*v1beta1.VolumeSnapshotClass, err error) // Get retrieves the VolumeSnapshotClass from the index for a given name. - Get(name string) (*v1alpha1.VolumeSnapshotClass, error) + Get(name string) (*v1beta1.VolumeSnapshotClass, error) VolumeSnapshotClassListerExpansion } @@ -45,21 +45,21 @@ func NewVolumeSnapshotClassLister(indexer cache.Indexer) VolumeSnapshotClassList } // List lists all VolumeSnapshotClasses in the indexer. -func (s *volumeSnapshotClassLister) List(selector labels.Selector) (ret []*v1alpha1.VolumeSnapshotClass, err error) { +func (s *volumeSnapshotClassLister) List(selector labels.Selector) (ret []*v1beta1.VolumeSnapshotClass, err error) { err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.VolumeSnapshotClass)) + ret = append(ret, m.(*v1beta1.VolumeSnapshotClass)) }) return ret, err } // Get retrieves the VolumeSnapshotClass from the index for a given name. -func (s *volumeSnapshotClassLister) Get(name string) (*v1alpha1.VolumeSnapshotClass, error) { +func (s *volumeSnapshotClassLister) Get(name string) (*v1beta1.VolumeSnapshotClass, error) { obj, exists, err := s.indexer.GetByKey(name) if err != nil { return nil, err } if !exists { - return nil, errors.NewNotFound(v1alpha1.Resource("volumesnapshotclass"), name) + return nil, errors.NewNotFound(v1beta1.Resource("volumesnapshotclass"), name) } - return obj.(*v1alpha1.VolumeSnapshotClass), nil + return obj.(*v1beta1.VolumeSnapshotClass), nil } diff --git a/pkg/client/listers/volumesnapshot/v1alpha1/volumesnapshotcontent.go b/pkg/client/listers/volumesnapshot/v1beta1/volumesnapshotcontent.go similarity index 74% rename from pkg/client/listers/volumesnapshot/v1alpha1/volumesnapshotcontent.go rename to pkg/client/listers/volumesnapshot/v1beta1/volumesnapshotcontent.go index 97d4e90aa..87edbc8fc 100644 --- a/pkg/client/listers/volumesnapshot/v1alpha1/volumesnapshotcontent.go +++ b/pkg/client/listers/volumesnapshot/v1beta1/volumesnapshotcontent.go @@ -16,10 +16,10 @@ limitations under the License. // Code generated by lister-gen. DO NOT EDIT. -package v1alpha1 +package v1beta1 import ( - v1alpha1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + v1beta1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" "k8s.io/client-go/tools/cache" @@ -28,9 +28,9 @@ import ( // VolumeSnapshotContentLister helps list VolumeSnapshotContents. type VolumeSnapshotContentLister interface { // List lists all VolumeSnapshotContents in the indexer. - List(selector labels.Selector) (ret []*v1alpha1.VolumeSnapshotContent, err error) + List(selector labels.Selector) (ret []*v1beta1.VolumeSnapshotContent, err error) // Get retrieves the VolumeSnapshotContent from the index for a given name. - Get(name string) (*v1alpha1.VolumeSnapshotContent, error) + Get(name string) (*v1beta1.VolumeSnapshotContent, error) VolumeSnapshotContentListerExpansion } @@ -45,21 +45,21 @@ func NewVolumeSnapshotContentLister(indexer cache.Indexer) VolumeSnapshotContent } // List lists all VolumeSnapshotContents in the indexer. -func (s *volumeSnapshotContentLister) List(selector labels.Selector) (ret []*v1alpha1.VolumeSnapshotContent, err error) { +func (s *volumeSnapshotContentLister) List(selector labels.Selector) (ret []*v1beta1.VolumeSnapshotContent, err error) { err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.VolumeSnapshotContent)) + ret = append(ret, m.(*v1beta1.VolumeSnapshotContent)) }) return ret, err } // Get retrieves the VolumeSnapshotContent from the index for a given name. -func (s *volumeSnapshotContentLister) Get(name string) (*v1alpha1.VolumeSnapshotContent, error) { +func (s *volumeSnapshotContentLister) Get(name string) (*v1beta1.VolumeSnapshotContent, error) { obj, exists, err := s.indexer.GetByKey(name) if err != nil { return nil, err } if !exists { - return nil, errors.NewNotFound(v1alpha1.Resource("volumesnapshotcontent"), name) + return nil, errors.NewNotFound(v1beta1.Resource("volumesnapshotcontent"), name) } - return obj.(*v1alpha1.VolumeSnapshotContent), nil + return obj.(*v1beta1.VolumeSnapshotContent), nil } diff --git a/pkg/controller/csi_handler.go b/pkg/controller/csi_handler.go index 3b3a9000a..881f8a7b1 100644 --- a/pkg/controller/csi_handler.go +++ b/pkg/controller/csi_handler.go @@ -22,7 +22,7 @@ import ( "strings" "time" - crdv1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + crdv1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" "github.com/kubernetes-csi/external-snapshotter/pkg/snapshotter" "k8s.io/api/core/v1" diff --git a/pkg/controller/framework_test.go b/pkg/controller/framework_test.go index a197d82c2..cf5c4e859 100644 --- a/pkg/controller/framework_test.go +++ b/pkg/controller/framework_test.go @@ -29,12 +29,12 @@ import ( "testing" "time" - crdv1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + crdv1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" clientset "github.com/kubernetes-csi/external-snapshotter/pkg/client/clientset/versioned" "github.com/kubernetes-csi/external-snapshotter/pkg/client/clientset/versioned/fake" snapshotscheme "github.com/kubernetes-csi/external-snapshotter/pkg/client/clientset/versioned/scheme" informers "github.com/kubernetes-csi/external-snapshotter/pkg/client/informers/externalversions" - storagelisters "github.com/kubernetes-csi/external-snapshotter/pkg/client/listers/volumesnapshot/v1alpha1" + storagelisters "github.com/kubernetes-csi/external-snapshotter/pkg/client/listers/volumesnapshot/v1beta1" "k8s.io/api/core/v1" storagev1 "k8s.io/api/storage/v1" storagev1beta1 "k8s.io/api/storage/v1beta1" @@ -766,9 +766,9 @@ func newTestController(kubeClient kubernetes.Interface, clientset clientset.Inte clientset, kubeClient, mockDriverName, - informerFactory.Snapshot().V1alpha1().VolumeSnapshots(), - informerFactory.Snapshot().V1alpha1().VolumeSnapshotContents(), - informerFactory.Snapshot().V1alpha1().VolumeSnapshotClasses(), + informerFactory.Snapshot().V1beta1().VolumeSnapshots(), + informerFactory.Snapshot().V1beta1().VolumeSnapshotContents(), + informerFactory.Snapshot().V1beta1().VolumeSnapshotClasses(), coreFactory.Core().V1().PersistentVolumeClaims(), 3, 5*time.Millisecond, @@ -820,7 +820,7 @@ func newContent(name, className, snapshotHandle, volumeUID, volumeName, boundToS if boundToSnapshotName != "" { content.Spec.VolumeSnapshotRef = &v1.ObjectReference{ Kind: "VolumeSnapshot", - APIVersion: "snapshot.storage.k8s.io/v1alpha1", + APIVersion: "snapshot.storage.k8s.io/v1beta1", UID: types.UID(boundToSnapshotUID), Namespace: testNamespace, Name: boundToSnapshotName, @@ -854,7 +854,7 @@ func newSnapshot(name, className, boundToContent, snapshotUID, claimName string, Namespace: testNamespace, UID: types.UID(snapshotUID), ResourceVersion: "1", - SelfLink: "/apis/snapshot.storage.k8s.io/v1alpha1/namespaces/" + testNamespace + "/volumesnapshots/" + name, + SelfLink: "/apis/snapshot.storage.k8s.io/v1beta1/namespaces/" + testNamespace + "/volumesnapshots/" + name, }, Spec: crdv1.VolumeSnapshotSpec{ VolumeSnapshotClassName: &className, diff --git a/pkg/controller/snapshot_controller.go b/pkg/controller/snapshot_controller.go index 5333c63f4..9f102d9cf 100644 --- a/pkg/controller/snapshot_controller.go +++ b/pkg/controller/snapshot_controller.go @@ -21,7 +21,7 @@ import ( "strings" "time" - crdv1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + crdv1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" "k8s.io/api/core/v1" storagev1 "k8s.io/api/storage/v1" storage "k8s.io/api/storage/v1beta1" @@ -423,7 +423,7 @@ func (ctrl *csiSnapshotController) updateSnapshotErrorStatusWithEvent(snapshot * } snapshotClone.Status.Error = statusError snapshotClone.Status.ReadyToUse = false - newSnapshot, err := ctrl.clientset.SnapshotV1alpha1().VolumeSnapshots(snapshotClone.Namespace).UpdateStatus(snapshotClone) + newSnapshot, err := ctrl.clientset.SnapshotV1beta1().VolumeSnapshots(snapshotClone.Namespace).UpdateStatus(snapshotClone) if err != nil { klog.V(4).Infof("updating VolumeSnapshot[%s] error status failed %v", snapshotKey(snapshot), err) @@ -458,7 +458,7 @@ func IsSnapshotBound(snapshot *crdv1.VolumeSnapshot, content *crdv1.VolumeSnapsh // isSnapshotConentBeingUsed checks if snapshot content is bound to snapshot. func (ctrl *csiSnapshotController) isSnapshotContentBeingUsed(content *crdv1.VolumeSnapshotContent) bool { if content.Spec.VolumeSnapshotRef != nil { - snapshotObj, err := ctrl.clientset.SnapshotV1alpha1().VolumeSnapshots(content.Spec.VolumeSnapshotRef.Namespace).Get(content.Spec.VolumeSnapshotRef.Name, metav1.GetOptions{}) + snapshotObj, err := ctrl.clientset.SnapshotV1beta1().VolumeSnapshots(content.Spec.VolumeSnapshotRef.Namespace).Get(content.Spec.VolumeSnapshotRef.Name, metav1.GetOptions{}) if err != nil { klog.Infof("isSnapshotContentBeingUsed: Cannot get snapshot %s from api server: [%v]. VolumeSnapshot object may be deleted already.", content.Spec.VolumeSnapshotRef.Name, err) return false @@ -510,7 +510,7 @@ func (ctrl *csiSnapshotController) checkandBindSnapshotContent(snapshot *crdv1.V contentClone.Spec.VolumeSnapshotRef.UID = snapshot.UID className := *(snapshot.Spec.VolumeSnapshotClassName) contentClone.Spec.VolumeSnapshotClassName = &className - newContent, err := ctrl.clientset.SnapshotV1alpha1().VolumeSnapshotContents().Update(contentClone) + newContent, err := ctrl.clientset.SnapshotV1beta1().VolumeSnapshotContents().Update(contentClone) if err != nil { klog.V(4).Infof("updating VolumeSnapshotContent[%s] error status failed %v", newContent.Name, err) return nil, err @@ -691,7 +691,7 @@ func (ctrl *csiSnapshotController) createSnapshotOperation(snapshot *crdv1.Volum // Try to create the VolumeSnapshotContent object several times for i := 0; i < ctrl.createSnapshotContentRetryCount; i++ { klog.V(5).Infof("createSnapshot [%s]: trying to save volume snapshot content %s", snapshotKey(snapshot), snapshotContent.Name) - if _, err = ctrl.clientset.SnapshotV1alpha1().VolumeSnapshotContents().Create(snapshotContent); err == nil || apierrs.IsAlreadyExists(err) { + if _, err = ctrl.clientset.SnapshotV1beta1().VolumeSnapshotContents().Create(snapshotContent); err == nil || apierrs.IsAlreadyExists(err) { // Save succeeded. if err != nil { klog.V(3).Infof("volume snapshot content %q for snapshot %q already exists, reusing", snapshotContent.Name, snapshotKey(snapshot)) @@ -758,7 +758,7 @@ func (ctrl *csiSnapshotController) deleteSnapshotContentOperation(content *crdv1 return fmt.Errorf("failed to delete snapshot %#v, err: %v", content.Name, err) } - err = ctrl.clientset.SnapshotV1alpha1().VolumeSnapshotContents().Delete(content.Name, &metav1.DeleteOptions{}) + err = ctrl.clientset.SnapshotV1beta1().VolumeSnapshotContents().Delete(content.Name, &metav1.DeleteOptions{}) if err != nil { ctrl.eventRecorder.Event(content, v1.EventTypeWarning, "SnapshotContentObjectDeleteError", "Failed to delete snapshot content API object") return fmt.Errorf("failed to delete VolumeSnapshotContent %s from API server: %q", content.Name, err) @@ -769,7 +769,7 @@ func (ctrl *csiSnapshotController) deleteSnapshotContentOperation(content *crdv1 func (ctrl *csiSnapshotController) bindandUpdateVolumeSnapshot(snapshotContent *crdv1.VolumeSnapshotContent, snapshot *crdv1.VolumeSnapshot) (*crdv1.VolumeSnapshot, error) { klog.V(5).Infof("bindandUpdateVolumeSnapshot for snapshot [%s]: snapshotContent [%s]", snapshot.Name, snapshotContent.Name) - snapshotObj, err := ctrl.clientset.SnapshotV1alpha1().VolumeSnapshots(snapshot.Namespace).Get(snapshot.Name, metav1.GetOptions{}) + snapshotObj, err := ctrl.clientset.SnapshotV1beta1().VolumeSnapshots(snapshot.Namespace).Get(snapshot.Name, metav1.GetOptions{}) if err != nil { return nil, fmt.Errorf("error get snapshot %s from api server: %v", snapshotKey(snapshot), err) } @@ -782,7 +782,7 @@ func (ctrl *csiSnapshotController) bindandUpdateVolumeSnapshot(snapshotContent * } else { klog.Infof("bindVolumeSnapshotContentToVolumeSnapshot: before bind VolumeSnapshot %s to volumeSnapshotContent [%s]", snapshot.Name, snapshotContent.Name) snapshotCopy.Spec.SnapshotContentName = snapshotContent.Name - updateSnapshot, err := ctrl.clientset.SnapshotV1alpha1().VolumeSnapshots(snapshot.Namespace).Update(snapshotCopy) + updateSnapshot, err := ctrl.clientset.SnapshotV1beta1().VolumeSnapshots(snapshot.Namespace).Update(snapshotCopy) if err != nil { klog.Infof("bindVolumeSnapshotContentToVolumeSnapshot: Error binding VolumeSnapshot %s to volumeSnapshotContent [%s]. Error [%#v]", snapshot.Name, snapshotContent.Name, err) return nil, newControllerUpdateError(snapshotKey(snapshot), err.Error()) @@ -808,7 +808,7 @@ func (ctrl *csiSnapshotController) updateSnapshotContentSize(content *crdv1.Volu } contentClone := content.DeepCopy() contentClone.Spec.VolumeSnapshotSource.CSI.RestoreSize = &size - _, err := ctrl.clientset.SnapshotV1alpha1().VolumeSnapshotContents().Update(contentClone) + _, err := ctrl.clientset.SnapshotV1beta1().VolumeSnapshotContents().Update(contentClone) if err != nil { return newControllerUpdateError(content.Name, err.Error()) } @@ -848,7 +848,7 @@ func (ctrl *csiSnapshotController) updateSnapshotStatus(snapshot *crdv1.VolumeSn status.RestoreSize = resource.NewQuantity(size, resource.BinarySI) } snapshotClone.Status = status - newSnapshotObj, err := ctrl.clientset.SnapshotV1alpha1().VolumeSnapshots(snapshotClone.Namespace).UpdateStatus(snapshotClone) + newSnapshotObj, err := ctrl.clientset.SnapshotV1beta1().VolumeSnapshots(snapshotClone.Namespace).UpdateStatus(snapshotClone) if err != nil { return nil, newControllerUpdateError(snapshotKey(snapshot), err.Error()) } @@ -949,7 +949,7 @@ func (ctrl *csiSnapshotController) SetDefaultSnapshotClass(snapshot *crdv1.Volum klog.V(5).Infof("setDefaultSnapshotClass [%s]: default VolumeSnapshotClassName [%s]", snapshot.Name, defaultClasses[0].Name) snapshotClone := snapshot.DeepCopy() snapshotClone.Spec.VolumeSnapshotClassName = &(defaultClasses[0].Name) - newSnapshot, err := ctrl.clientset.SnapshotV1alpha1().VolumeSnapshots(snapshotClone.Namespace).Update(snapshotClone) + newSnapshot, err := ctrl.clientset.SnapshotV1beta1().VolumeSnapshots(snapshotClone.Namespace).Update(snapshotClone) if err != nil { klog.V(4).Infof("updating VolumeSnapshot[%s] default class failed %v", snapshotKey(snapshot), err) } @@ -1016,7 +1016,7 @@ func (ctrl *csiSnapshotController) addContentFinalizer(content *crdv1.VolumeSnap contentClone := content.DeepCopy() contentClone.ObjectMeta.Finalizers = append(contentClone.ObjectMeta.Finalizers, VolumeSnapshotContentFinalizer) - _, err := ctrl.clientset.SnapshotV1alpha1().VolumeSnapshotContents().Update(contentClone) + _, err := ctrl.clientset.SnapshotV1beta1().VolumeSnapshotContents().Update(contentClone) if err != nil { return newControllerUpdateError(content.Name, err.Error()) } @@ -1035,7 +1035,7 @@ func (ctrl *csiSnapshotController) removeContentFinalizer(content *crdv1.VolumeS contentClone := content.DeepCopy() contentClone.ObjectMeta.Finalizers = slice.RemoveString(contentClone.ObjectMeta.Finalizers, VolumeSnapshotContentFinalizer, nil) - _, err := ctrl.clientset.SnapshotV1alpha1().VolumeSnapshotContents().Update(contentClone) + _, err := ctrl.clientset.SnapshotV1beta1().VolumeSnapshotContents().Update(contentClone) if err != nil { return newControllerUpdateError(content.Name, err.Error()) } @@ -1053,7 +1053,7 @@ func (ctrl *csiSnapshotController) removeContentFinalizer(content *crdv1.VolumeS func (ctrl *csiSnapshotController) addSnapshotFinalizer(snapshot *crdv1.VolumeSnapshot) error { snapshotClone := snapshot.DeepCopy() snapshotClone.ObjectMeta.Finalizers = append(snapshotClone.ObjectMeta.Finalizers, VolumeSnapshotFinalizer) - _, err := ctrl.clientset.SnapshotV1alpha1().VolumeSnapshots(snapshotClone.Namespace).Update(snapshotClone) + _, err := ctrl.clientset.SnapshotV1beta1().VolumeSnapshots(snapshotClone.Namespace).Update(snapshotClone) if err != nil { return newControllerUpdateError(snapshot.Name, err.Error()) } @@ -1072,7 +1072,7 @@ func (ctrl *csiSnapshotController) removeSnapshotFinalizer(snapshot *crdv1.Volum snapshotClone := snapshot.DeepCopy() snapshotClone.ObjectMeta.Finalizers = slice.RemoveString(snapshotClone.ObjectMeta.Finalizers, VolumeSnapshotFinalizer, nil) - _, err := ctrl.clientset.SnapshotV1alpha1().VolumeSnapshots(snapshotClone.Namespace).Update(snapshotClone) + _, err := ctrl.clientset.SnapshotV1beta1().VolumeSnapshots(snapshotClone.Namespace).Update(snapshotClone) if err != nil { return newControllerUpdateError(snapshot.Name, err.Error()) } diff --git a/pkg/controller/snapshot_controller_base.go b/pkg/controller/snapshot_controller_base.go index 5458b1bcf..286adc5a2 100644 --- a/pkg/controller/snapshot_controller_base.go +++ b/pkg/controller/snapshot_controller_base.go @@ -20,10 +20,10 @@ import ( "fmt" "time" - crdv1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + crdv1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" clientset "github.com/kubernetes-csi/external-snapshotter/pkg/client/clientset/versioned" - storageinformers "github.com/kubernetes-csi/external-snapshotter/pkg/client/informers/externalversions/volumesnapshot/v1alpha1" - storagelisters "github.com/kubernetes-csi/external-snapshotter/pkg/client/listers/volumesnapshot/v1alpha1" + storageinformers "github.com/kubernetes-csi/external-snapshotter/pkg/client/informers/externalversions/volumesnapshot/v1beta1" + storagelisters "github.com/kubernetes-csi/external-snapshotter/pkg/client/listers/volumesnapshot/v1beta1" "github.com/kubernetes-csi/external-snapshotter/pkg/snapshotter" "k8s.io/api/core/v1" diff --git a/pkg/controller/snapshot_controller_test.go b/pkg/controller/snapshot_controller_test.go index 625f9d700..c8c41a021 100644 --- a/pkg/controller/snapshot_controller_test.go +++ b/pkg/controller/snapshot_controller_test.go @@ -17,7 +17,7 @@ limitations under the License. package controller import ( - crdv1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + crdv1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" "k8s.io/client-go/tools/cache" "testing" ) diff --git a/pkg/controller/snapshot_create_test.go b/pkg/controller/snapshot_create_test.go index 53358b238..385cf79c7 100644 --- a/pkg/controller/snapshot_create_test.go +++ b/pkg/controller/snapshot_create_test.go @@ -21,7 +21,7 @@ import ( "testing" "time" - crdv1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + crdv1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" "k8s.io/api/core/v1" storage "k8s.io/api/storage/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -327,7 +327,7 @@ func TestCreateSnapshotSync(t *testing.T) { }, }, errors: []reactorError{ - // Inject error to the forth client.VolumesnapshotV1alpha1().VolumeSnapshots().Update call. + // Inject error to the forth client.VolumesnapshotV1beta1().VolumeSnapshots().Update call. // All other calls will succeed. {"update", "volumesnapshots", errors.New("mock update error")}, {"update", "volumesnapshots", errors.New("mock update error")}, diff --git a/pkg/controller/snapshot_delete_test.go b/pkg/controller/snapshot_delete_test.go index 6be2be119..1f5878ee0 100644 --- a/pkg/controller/snapshot_delete_test.go +++ b/pkg/controller/snapshot_delete_test.go @@ -20,7 +20,7 @@ import ( "errors" "testing" - crdv1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + crdv1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -195,7 +195,7 @@ func TestDeleteSync(t *testing.T) { expectedDeleteCalls: []deleteCall{{"sid1-6", map[string]string{"foo": "bar"}, nil}}, expectedEvents: []string{"Warning SnapshotContentObjectDeleteError"}, errors: []reactorError{ - // Inject error to the first client.VolumesnapshotV1alpha1().VolumeSnapshotContents().Delete call. + // Inject error to the first client.VolumesnapshotV1beta1().VolumeSnapshotContents().Delete call. // All other calls will succeed. {"delete", "volumesnapshotcontents", errors.New("mock delete error")}, }, diff --git a/pkg/controller/snapshot_ready_test.go b/pkg/controller/snapshot_ready_test.go index 1ccb6bd90..01223e8e0 100644 --- a/pkg/controller/snapshot_ready_test.go +++ b/pkg/controller/snapshot_ready_test.go @@ -186,7 +186,7 @@ func TestSync(t *testing.T) { }, }, errors: []reactorError{ - // Inject error to the first client.VolumesnapshotV1alpha1().VolumeSnapshots().Update call. + // Inject error to the first client.VolumesnapshotV1beta1().VolumeSnapshots().Update call. // All other calls will succeed. {"update", "volumesnapshots", errors.New("mock update error")}, }, diff --git a/pkg/controller/util.go b/pkg/controller/util.go index b91f32591..22e491b25 100644 --- a/pkg/controller/util.go +++ b/pkg/controller/util.go @@ -20,7 +20,7 @@ import ( "fmt" "strings" - crdv1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + crdv1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/controller/util_test.go b/pkg/controller/util_test.go index 4da945761..a73c3ab3f 100644 --- a/pkg/controller/util_test.go +++ b/pkg/controller/util_test.go @@ -17,7 +17,7 @@ limitations under the License. package controller import ( - crdv1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + crdv1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "reflect" From 9b86d7cfae1b6ef19d6e2c343a6c3058a1953d6b Mon Sep 17 00:00:00 2001 From: xiangqian Date: Thu, 22 Aug 2019 22:31:10 -0700 Subject: [PATCH 02/11] generate crds, modify api --- ....storage.k8s.io_volumesnapshotclasses.yaml | 76 ++--- ...storage.k8s.io_volumesnapshotcontents.yaml | 297 +++++++++--------- ...apshot.storage.k8s.io_volumesnapshots.yaml | 202 ++++++------ pkg/apis/volumesnapshot/v1beta1/types.go | 160 ++++++---- 4 files changed, 389 insertions(+), 346 deletions(-) diff --git a/config/crd/snapshot.storage.k8s.io_volumesnapshotclasses.yaml b/config/crd/snapshot.storage.k8s.io_volumesnapshotclasses.yaml index f4e83af9f..076df1f41 100644 --- a/config/crd/snapshot.storage.k8s.io_volumesnapshotclasses.yaml +++ b/config/crd/snapshot.storage.k8s.io_volumesnapshotclasses.yaml @@ -11,44 +11,50 @@ spec: kind: VolumeSnapshotClass plural: volumesnapshotclasses scope: "" + validation: + openAPIV3Schema: + description: VolumeSnapshotClass describes the parameters for a class of storage + snapshotter for which VolumeSnapshot can be dynamically taken for a given + PersistentVolumeClaim VolumeSnapshotClasses are non-namespaced. The name of + a VolumeSnapshotClass object is significant, it serves as the unique identifier + for a user to request a snapshot to be created using the specific VolumeSnapshotClass + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources' + type: string + deletionPolicy: + description: DeletionPolicy defines whether a VolumeSnapshotContent and + its associated physical snapshot on underlying storage system should be + deleted or not when released from its corresponding VolumeSnapshot. If + not specified, the default will be VolumeSnapshotContentRetain for static + binding, and VolumeSnapshotContentDelete for dynamic snapshot creation. + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds' + type: string + metadata: + description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata' + type: object + parameters: + additionalProperties: + type: string + description: Parameters holds parameters for underlying storage system. + These values are opaque to Kubernetes. + type: object + snapshotter: + description: Snapshotter is the name of the driver expected to handle VolumeSnapshot + requests of this VolumeSnapshotClass. + type: string + required: + - snapshotter + type: object version: v1beta1 versions: - name: v1beta1 - schema: - openAPIV3Schema: - description: VolumeSnapshotClass describes the parameters used by storage - system when provisioning VolumeSnapshots from PVCs. The name of a VolumeSnapshotClass - object is significant, and is how users can request a particular class. - properties: - apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources' - type: string - deletionPolicy: - description: 'Optional: what happens to a snapshot content when released - from its snapshot. The default policy is Delete if not specified.' - type: string - kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds' - type: string - metadata: - description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata' - type: object - parameters: - additionalProperties: - type: string - description: Parameters holds parameters for the snapshotter. These values - are opaque to the system and are passed directly to the snapshotter. - type: object - snapshotter: - description: Snapshotter is the driver expected to handle this VolumeSnapshotClass. - type: string - required: - - snapshotter - type: object served: true storage: true status: diff --git a/config/crd/snapshot.storage.k8s.io_volumesnapshotcontents.yaml b/config/crd/snapshot.storage.k8s.io_volumesnapshotcontents.yaml index 5b9b8379a..e52973518 100644 --- a/config/crd/snapshot.storage.k8s.io_volumesnapshotcontents.yaml +++ b/config/crd/snapshot.storage.k8s.io_volumesnapshotcontents.yaml @@ -11,155 +11,160 @@ spec: kind: VolumeSnapshotContent plural: volumesnapshotcontents scope: "" + validation: + openAPIV3Schema: + description: VolumeSnapshotContent represents the actual "on-disk" snapshot + object in the underlying storage system + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds' + type: string + metadata: + description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata' + type: object + spec: + description: Spec represents the desired state of the snapshot content + properties: + csiVolumeSnapshotSource: + description: CSI (Container Storage Interface) represents storage that + handled by an external CSI Volume Driver (Alpha feature). + properties: + creationTime: + description: Timestamp when the point-in-time snapshot is taken + by the underlying storage system. This timestamp will be generated + and returned by the CSI volume driver after the snapshot is cut. + 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 (aka, epoch time) since 1970-01-01 00:00:00 + UTC. This field is required in the CSI spec however made optional + here to support static binding. + format: int64 + type: integer + driver: + description: Driver is the name of the driver used to create a physical + snapshot on underlying storage system. This MUST be the same name + returned by the CSI GetPluginName() call for that driver. Required. + type: string + restoreSize: + description: When restoring a volume from a snapshot, the volume + size needs to be equal to or larger than the RestoreSize if it + is specified. If RestoreSize is set to nil, in the dynamic snapshot + creation case, it means that the underlying storage system does + not have this information available; in the static binding case, + this piece of information is not available. + format: int64 + type: integer + snapshotHandle: + description: SnapshotHandle is the unique id returned from the underlying + storage system by the CSI driver's CreationSnapshot gRPC call. + It serves as the only and sufficient handle when communicating + with underlying storage systems via CSI driver for all subsequent + calls on the specific VolumeSnapshot Required. + type: string + required: + - driver + - snapshotHandle + type: object + deletionPolicy: + description: DeletionPolicy defines whether a VolumeSnapshotContent + and its associated physical snapshot on underlying storage system + should be deleted or not when released from its corresponding VolumeSnapshot. + If not specified, the default will be VolumeSnapshotContentRetain + for static binding, and VolumeSnapshotContentDelete for dynamic snapshot + creation. + type: string + persistentVolumeRef: + description: PersistentVolumeRef represents the PersistentVolume that + the snapshot has been taken from. In dynamic snapshot creation case, + the field will be specified when VolumeSnapshot and VolumeSnapshotContent + are bound. + properties: + apiVersion: + description: API version of the referent. + type: string + fieldPath: + description: 'If referring to a piece of an object instead of an + entire object, this string should contain a valid JSON/Go field + access statement, such as desiredState.manifest.containers[2]. + For example, if the object reference is to a container within + a pod, this would take on a value like: "spec.containers{name}" + (where "name" refers to the name of the container that triggered + the event) or if no container name is specified "spec.containers[2]" + (container with index 2 in this pod). This syntax is chosen only + to have some well-defined way of referencing a part of an object. + TODO: this design is not final and this field is subject to change + in the future.' + type: string + kind: + description: 'Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds' + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names' + type: string + namespace: + description: 'Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/' + type: string + resourceVersion: + description: 'Specific resourceVersion to which this reference is + made, if any. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#concurrency-control-and-consistency' + type: string + uid: + description: 'UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids' + type: string + type: object + volumeSnapshotRef: + description: VolumeSnapshotRef is part of bi-directional binding between + VolumeSnapshot and VolumeSnapshotContent. Expect to be non-nil when + bound. VolumeSnapshot.VolumeSnapshotContentName is the authoritative + bind between VolumeSnapshot and VolumeSnapshotContent + properties: + apiVersion: + description: API version of the referent. + type: string + fieldPath: + description: 'If referring to a piece of an object instead of an + entire object, this string should contain a valid JSON/Go field + access statement, such as desiredState.manifest.containers[2]. + For example, if the object reference is to a container within + a pod, this would take on a value like: "spec.containers{name}" + (where "name" refers to the name of the container that triggered + the event) or if no container name is specified "spec.containers[2]" + (container with index 2 in this pod). This syntax is chosen only + to have some well-defined way of referencing a part of an object. + TODO: this design is not final and this field is subject to change + in the future.' + type: string + kind: + description: 'Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds' + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names' + type: string + namespace: + description: 'Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/' + type: string + resourceVersion: + description: 'Specific resourceVersion to which this reference is + made, if any. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#concurrency-control-and-consistency' + type: string + uid: + description: 'UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids' + type: string + type: object + type: object + required: + - spec + type: object version: v1beta1 versions: - name: v1beta1 - schema: - openAPIV3Schema: - description: VolumeSnapshotContent represents the actual "on-disk" snapshot - object - properties: - apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources' - type: string - kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds' - type: string - metadata: - description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata' - type: object - spec: - description: Spec represents the desired state of the snapshot content - properties: - csiVolumeSnapshotSource: - description: CSI (Container Storage Interface) represents storage - that handled by an external CSI Volume Driver (Alpha feature). - properties: - creationTime: - description: Timestamp when the point-in-time snapshot is taken - on the storage system. This timestamp will be generated by the - CSI volume driver after the snapshot is cut. The format of this - field should be 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. This field is - required in the CSI spec but optional here to support static - binding. - format: int64 - type: integer - driver: - description: Driver is the name of the driver to use for this - snapshot. This MUST be the same name returned by the CSI GetPluginName() - call for that driver. Required. - type: string - restoreSize: - description: When restoring volume from the snapshot, the volume - size should be equal to or larger than the RestoreSize if it - is specified. If RestoreSize is set to nil, it means that the - storage plugin does not have this information available. - format: int64 - type: integer - snapshotHandle: - description: SnapshotHandle is the unique snapshot id returned - by the CSI volume plugin’s CreateSnapshot to refer to the snapshot - on all subsequent calls. Required. - type: string - required: - - driver - - snapshotHandle - type: object - deletionPolicy: - description: 'Optional: what happens to a snapshot content when released - from its snapshot. It will be set to Delete by default if not specified' - type: string - persistentVolumeRef: - description: PersistentVolumeRef represents the PersistentVolume that - the snapshot has been taken from. It becomes non-nil when VolumeSnapshot - and VolumeSnapshotContent are bound. - properties: - apiVersion: - description: API version of the referent. - type: string - fieldPath: - description: 'If referring to a piece of an object instead of - an entire object, this string should contain a valid JSON/Go - field access statement, such as desiredState.manifest.containers[2]. - For example, if the object reference is to a container within - a pod, this would take on a value like: "spec.containers{name}" - (where "name" refers to the name of the container that triggered - the event) or if no container name is specified "spec.containers[2]" - (container with index 2 in this pod). This syntax is chosen - only to have some well-defined way of referencing a part of - an object. TODO: this design is not final and this field is - subject to change in the future.' - type: string - kind: - description: 'Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds' - type: string - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names' - type: string - namespace: - description: 'Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/' - type: string - resourceVersion: - description: 'Specific resourceVersion to which this reference - is made, if any. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#concurrency-control-and-consistency' - type: string - uid: - description: 'UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids' - type: string - type: object - snapshotClassName: - description: Name of the VolumeSnapshotClass used by the VolumeSnapshot. - If not specified, a default snapshot class will be used if it is - available. - type: string - volumeSnapshotRef: - description: VolumeSnapshotRef is part of bi-directional binding between - VolumeSnapshot and VolumeSnapshotContent. It becomes non-nil when - bound. - properties: - apiVersion: - description: API version of the referent. - type: string - fieldPath: - description: 'If referring to a piece of an object instead of - an entire object, this string should contain a valid JSON/Go - field access statement, such as desiredState.manifest.containers[2]. - For example, if the object reference is to a container within - a pod, this would take on a value like: "spec.containers{name}" - (where "name" refers to the name of the container that triggered - the event) or if no container name is specified "spec.containers[2]" - (container with index 2 in this pod). This syntax is chosen - only to have some well-defined way of referencing a part of - an object. TODO: this design is not final and this field is - subject to change in the future.' - type: string - kind: - description: 'Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds' - type: string - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names' - type: string - namespace: - description: 'Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/' - type: string - resourceVersion: - description: 'Specific resourceVersion to which this reference - is made, if any. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#concurrency-control-and-consistency' - type: string - uid: - description: 'UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids' - type: string - type: object - type: object - required: - - spec - type: object served: true storage: true status: diff --git a/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml b/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml index 7b4182456..f57eb387d 100644 --- a/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml +++ b/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml @@ -11,106 +11,114 @@ spec: kind: VolumeSnapshot plural: volumesnapshots scope: "" + validation: + openAPIV3Schema: + description: VolumeSnapshot is a user's request for taking a point in time snapshot + of a volume. Upon successful creation of the snapshot by the volume provider, + it is bound to a corresponding VolumeSnapshotContent. VolumeSnapshot objects + are namespaced + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds' + type: string + metadata: + description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata' + type: object + spec: + description: 'Spec defines the desired characteristics of a snapshot requested + by a user. More info: https:s//kubernetes.io/docs/concepts/storage/volume-snapshots#volumesnapshots' + properties: + source: + description: Source has the information about where a snapshot should + be created from. Currently PersistentVolumeClaim is the only supported + source type. If specified, and VolumeSnapshotContentName is not specified + (i.e., nil), snapshot will be dynamically created from the given source. + If not specified, user can statically bind a VolumeSnapshot to a VolumeSnapshotContent + by specifying VolumeSnapshotContentName. + properties: + apiGroup: + description: APIGroup is the group for the resource being referenced. + If APIGroup is not specified, the specified Kind must be in the + core API group. For any other third-party types, APIGroup is required. + type: string + kind: + description: Kind is the type of resource being referenced + type: string + name: + description: Name is the name of resource being referenced + type: string + required: + - kind + - name + type: object + volumeSnapshotClassName: + description: 'Name of the VolumeSnapshotClass requested by the VolumeSnapshot. + If not specified, the default snapshot class will be used if there + exists one. More info: https://kubernetes.io/docs/concepts/storage/volume-snapshot-classes' + type: string + volumeSnapshotContentName: + description: VolumeSnapshotContentName is the binding reference to the + VolumeSnapshotContent backing the VolumeSnapshot. In dynamic snapshot + creation case, VolumeSnapshotContentName must NOT be specified. + type: string + type: object + status: + description: 'Status represents the current status/information of a volume + snapshot. NOTE: Status is subjected to change by sources other than snapshot + controller, for example, undesired corruption from human operation + errors. It is only informational to provide necessary transparency + of a snapshot''s status to users. It is highly recommended not to + rely on this piece of information programmatically.' + properties: + creationTime: + description: CreationTime, if not nil, represents the timestamp when + a snapshot was successfully cut by the underlying storage system. + In static binding, CreationTime might not be available. + format: date-time + type: string + error: + description: The lastest observed error during snapshot creation operation, + if any. + properties: + message: + description: String detailing the error encountered during Attach + or Detach operation. This string may be logged, so it should not + contain sensitive information. + type: string + time: + description: Time the error was encountered. + format: date-time + type: string + type: object + readyToUse: + description: ReadyToUse is a status/informational flag which provides + transparency to users. In the dynamic snapshot creation case, ReadyToUse + will be set to true when underlying storage system has successfully + finished all procedures out-of-bound to make a snapshot available + AND snapshot controller has bound the VolumeSnapshot to a VolumeSnapshotContent + successfully. + type: boolean + restoreSize: + description: RestoreSize, if not nil, represents the minimum volume + size to restore from a VolumeSnapshot It is a storage system level + property of a snapshot when the underlying storage system supports. + The field could be nil if the underlying storage system does not have + the information available, , or in cases like manual/static binding. + type: string + required: + - readyToUse + type: object + type: object version: v1beta1 versions: - name: v1beta1 - schema: - openAPIV3Schema: - description: VolumeSnapshot is a user's request for taking a snapshot. Upon - successful creation of the actual snapshot by the volume provider it is - bound to the corresponding VolumeSnapshotContent. Only the VolumeSnapshot - object is accessible to the user in the namespace. - properties: - apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources' - type: string - kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds' - type: string - metadata: - description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata' - type: object - spec: - description: Spec defines the desired characteristics of a snapshot requested - by a user. - properties: - snapshotClassName: - description: Name of the VolumeSnapshotClass used by the VolumeSnapshot. - If not specified, a default snapshot class will be used if it is - available. - type: string - snapshotContentName: - description: SnapshotContentName binds the VolumeSnapshot object with - the VolumeSnapshotContent - type: string - source: - description: Source has the information about where the snapshot is - created from. In Alpha version, only PersistentVolumeClaim is supported - as the source. If not specified, user can create VolumeSnapshotContent - and bind it with VolumeSnapshot manually. - properties: - apiGroup: - description: APIGroup is the group for the resource being referenced. - If APIGroup is not specified, the specified Kind must be in - the core API group. For any other third-party types, APIGroup - is required. - type: string - kind: - description: Kind is the type of resource being referenced - type: string - name: - description: Name is the name of resource being referenced - type: string - required: - - kind - - name - type: object - type: object - status: - description: Status represents the latest observed state of the snapshot - properties: - creationTime: - description: CreationTime is the time the snapshot was successfully - created. If it is set, it means the snapshot was created; Otherwise - the snapshot was not created. - format: date-time - type: string - error: - description: The last error encountered during create snapshot operation, - if any. This field must only be set by the entity completing the - create snapshot operation, i.e. the external-snapshotter. - properties: - message: - description: String detailing the error encountered during Attach - or Detach operation. This string may be logged, so it should - not contain sensitive information. - type: string - time: - description: Time the error was encountered. - format: date-time - type: string - type: object - readyToUse: - description: ReadyToUse is set to true only if the snapshot is ready - to use (e.g., finish uploading if there is an uploading phase) and - also VolumeSnapshot and its VolumeSnapshotContent bind correctly - with each other. If any of the above condition is not true, ReadyToUse - is set to false - type: boolean - restoreSize: - description: When restoring volume from the snapshot, the volume size - should be equal to or larger than the RestoreSize if it is specified. - If RestoreSize is set to nil, it means that the storage plugin does - not have this information available. - type: string - type: object - required: - - spec - type: object served: true storage: true status: diff --git a/pkg/apis/volumesnapshot/v1beta1/types.go b/pkg/apis/volumesnapshot/v1beta1/types.go index 2fb0b8e75..a5d859037 100644 --- a/pkg/apis/volumesnapshot/v1beta1/types.go +++ b/pkg/apis/volumesnapshot/v1beta1/types.go @@ -35,9 +35,10 @@ const ( // +genclient // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// VolumeSnapshot is a user's request for taking a snapshot. Upon successful creation of the actual -// snapshot by the volume provider it is bound to the corresponding VolumeSnapshotContent. -// Only the VolumeSnapshot object is accessible to the user in the namespace. +// VolumeSnapshot is a user's request for taking a point in time snapshot of a volume. +// Upon successful creation of the snapshot by the volume provider, it is bound to a +// corresponding VolumeSnapshotContent. +// VolumeSnapshot objects are namespaced type VolumeSnapshot struct { metav1.TypeMeta `json:",inline"` // Standard object's metadata. @@ -46,9 +47,15 @@ type VolumeSnapshot struct { metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` // Spec defines the desired characteristics of a snapshot requested by a user. - Spec VolumeSnapshotSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"` + // More info: https:s//kubernetes.io/docs/concepts/storage/volume-snapshots#volumesnapshots + // +optional + Spec VolumeSnapshotSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` - // Status represents the latest observed state of the snapshot + // Status represents the current status/information of a volume snapshot. + // NOTE: Status is subjected to change by sources other than snapshot controller, + // for example, undesired corruption from human operation errors. It is only informational to + // provide necessary transparency of a snapshot's status to users. It is highly recommended + // not to rely on this piece of information programmatically. // +optional Status VolumeSnapshotStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` } @@ -61,51 +68,57 @@ type VolumeSnapshotList struct { // +optional metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` - // Items is the list of VolumeSnapshots + // List of VolumeSnapshots Items []VolumeSnapshot `json:"items" protobuf:"bytes,2,rep,name=items"` } // VolumeSnapshotSpec describes the common attributes of a volume snapshot type VolumeSnapshotSpec struct { - // Source has the information about where the snapshot is created from. - // In Alpha version, only PersistentVolumeClaim is supported as the source. - // If not specified, user can create VolumeSnapshotContent and bind it with VolumeSnapshot manually. + // Source has the information about where a snapshot should be created from. + // Currently PersistentVolumeClaim is the only supported source type. + // If specified, and VolumeSnapshotContentName is not specified (i.e., nil), + // snapshot will be dynamically created from the given source. + // If not specified, user can statically bind a VolumeSnapshot to a + // VolumeSnapshotContent by specifying VolumeSnapshotContentName. // +optional - Source *core_v1.TypedLocalObjectReference `json:"source" protobuf:"bytes,1,opt,name=source"` + Source *core_v1.TypedLocalObjectReference `json:"source,omitempty" protobuf:"bytes,1,opt,name=source"` - // SnapshotContentName binds the VolumeSnapshot object with the VolumeSnapshotContent + // VolumeSnapshotContentName is the binding reference to the VolumeSnapshotContent backing the VolumeSnapshot. + // In dynamic snapshot creation case, VolumeSnapshotContentName must NOT be specified. // +optional - SnapshotContentName string `json:"snapshotContentName" protobuf:"bytes,2,opt,name=snapshotContentName"` + VolumeSnapshotContentName *string `json:"volumeSnapshotContentName,omitempty" protobuf:"bytes,2,opt,name=volumeSnapshotContentName"` - // Name of the VolumeSnapshotClass used by the VolumeSnapshot. If not specified, a default snapshot class will - // be used if it is available. + // Name of the VolumeSnapshotClass requested by the VolumeSnapshot. + // If not specified, the default snapshot class will be used if there exists one. + // More info: https://kubernetes.io/docs/concepts/storage/volume-snapshot-classes // +optional - VolumeSnapshotClassName *string `json:"snapshotClassName" protobuf:"bytes,3,opt,name=snapshotClassName"` + VolumeSnapshotClassName *string `json:"volumeSnapshotClassName,omitempty" protobuf:"bytes,3,opt,name=volumeSnapshotClassName"` } // VolumeSnapshotStatus is the status of the VolumeSnapshot type VolumeSnapshotStatus struct { - // CreationTime is the time the snapshot was successfully created. If it is set, - // it means the snapshot was created; Otherwise the snapshot was not created. - // +optional - CreationTime *metav1.Time `json:"creationTime" protobuf:"bytes,1,opt,name=creationTime"` + // NOTE: All fields in VolumeSnapshotStatus are informational for user references. + // Controllers MUST NOT rely on any fields programmatically. - // When restoring volume from the snapshot, the volume size should be equal to or - // larger than the RestoreSize if it is specified. If RestoreSize is set to nil, it means - // that the storage plugin does not have this information available. + // CreationTime, if not nil, represents the timestamp when a snapshot was successfully + // cut by the underlying storage system. In static binding, CreationTime might not be available. // +optional - RestoreSize *resource.Quantity `json:"restoreSize" protobuf:"bytes,2,opt,name=restoreSize"` + CreationTime *metav1.Time `json:"creationTime,omitempty" protobuf:"bytes,1,opt,name=creationTime"` - // ReadyToUse is set to true only if the snapshot is ready to use (e.g., finish uploading if - // there is an uploading phase) and also VolumeSnapshot and its VolumeSnapshotContent - // bind correctly with each other. If any of the above condition is not true, ReadyToUse is - // set to false - // +optional + // ReadyToUse is a status/informational flag which provides transparency to users. + // In the dynamic snapshot creation case, ReadyToUse will be set to true when underlying storage + // system has successfully finished all procedures out-of-bound to make a snapshot available AND + // snapshot controller has bound the VolumeSnapshot to a VolumeSnapshotContent successfully. ReadyToUse bool `json:"readyToUse" protobuf:"varint,3,opt,name=readyToUse"` - // The last error encountered during create snapshot operation, if any. - // This field must only be set by the entity completing the create snapshot - // operation, i.e. the external-snapshotter. + // RestoreSize, if not nil, represents the minimum volume size to restore from a VolumeSnapshot + // It is a storage system level property of a snapshot when the underlying storage system supports. + // The field could be nil if the underlying storage system does not have the information available, + // , or in cases like manual/static binding. + // +optional + RestoreSize *resource.Quantity `json:"restoreSize,omitempty" protobuf:"bytes,2,opt,name=restoreSize"` + + // The lastest observed error during snapshot creation operation, if any. // +optional Error *storage.VolumeError `json:"error,omitempty" protobuf:"bytes,4,opt,name=error,casttype=VolumeError"` } @@ -114,9 +127,11 @@ type VolumeSnapshotStatus struct { // +genclient:nonNamespaced // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// VolumeSnapshotClass describes the parameters used by storage system when -// provisioning VolumeSnapshots from PVCs. -// The name of a VolumeSnapshotClass object is significant, and is how users can request a particular class. +// VolumeSnapshotClass describes the parameters for a class of storage snapshotter +// for which VolumeSnapshot can be dynamically taken for a given PersistentVolumeClaim +// VolumeSnapshotClasses are non-namespaced. +// The name of a VolumeSnapshotClass object is significant, it serves as the unique identifier +// for a user to request a snapshot to be created using the specific VolumeSnapshotClass type VolumeSnapshotClass struct { metav1.TypeMeta `json:",inline"` // Standard object's metadata. @@ -124,24 +139,26 @@ type VolumeSnapshotClass struct { // +optional metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` - // Snapshotter is the driver expected to handle this VolumeSnapshotClass. + // Snapshotter is the name of the driver expected to handle VolumeSnapshot requests of this VolumeSnapshotClass. Snapshotter string `json:"snapshotter" protobuf:"bytes,2,opt,name=snapshotter"` - // Parameters holds parameters for the snapshotter. - // These values are opaque to the system and are passed directly - // to the snapshotter. + // Parameters holds parameters for underlying storage system. + // These values are opaque to Kubernetes. // +optional Parameters map[string]string `json:"parameters,omitempty" protobuf:"bytes,3,rep,name=parameters"` - // Optional: what happens to a snapshot content when released from its snapshot. - // The default policy is Delete if not specified. + // DeletionPolicy defines whether a VolumeSnapshotContent and its + // associated physical snapshot on underlying storage system + // should be deleted or not when released from its corresponding VolumeSnapshot. + // If not specified, the default will be VolumeSnapshotContentRetain for static binding, + // and VolumeSnapshotContentDelete for dynamic snapshot creation. // +optional DeletionPolicy *DeletionPolicy `json:"deletionPolicy,omitempty" protobuf:"bytes,4,opt,name=deletionPolicy"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// VolumeSnapshotClassList is a collection of snapshot classes. +// VolumeSnapshotClassList is a collection of VolumeSnapshotClasses. type VolumeSnapshotClassList struct { metav1.TypeMeta `json:",inline"` // Standard list metadata @@ -157,7 +174,8 @@ type VolumeSnapshotClassList struct { // +genclient:nonNamespaced // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// VolumeSnapshotContent represents the actual "on-disk" snapshot object +// VolumeSnapshotContent represents the actual "on-disk" snapshot object in the +// underlying storage system type VolumeSnapshotContent struct { metav1.TypeMeta `json:",inline"` // Standard object's metadata. @@ -181,30 +199,31 @@ type VolumeSnapshotContentList struct { Items []VolumeSnapshotContent `json:"items" protobuf:"bytes,2,rep,name=items"` } -// VolumeSnapshotContentSpec is the spec of the volume snapshot content +// VolumeSnapshotContentSpec is the specification of a VolumeSnapshotContent type VolumeSnapshotContentSpec struct { - // Source represents the location and type of the volume snapshot + // VolumeSnapshotSource holds critical metadata where the snapshot on underlying storage + // system has been created from. VolumeSnapshotSource `json:",inline" protobuf:"bytes,1,opt,name=volumeSnapshotSource"` // VolumeSnapshotRef is part of bi-directional binding between VolumeSnapshot - // and VolumeSnapshotContent. It becomes non-nil when bound. - // +optional - VolumeSnapshotRef *core_v1.ObjectReference `json:"volumeSnapshotRef" protobuf:"bytes,2,opt,name=volumeSnapshotRef"` - - // PersistentVolumeRef represents the PersistentVolume that the snapshot has been - // taken from. It becomes non-nil when VolumeSnapshot and VolumeSnapshotContent are bound. + // and VolumeSnapshotContent. + // Expect to be non-nil when bound. + // VolumeSnapshot.VolumeSnapshotContentName is the authoritative bind between VolumeSnapshot and VolumeSnapshotContent // +optional - PersistentVolumeRef *core_v1.ObjectReference `json:"persistentVolumeRef" protobuf:"bytes,3,opt,name=persistentVolumeRef"` + VolumeSnapshotRef *core_v1.ObjectReference `json:"volumeSnapshotRef,omitempty" protobuf:"bytes,2,opt,name=volumeSnapshotRef"` - // Name of the VolumeSnapshotClass used by the VolumeSnapshot. If not specified, a default snapshot class will - // be used if it is available. + // PersistentVolumeRef represents the PersistentVolume that the snapshot has been taken from. + // In dynamic snapshot creation case, the field will be specified when VolumeSnapshot and VolumeSnapshotContent are bound. // +optional - VolumeSnapshotClassName *string `json:"snapshotClassName" protobuf:"bytes,4,opt,name=snapshotClassName"` + PersistentVolumeRef *core_v1.ObjectReference `json:"persistentVolumeRef,omitempty" protobuf:"bytes,3,opt,name=persistentVolumeRef"` - // Optional: what happens to a snapshot content when released from its snapshot. It will be set to Delete by default - // if not specified + // DeletionPolicy defines whether a VolumeSnapshotContent and its + // associated physical snapshot on underlying storage system + // should be deleted or not when released from its corresponding VolumeSnapshot. + // If not specified, the default will be VolumeSnapshotContentRetain for static binding, + // and VolumeSnapshotContentDelete for dynamic snapshot creation. // +optional - DeletionPolicy *DeletionPolicy `json:"deletionPolicy" protobuf:"bytes,5,opt,name=deletionPolicy"` + DeletionPolicy *DeletionPolicy `json:"deletionPolicy,omitempty" protobuf:"bytes,5,opt,name=deletionPolicy"` } // VolumeSnapshotSource represents the actual location and type of the snapshot. Only one of its members may be specified. @@ -216,29 +235,34 @@ type VolumeSnapshotSource struct { // CSIVolumeSnapshotSource represents the source from CSI volume snapshot type CSIVolumeSnapshotSource struct { - // Driver is the name of the driver to use for this snapshot. + // Driver is the name of the driver used to create a physical snapshot on + // underlying storage system. // This MUST be the same name returned by the CSI GetPluginName() call for // that driver. // Required. Driver string `json:"driver" protobuf:"bytes,1,opt,name=driver"` - // SnapshotHandle is the unique snapshot id returned by the CSI volume - // plugin’s CreateSnapshot to refer to the snapshot on all subsequent calls. + // SnapshotHandle is the unique id returned from the underlying storage system + // by the CSI driver's CreationSnapshot gRPC call. It serves as the only and sufficient + // handle when communicating with underlying storage systems via CSI driver for + // all subsequent calls on the specific VolumeSnapshot // Required. SnapshotHandle string `json:"snapshotHandle" protobuf:"bytes,2,opt,name=snapshotHandle"` - // Timestamp when the point-in-time snapshot is taken on the storage - // system. This timestamp will be generated by the CSI volume driver after - // the snapshot is cut. The format of this field should be a Unix nanoseconds + // Timestamp when the point-in-time snapshot is taken by the underlying storage + // system. This timestamp will be generated and returned by the CSI volume driver after + // the snapshot is cut. 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. - // This field is required in the CSI spec but optional here to support static binding. + // the current time in nanoseconds (aka, epoch time) since 1970-01-01 00:00:00 UTC. + // This field is required in the CSI spec however made optional here to support static binding. // +optional CreationTime *int64 `json:"creationTime,omitempty" protobuf:"varint,3,opt,name=creationTime"` - // When restoring volume from the snapshot, the volume size should be equal to or - // larger than the RestoreSize if it is specified. If RestoreSize is set to nil, it means - // that the storage plugin does not have this information available. + // When restoring a volume from a snapshot, the volume size needs to be equal to or + // larger than the RestoreSize if it is specified. + // If RestoreSize is set to nil, in the dynamic snapshot creation case, it means + // that the underlying storage system does not have this information available; + // in the static binding case, this piece of information is not available. // +optional RestoreSize *int64 `json:"restoreSize,omitempty" protobuf:"bytes,4,opt,name=restoreSize"` } From 1eac944b73b9b144cbce60bb9be2315c8367e20b Mon Sep 17 00:00:00 2001 From: xiangqian Date: Fri, 23 Aug 2019 16:53:09 -0700 Subject: [PATCH 03/11] final adjustment on types.go based on feedback rename variable names in comments to follow OpenAPIV3Schema, enforces namespaced or cluster comments update feedback from Tim --- ....storage.k8s.io_volumesnapshotclasses.yaml | 39 ++-- ...storage.k8s.io_volumesnapshotcontents.yaml | 116 ++++-------- ...apshot.storage.k8s.io_volumesnapshots.yaml | 94 +++++----- pkg/apis/volumesnapshot/v1beta1/types.go | 172 +++++++++--------- 4 files changed, 200 insertions(+), 221 deletions(-) diff --git a/config/crd/snapshot.storage.k8s.io_volumesnapshotclasses.yaml b/config/crd/snapshot.storage.k8s.io_volumesnapshotclasses.yaml index 076df1f41..75dba2f39 100644 --- a/config/crd/snapshot.storage.k8s.io_volumesnapshotclasses.yaml +++ b/config/crd/snapshot.storage.k8s.io_volumesnapshotclasses.yaml @@ -10,14 +10,13 @@ spec: names: kind: VolumeSnapshotClass plural: volumesnapshotclasses - scope: "" + scope: Cluster validation: openAPIV3Schema: - description: VolumeSnapshotClass describes the parameters for a class of storage - snapshotter for which VolumeSnapshot can be dynamically taken for a given - PersistentVolumeClaim VolumeSnapshotClasses are non-namespaced. The name of - a VolumeSnapshotClass object is significant, it serves as the unique identifier - for a user to request a snapshot to be created using the specific VolumeSnapshotClass + description: VolumeSnapshotClass specifies parameters that a underlying storage + system uses when creating a volume snapshot. A specific VolumeSnapshotClass + is used by specifying its name in a VolumeSnapshot object. VolumeSnapshotClasses + are non-namespaced properties: apiVersion: description: 'APIVersion defines the versioned schema of this representation @@ -25,11 +24,19 @@ spec: internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources' type: string deletionPolicy: - description: DeletionPolicy defines whether a VolumeSnapshotContent and - its associated physical snapshot on underlying storage system should be - deleted or not when released from its corresponding VolumeSnapshot. If - not specified, the default will be VolumeSnapshotContentRetain for static - binding, and VolumeSnapshotContentDelete for dynamic snapshot creation. + description: deletionPolicy determines whether a VolumeSnapshotContent created + through the VolumeSnapshotClass should be deleted when its bound VolumeSnapshot + is deleted. Supported values are "Retain" and "Delete". "Retain" means + that the VolumeSnapshotContent and its physical snapshot on underlying + storage system are kept. "Delete" means that the VolumeSnapshotContent + and its physical snapshot on underlying storage system are deleted. If + not specified, the default value is "Delete" + enum: + - Delete + - Retain + type: string + driver: + description: driver is the name of the driver that handles this VolumeSnapshotClass. type: string kind: description: 'Kind is a string value representing the REST resource this @@ -42,15 +49,11 @@ spec: parameters: additionalProperties: type: string - description: Parameters holds parameters for underlying storage system. - These values are opaque to Kubernetes. + description: parameters is a key-value map with storage driver specific + parameters for creating snapshots. These values are opaque to Kubernetes. type: object - snapshotter: - description: Snapshotter is the name of the driver expected to handle VolumeSnapshot - requests of this VolumeSnapshotClass. - type: string required: - - snapshotter + - driver type: object version: v1beta1 versions: diff --git a/config/crd/snapshot.storage.k8s.io_volumesnapshotcontents.yaml b/config/crd/snapshot.storage.k8s.io_volumesnapshotcontents.yaml index e52973518..205499386 100644 --- a/config/crd/snapshot.storage.k8s.io_volumesnapshotcontents.yaml +++ b/config/crd/snapshot.storage.k8s.io_volumesnapshotcontents.yaml @@ -10,7 +10,7 @@ spec: names: kind: VolumeSnapshotContent plural: volumesnapshotcontents - scope: "" + scope: Cluster validation: openAPIV3Schema: description: VolumeSnapshotContent represents the actual "on-disk" snapshot @@ -30,100 +30,64 @@ spec: description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata' type: object spec: - description: Spec represents the desired state of the snapshot content + description: spec defines properties of a VolumeSnapshotContent created + by underlying storage system. properties: - csiVolumeSnapshotSource: - description: CSI (Container Storage Interface) represents storage that - handled by an external CSI Volume Driver (Alpha feature). + csi: + description: csi represents a volume snapshot created by a CSI(Container + Storage Interface) driver. properties: creationTime: - description: Timestamp when the point-in-time snapshot is taken - by the underlying storage system. This timestamp will be generated - and returned by the CSI volume driver after the snapshot is cut. - 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 (aka, epoch time) since 1970-01-01 00:00:00 - UTC. This field is required in the CSI spec however made optional - here to support static binding. + description: creationTime is the timestamp when the point-in-time + snapshot is taken by the underlying storage system. This timestamp + is returned by the CSI driver after the snapshot is cut. 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 (aka, epoch time) since 1970-01-01 00:00:00 UTC. format: int64 type: integer driver: - description: Driver is the name of the driver used to create a physical - snapshot on underlying storage system. This MUST be the same name - returned by the CSI GetPluginName() call for that driver. Required. + description: driver is the name of the CSI driver used to create + the physical snapshot on the underlying storage system. This MUST + be the same name returned by the CSI GetPluginName() call for + that driver. Required. type: string restoreSize: - description: When restoring a volume from a snapshot, the volume - size needs to be equal to or larger than the RestoreSize if it - is specified. If RestoreSize is set to nil, in the dynamic snapshot - creation case, it means that the underlying storage system does - not have this information available; in the static binding case, - this piece of information is not available. + description: restoreSize specifies the number of bytes that the + snapshot's data would consume when restored to a volume. When + restoring a volume from a snapshot, the volume size needs to be + equal to or larger than the RestoreSize if it is specified. format: int64 type: integer snapshotHandle: - description: SnapshotHandle is the unique id returned from the underlying - storage system by the CSI driver's CreationSnapshot gRPC call. - It serves as the only and sufficient handle when communicating - with underlying storage systems via CSI driver for all subsequent - calls on the specific VolumeSnapshot Required. + description: snapshotHandle is the snapshot id returned by the CSI + driver in the CreateSnapshotResponse and is used as the snapshot + identifier for all subsequent CSI calls. Required. type: string required: - driver - snapshotHandle type: object deletionPolicy: - description: DeletionPolicy defines whether a VolumeSnapshotContent - and its associated physical snapshot on underlying storage system - should be deleted or not when released from its corresponding VolumeSnapshot. - If not specified, the default will be VolumeSnapshotContentRetain - for static binding, and VolumeSnapshotContentDelete for dynamic snapshot - creation. + description: deletionPolicy determines whether this VolumeSnapshotContent + and its bound physical snapshot on the underlying storage system should + be deleted when its VolumeSnapshot is deleted. Supported values are + "Retain" and "Delete". "Retain" means that the VolumeSnapshotContent + and its physical snapshot on underlying storage system are kept. "Delete" + means that the VolumeSnapshotContent and its physical snapshot on + underlying storage system are deleted. If not specified, the default + value is "Retain" + enum: + - Delete + - Retain type: string - persistentVolumeRef: - description: PersistentVolumeRef represents the PersistentVolume that - the snapshot has been taken from. In dynamic snapshot creation case, - the field will be specified when VolumeSnapshot and VolumeSnapshotContent - are bound. - properties: - apiVersion: - description: API version of the referent. - type: string - fieldPath: - description: 'If referring to a piece of an object instead of an - entire object, this string should contain a valid JSON/Go field - access statement, such as desiredState.manifest.containers[2]. - For example, if the object reference is to a container within - a pod, this would take on a value like: "spec.containers{name}" - (where "name" refers to the name of the container that triggered - the event) or if no container name is specified "spec.containers[2]" - (container with index 2 in this pod). This syntax is chosen only - to have some well-defined way of referencing a part of an object. - TODO: this design is not final and this field is subject to change - in the future.' - type: string - kind: - description: 'Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds' - type: string - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names' - type: string - namespace: - description: 'Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/' - type: string - resourceVersion: - description: 'Specific resourceVersion to which this reference is - made, if any. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#concurrency-control-and-consistency' - type: string - uid: - description: 'UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids' - type: string - type: object volumeSnapshotRef: - description: VolumeSnapshotRef is part of bi-directional binding between - VolumeSnapshot and VolumeSnapshotContent. Expect to be non-nil when - bound. VolumeSnapshot.VolumeSnapshotContentName is the authoritative - bind between VolumeSnapshot and VolumeSnapshotContent + description: volumeSnapshotRef specifies the VolumeSnapshot object that + this VolumeSnapshotContent is bound with. The VolumeSnapshot.Spec.VolumeSnapshotContentName + field must reference this VolumeSnapshotContent name for the binding + to be considered valid(a.k.a bi-directional binding). If the referenced + VolumeSnapshot object does not exist(i.e., deleted by user), then + the VolumeSnapshotContent.Spec.DeletionPolicy is triggered. properties: apiVersion: description: API version of the referent. diff --git a/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml b/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml index f57eb387d..ba77c98dd 100644 --- a/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml +++ b/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml @@ -10,13 +10,12 @@ spec: names: kind: VolumeSnapshot plural: volumesnapshots - scope: "" + scope: Namespaced validation: openAPIV3Schema: - description: VolumeSnapshot is a user's request for taking a point in time snapshot - of a volume. Upon successful creation of the snapshot by the volume provider, - it is bound to a corresponding VolumeSnapshotContent. VolumeSnapshot objects - are namespaced + description: VolumeSnapshot is a user's request for taking a point-in-time snapshot + of a PersistentVolumeClaim. Upon successful creation of a snapshot by the + underlying storage system, it is bound to a corresponding VolumeSnapshotContent. properties: apiVersion: description: 'APIVersion defines the versioned schema of this representation @@ -32,16 +31,16 @@ spec: description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata' type: object spec: - description: 'Spec defines the desired characteristics of a snapshot requested + description: 'spec defines the desired characteristics of a snapshot requested by a user. More info: https:s//kubernetes.io/docs/concepts/storage/volume-snapshots#volumesnapshots' properties: source: - description: Source has the information about where a snapshot should - be created from. Currently PersistentVolumeClaim is the only supported - source type. If specified, and VolumeSnapshotContentName is not specified - (i.e., nil), snapshot will be dynamically created from the given source. - If not specified, user can statically bind a VolumeSnapshot to a VolumeSnapshotContent - by specifying VolumeSnapshotContentName. + description: source specifies where a snapshot should be created from. + Currently, PersistentVolumeClaim is the only supported source type. + If specified, and VolumeSnapshotContentName is not specified(i.e., + nil), snapshot will be dynamically created from the given source. + If not specified, and VolumeSnapshotContentName is not specified, + system controller will fail on dynamic snapshot creation. properties: apiGroup: description: APIGroup is the group for the resource being referenced. @@ -59,37 +58,44 @@ spec: - name type: object volumeSnapshotClassName: - description: 'Name of the VolumeSnapshotClass requested by the VolumeSnapshot. - If not specified, the default snapshot class will be used if there - exists one. More info: https://kubernetes.io/docs/concepts/storage/volume-snapshot-classes' + description: 'volumeSnapshotClassName is the name of the VolumeSnapshotClass + requested by the VolumeSnapshot. If not specified, the default snapshot + class will be used if there exists one. If not specified, and there + is no default snapshot class, dynamic VolumeSnapshot creation will + fail. More info: https://kubernetes.io/docs/concepts/storage/volume-snapshot-classes' type: string volumeSnapshotContentName: - description: VolumeSnapshotContentName is the binding reference to the - VolumeSnapshotContent backing the VolumeSnapshot. In dynamic snapshot - creation case, VolumeSnapshotContentName must NOT be specified. + description: volumeSnapshotContentName is the name of the VolumeSnapshotContent + object backing the VolumeSnapshot. To request a pre-existing VolumeSnapshotContent + object, this field MUST be specified during VolumeSnapshot object + creation. Otherwise, a snapshot will be dynamically created, and this + field will be populated afterwards. type: string type: object status: - description: 'Status represents the current status/information of a volume - snapshot. NOTE: Status is subjected to change by sources other than snapshot - controller, for example, undesired corruption from human operation - errors. It is only informational to provide necessary transparency - of a snapshot''s status to users. It is highly recommended not to - rely on this piece of information programmatically.' + description: 'status represents the current information of a snapshot. NOTE: + status can be modified by sources other than system controllers, and + must not be depended upon for accuracy. Controllers should only + be using information from the VolumeSnapshotContent object after + verifying that the binding is accurate and complete.' properties: creationTime: - description: CreationTime, if not nil, represents the timestamp when + description: 'creationTime, if not nil, represents the timestamp when a snapshot was successfully cut by the underlying storage system. - In static binding, CreationTime might not be available. + In static binding, CreationTime might not be available. NOTE: Controllers + MUST NOT rely on this field programmatically' format: date-time type: string error: - description: The lastest observed error during snapshot creation operation, - if any. + description: error is the latest observed error during snapshot creation, + if any. This field could be helpful to upper level controllers(i.e., + application controller) to decide whether they should continue on + waiting for the snapshot to be created based on the type of error + reported. properties: message: - description: String detailing the error encountered during Attach - or Detach operation. This string may be logged, so it should not + description: String detailing the error encountered during snapshot + creation. This string may be logged, so it should not contain sensitive information. type: string time: @@ -98,22 +104,24 @@ spec: type: string type: object readyToUse: - description: ReadyToUse is a status/informational flag which provides - transparency to users. In the dynamic snapshot creation case, ReadyToUse - will be set to true when underlying storage system has successfully - finished all procedures out-of-bound to make a snapshot available - AND snapshot controller has bound the VolumeSnapshot to a VolumeSnapshotContent - successfully. + description: 'readyToUse is an informational flag which provides transparency + to users. In dynamic snapshot creation case, ReadyToUse will be set + to true when underlying storage system has successfully finished all + procedures out-of-bound to make a snapshot available AND snapshot + controller has bound the VolumeSnapshot to a VolumeSnapshotContent + successfully. If not specified(i.e., nil), it means the readiness + of the VolumeSnapshot is unknown to system controllers. NOTE: Controllers + MUST NOT rely on this field programmatically' type: boolean restoreSize: - description: RestoreSize, if not nil, represents the minimum volume - size to restore from a VolumeSnapshot It is a storage system level - property of a snapshot when the underlying storage system supports. - The field could be nil if the underlying storage system does not have - the information available, , or in cases like manual/static binding. + description: 'restoreSize specifies the number of bytes that the snapshot''s + data would consume when restored to a volume. When restoring a volume + from a snapshot, the volume size needs to be equal to or larger than + the RestoreSize if it is specified. The field could be nil if the + underlying storage system does not have the information available, + or in cases like static binding. NOTE: Controllers MUST NOT rely on + this field programmatically' type: string - required: - - readyToUse type: object type: object version: v1beta1 diff --git a/pkg/apis/volumesnapshot/v1beta1/types.go b/pkg/apis/volumesnapshot/v1beta1/types.go index a5d859037..91ed9aff8 100644 --- a/pkg/apis/volumesnapshot/v1beta1/types.go +++ b/pkg/apis/volumesnapshot/v1beta1/types.go @@ -23,22 +23,14 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -const ( - // VolumeSnapshotContentResourcePlural is "volumesnapshotcontents" - VolumeSnapshotContentResourcePlural = "volumesnapshotcontents" - // VolumeSnapshotResourcePlural is "volumesnapshots" - VolumeSnapshotResourcePlural = "volumesnapshots" - // VolumeSnapshotClassResourcePlural is "volumesnapshotclasses" - VolumeSnapshotClassResourcePlural = "volumesnapshotclasses" -) - // +genclient // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// VolumeSnapshot is a user's request for taking a point in time snapshot of a volume. -// Upon successful creation of the snapshot by the volume provider, it is bound to a +// VolumeSnapshot is a user's request for taking a point-in-time snapshot of a PersistentVolumeClaim. +// Upon successful creation of a snapshot by the underlying storage system, it is bound to a // corresponding VolumeSnapshotContent. -// VolumeSnapshot objects are namespaced +// +kubebuilder:object:root=true +// +kubebuilder:resource:scope=Namespaced type VolumeSnapshot struct { metav1.TypeMeta `json:",inline"` // Standard object's metadata. @@ -46,16 +38,16 @@ type VolumeSnapshot struct { // +optional metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` - // Spec defines the desired characteristics of a snapshot requested by a user. + // spec defines the desired characteristics of a snapshot requested by a user. // More info: https:s//kubernetes.io/docs/concepts/storage/volume-snapshots#volumesnapshots // +optional Spec VolumeSnapshotSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` - // Status represents the current status/information of a volume snapshot. - // NOTE: Status is subjected to change by sources other than snapshot controller, - // for example, undesired corruption from human operation errors. It is only informational to - // provide necessary transparency of a snapshot's status to users. It is highly recommended - // not to rely on this piece of information programmatically. + // status represents the current information of a snapshot. + // NOTE: status can be modified by sources other than system controllers, + // and must not be depended upon for accuracy. + // Controllers should only be using information from the VolumeSnapshotContent object + // after verifying that the binding is accurate and complete. // +optional Status VolumeSnapshotStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` } @@ -74,51 +66,66 @@ type VolumeSnapshotList struct { // VolumeSnapshotSpec describes the common attributes of a volume snapshot type VolumeSnapshotSpec struct { - // Source has the information about where a snapshot should be created from. - // Currently PersistentVolumeClaim is the only supported source type. - // If specified, and VolumeSnapshotContentName is not specified (i.e., nil), + // source specifies where a snapshot should be created from. + // Currently, PersistentVolumeClaim is the only supported source type. + // If specified, and VolumeSnapshotContentName is not specified(i.e., nil), // snapshot will be dynamically created from the given source. - // If not specified, user can statically bind a VolumeSnapshot to a - // VolumeSnapshotContent by specifying VolumeSnapshotContentName. + // If not specified, and VolumeSnapshotContentName is not specified, system + // controller will fail on dynamic snapshot creation. // +optional Source *core_v1.TypedLocalObjectReference `json:"source,omitempty" protobuf:"bytes,1,opt,name=source"` - // VolumeSnapshotContentName is the binding reference to the VolumeSnapshotContent backing the VolumeSnapshot. - // In dynamic snapshot creation case, VolumeSnapshotContentName must NOT be specified. + // volumeSnapshotContentName is the name of the VolumeSnapshotContent object backing the VolumeSnapshot. + // To request a pre-existing VolumeSnapshotContent object, this field MUST be specified during + // VolumeSnapshot object creation. Otherwise, a snapshot will be dynamically created, and this field will + // be populated afterwards. // +optional VolumeSnapshotContentName *string `json:"volumeSnapshotContentName,omitempty" protobuf:"bytes,2,opt,name=volumeSnapshotContentName"` - // Name of the VolumeSnapshotClass requested by the VolumeSnapshot. + // volumeSnapshotClassName is the name of the VolumeSnapshotClass requested by the VolumeSnapshot. // If not specified, the default snapshot class will be used if there exists one. + // If not specified, and there is no default snapshot class, dynamic VolumeSnapshot creation will fail. // More info: https://kubernetes.io/docs/concepts/storage/volume-snapshot-classes // +optional VolumeSnapshotClassName *string `json:"volumeSnapshotClassName,omitempty" protobuf:"bytes,3,opt,name=volumeSnapshotClassName"` } // VolumeSnapshotStatus is the status of the VolumeSnapshot +// +kubebuilder:subresource:status type VolumeSnapshotStatus struct { // NOTE: All fields in VolumeSnapshotStatus are informational for user references. // Controllers MUST NOT rely on any fields programmatically. - // CreationTime, if not nil, represents the timestamp when a snapshot was successfully - // cut by the underlying storage system. In static binding, CreationTime might not be available. + // creationTime, if not nil, represents the timestamp when a snapshot was successfully + // cut by the underlying storage system. + // In static binding, CreationTime might not be available. + // NOTE: Controllers MUST NOT rely on this field programmatically // +optional CreationTime *metav1.Time `json:"creationTime,omitempty" protobuf:"bytes,1,opt,name=creationTime"` - // ReadyToUse is a status/informational flag which provides transparency to users. - // In the dynamic snapshot creation case, ReadyToUse will be set to true when underlying storage + // readyToUse is an informational flag which provides transparency to users. + // In dynamic snapshot creation case, ReadyToUse will be set to true when underlying storage // system has successfully finished all procedures out-of-bound to make a snapshot available AND // snapshot controller has bound the VolumeSnapshot to a VolumeSnapshotContent successfully. - ReadyToUse bool `json:"readyToUse" protobuf:"varint,3,opt,name=readyToUse"` + // If not specified(i.e., nil), it means the readiness of the VolumeSnapshot is unknown to system controllers. + // NOTE: Controllers MUST NOT rely on this field programmatically + // +optional + ReadyToUse *bool `json:"readyToUse,omitempty" protobuf:"varint,3,opt,name=readyToUse"` - // RestoreSize, if not nil, represents the minimum volume size to restore from a VolumeSnapshot - // It is a storage system level property of a snapshot when the underlying storage system supports. + // restoreSize specifies the number of bytes that the snapshot's data would consume when + // restored to a volume. + // When restoring a volume from a snapshot, the volume size needs to be equal to or + // larger than the RestoreSize if it is specified. // The field could be nil if the underlying storage system does not have the information available, - // , or in cases like manual/static binding. + // or in cases like static binding. + // NOTE: Controllers MUST NOT rely on this field programmatically // +optional RestoreSize *resource.Quantity `json:"restoreSize,omitempty" protobuf:"bytes,2,opt,name=restoreSize"` - // The lastest observed error during snapshot creation operation, if any. + // error is the latest observed error during snapshot creation, if any. + // This field could be helpful to upper level controllers(i.e., application controller) + // to decide whether they should continue on waiting for the snapshot to be created + // based on the type of error reported. // +optional Error *storage.VolumeError `json:"error,omitempty" protobuf:"bytes,4,opt,name=error,casttype=VolumeError"` } @@ -127,11 +134,12 @@ type VolumeSnapshotStatus struct { // +genclient:nonNamespaced // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// VolumeSnapshotClass describes the parameters for a class of storage snapshotter -// for which VolumeSnapshot can be dynamically taken for a given PersistentVolumeClaim -// VolumeSnapshotClasses are non-namespaced. -// The name of a VolumeSnapshotClass object is significant, it serves as the unique identifier -// for a user to request a snapshot to be created using the specific VolumeSnapshotClass +// VolumeSnapshotClass specifies parameters that a underlying storage system uses when +// creating a volume snapshot. A specific VolumeSnapshotClass is used by specifying its +// name in a VolumeSnapshot object. +// VolumeSnapshotClasses are non-namespaced +// +kubebuilder:object:root=true +// +kubebuilder:resource:scope=Cluster type VolumeSnapshotClass struct { metav1.TypeMeta `json:",inline"` // Standard object's metadata. @@ -139,19 +147,20 @@ type VolumeSnapshotClass struct { // +optional metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` - // Snapshotter is the name of the driver expected to handle VolumeSnapshot requests of this VolumeSnapshotClass. - Snapshotter string `json:"snapshotter" protobuf:"bytes,2,opt,name=snapshotter"` + // driver is the name of the driver that handles this VolumeSnapshotClass. + Driver string `json:"driver" protobuf:"bytes,2,opt,name=driver"` - // Parameters holds parameters for underlying storage system. + // parameters is a key-value map with storage driver specific parameters for creating snapshots. // These values are opaque to Kubernetes. // +optional Parameters map[string]string `json:"parameters,omitempty" protobuf:"bytes,3,rep,name=parameters"` - // DeletionPolicy defines whether a VolumeSnapshotContent and its - // associated physical snapshot on underlying storage system - // should be deleted or not when released from its corresponding VolumeSnapshot. - // If not specified, the default will be VolumeSnapshotContentRetain for static binding, - // and VolumeSnapshotContentDelete for dynamic snapshot creation. + // deletionPolicy determines whether a VolumeSnapshotContent created through the VolumeSnapshotClass should + // be deleted when its bound VolumeSnapshot is deleted. + // Supported values are "Retain" and "Delete". + // "Retain" means that the VolumeSnapshotContent and its physical snapshot on underlying storage system are kept. + // "Delete" means that the VolumeSnapshotContent and its physical snapshot on underlying storage system are deleted. + // If not specified, the default value is "Delete" // +optional DeletionPolicy *DeletionPolicy `json:"deletionPolicy,omitempty" protobuf:"bytes,4,opt,name=deletionPolicy"` } @@ -166,7 +175,7 @@ type VolumeSnapshotClassList struct { // +optional metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` - // Items is the list of VolumeSnapshotClasses + // items is the list of VolumeSnapshotClasses Items []VolumeSnapshotClass `json:"items" protobuf:"bytes,2,rep,name=items"` } @@ -176,6 +185,8 @@ type VolumeSnapshotClassList struct { // VolumeSnapshotContent represents the actual "on-disk" snapshot object in the // underlying storage system +// +kubebuilder:object:root=true +// +kubebuilder:resource:scope=Cluster type VolumeSnapshotContent struct { metav1.TypeMeta `json:",inline"` // Standard object's metadata. @@ -183,7 +194,7 @@ type VolumeSnapshotContent struct { // +optional metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` - // Spec represents the desired state of the snapshot content + // spec defines properties of a VolumeSnapshotContent created by underlying storage system. Spec VolumeSnapshotContentSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"` } @@ -195,86 +206,79 @@ type VolumeSnapshotContentList struct { // +optional metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` - // Items is the list of VolumeSnapshotContents + // items is the list of VolumeSnapshotContents Items []VolumeSnapshotContent `json:"items" protobuf:"bytes,2,rep,name=items"` } // VolumeSnapshotContentSpec is the specification of a VolumeSnapshotContent type VolumeSnapshotContentSpec struct { - // VolumeSnapshotSource holds critical metadata where the snapshot on underlying storage + // volumeSnapshotSource holds critical metadata where the snapshot on underlying storage // system has been created from. VolumeSnapshotSource `json:",inline" protobuf:"bytes,1,opt,name=volumeSnapshotSource"` - // VolumeSnapshotRef is part of bi-directional binding between VolumeSnapshot - // and VolumeSnapshotContent. - // Expect to be non-nil when bound. - // VolumeSnapshot.VolumeSnapshotContentName is the authoritative bind between VolumeSnapshot and VolumeSnapshotContent + // volumeSnapshotRef specifies the VolumeSnapshot object that this VolumeSnapshotContent is bound with. + // The VolumeSnapshot.Spec.VolumeSnapshotContentName field must reference this VolumeSnapshotContent name for the + // binding to be considered valid(a.k.a bi-directional binding). If the referenced VolumeSnapshot object does not + // exist(i.e., deleted by user), then the VolumeSnapshotContent.Spec.DeletionPolicy is triggered. // +optional VolumeSnapshotRef *core_v1.ObjectReference `json:"volumeSnapshotRef,omitempty" protobuf:"bytes,2,opt,name=volumeSnapshotRef"` - // PersistentVolumeRef represents the PersistentVolume that the snapshot has been taken from. - // In dynamic snapshot creation case, the field will be specified when VolumeSnapshot and VolumeSnapshotContent are bound. - // +optional - PersistentVolumeRef *core_v1.ObjectReference `json:"persistentVolumeRef,omitempty" protobuf:"bytes,3,opt,name=persistentVolumeRef"` - - // DeletionPolicy defines whether a VolumeSnapshotContent and its - // associated physical snapshot on underlying storage system - // should be deleted or not when released from its corresponding VolumeSnapshot. - // If not specified, the default will be VolumeSnapshotContentRetain for static binding, - // and VolumeSnapshotContentDelete for dynamic snapshot creation. + // deletionPolicy determines whether this VolumeSnapshotContent and its bound physical snapshot on + // the underlying storage system should be deleted when its VolumeSnapshot is deleted. + // Supported values are "Retain" and "Delete". + // "Retain" means that the VolumeSnapshotContent and its physical snapshot on underlying storage system are kept. + // "Delete" means that the VolumeSnapshotContent and its physical snapshot on underlying storage system are deleted. + // If not specified, the default value is "Retain" // +optional DeletionPolicy *DeletionPolicy `json:"deletionPolicy,omitempty" protobuf:"bytes,5,opt,name=deletionPolicy"` } // VolumeSnapshotSource represents the actual location and type of the snapshot. Only one of its members may be specified. type VolumeSnapshotSource struct { - // CSI (Container Storage Interface) represents storage that handled by an external CSI Volume Driver (Alpha feature). + // csi represents a volume snapshot created by a CSI(Container Storage Interface) driver. // +optional - CSI *CSIVolumeSnapshotSource `json:"csiVolumeSnapshotSource,omitempty"` + CSI *CSIVolumeSnapshotSource `json:"csi,omitempty"` } // CSIVolumeSnapshotSource represents the source from CSI volume snapshot type CSIVolumeSnapshotSource struct { - // Driver is the name of the driver used to create a physical snapshot on - // underlying storage system. + // driver is the name of the CSI driver used to create the physical snapshot on + // the underlying storage system. // This MUST be the same name returned by the CSI GetPluginName() call for // that driver. // Required. Driver string `json:"driver" protobuf:"bytes,1,opt,name=driver"` - // SnapshotHandle is the unique id returned from the underlying storage system - // by the CSI driver's CreationSnapshot gRPC call. It serves as the only and sufficient - // handle when communicating with underlying storage systems via CSI driver for - // all subsequent calls on the specific VolumeSnapshot + // snapshotHandle is the snapshot id returned by the CSI driver in the CreateSnapshotResponse + // and is used as the snapshot identifier for all subsequent CSI calls. // Required. SnapshotHandle string `json:"snapshotHandle" protobuf:"bytes,2,opt,name=snapshotHandle"` - // Timestamp when the point-in-time snapshot is taken by the underlying storage - // system. This timestamp will be generated and returned by the CSI volume driver after - // the snapshot is cut. The format of this field is a Unix nanoseconds - // time encoded as an int64. On Unix, the command `date +%s%N` returns + // creationTime is the timestamp when the point-in-time snapshot is taken by the underlying storage + // system. This timestamp is returned by the CSI driver after the snapshot is cut. + // 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 (aka, epoch time) since 1970-01-01 00:00:00 UTC. - // This field is required in the CSI spec however made optional here to support static binding. // +optional CreationTime *int64 `json:"creationTime,omitempty" protobuf:"varint,3,opt,name=creationTime"` + // restoreSize specifies the number of bytes that the snapshot's data would consume when + // restored to a volume. // When restoring a volume from a snapshot, the volume size needs to be equal to or // larger than the RestoreSize if it is specified. - // If RestoreSize is set to nil, in the dynamic snapshot creation case, it means - // that the underlying storage system does not have this information available; - // in the static binding case, this piece of information is not available. // +optional RestoreSize *int64 `json:"restoreSize,omitempty" protobuf:"bytes,4,opt,name=restoreSize"` } // DeletionPolicy describes a policy for end-of-life maintenance of volume snapshot contents +// +kubebuilder:validation:Enum=Delete;Retain type DeletionPolicy string const ( - // VolumeSnapshotContentDelete means the snapshot content will be deleted from Kubernetes on release from its volume snapshot. + // volumeSnapshotContentDelete means the snapshot content will be deleted from Kubernetes on release from its volume snapshot. VolumeSnapshotContentDelete DeletionPolicy = "Delete" - // VolumeSnapshotContentRetain means the snapshot will be left in its current state on release from its volume snapshot. + // volumeSnapshotContentRetain means the snapshot will be left in its current state on release from its volume snapshot. // The default policy is Retain if not specified. VolumeSnapshotContentRetain DeletionPolicy = "Retain" ) From 5e4324057ec54edfc7e5cebfe1718aea4bb94127 Mon Sep 17 00:00:00 2001 From: Xing Yang Date: Thu, 11 Jul 2019 12:32:07 -0700 Subject: [PATCH 04/11] Update VolumeSnapshot CRD version to v1beta --- cmd/csi-snapshotter/create_crd.go | 2 +- cmd/csi-snapshotter/main.go | 6 +- ....storage.k8s.io_volumesnapshotclasses.yaml | 59 ++++++ ...storage.k8s.io_volumesnapshotcontents.yaml | 170 ++++++++++++++++++ ...apshot.storage.k8s.io_volumesnapshots.yaml | 121 +++++++++++++ hack/update-generated-code.sh | 2 +- .../{v1alpha1 => v1beta1}/doc.go | 2 +- .../{v1alpha1 => v1beta1}/register.go | 4 +- .../{v1alpha1 => v1beta1}/types.go | 2 +- .../zz_generated.deepcopy.go | 6 +- pkg/client/clientset/versioned/clientset.go | 18 +- .../versioned/fake/clientset_generated.go | 10 +- .../clientset/versioned/fake/register.go | 4 +- .../clientset/versioned/scheme/register.go | 4 +- .../{v1alpha1 => v1beta1}/doc.go | 2 +- .../{v1alpha1 => v1beta1}/fake/doc.go | 0 .../fake/fake_volumesnapshot.go | 50 +++--- .../fake/fake_volumesnapshot_client.go | 12 +- .../fake/fake_volumesnapshotclass.go | 44 ++--- .../fake/fake_volumesnapshotcontent.go | 44 ++--- .../generated_expansion.go | 2 +- .../{v1alpha1 => v1beta1}/volumesnapshot.go | 42 ++--- .../volumesnapshot_client.go | 36 ++-- .../volumesnapshotclass.go | 36 ++-- .../volumesnapshotcontent.go | 36 ++-- .../informers/externalversions/generic.go | 16 +- .../volumesnapshot/interface.go | 12 +- .../{v1alpha1 => v1beta1}/interface.go | 2 +- .../{v1alpha1 => v1beta1}/volumesnapshot.go | 20 +-- .../volumesnapshotclass.go | 20 +-- .../volumesnapshotcontent.go | 20 +-- .../expansion_generated.go | 2 +- .../{v1alpha1 => v1beta1}/volumesnapshot.go | 24 +-- .../volumesnapshotclass.go | 18 +- .../volumesnapshotcontent.go | 18 +- pkg/controller/csi_handler.go | 2 +- pkg/controller/framework_test.go | 14 +- pkg/controller/snapshot_controller.go | 30 ++-- pkg/controller/snapshot_controller_base.go | 6 +- pkg/controller/snapshot_controller_test.go | 2 +- pkg/controller/snapshot_create_test.go | 4 +- pkg/controller/snapshot_delete_test.go | 4 +- pkg/controller/snapshot_ready_test.go | 2 +- pkg/controller/util.go | 2 +- pkg/controller/util_test.go | 2 +- 45 files changed, 642 insertions(+), 292 deletions(-) create mode 100644 config/crd/snapshot.storage.k8s.io_volumesnapshotclasses.yaml create mode 100644 config/crd/snapshot.storage.k8s.io_volumesnapshotcontents.yaml create mode 100644 config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml rename pkg/apis/volumesnapshot/{v1alpha1 => v1beta1}/doc.go (97%) rename pkg/apis/volumesnapshot/{v1alpha1 => v1beta1}/register.go (98%) rename pkg/apis/volumesnapshot/{v1alpha1 => v1beta1}/types.go (99%) rename pkg/apis/volumesnapshot/{v1alpha1 => v1beta1}/zz_generated.deepcopy.go (99%) rename pkg/client/clientset/versioned/typed/volumesnapshot/{v1alpha1 => v1beta1}/doc.go (97%) rename pkg/client/clientset/versioned/typed/volumesnapshot/{v1alpha1 => v1beta1}/fake/doc.go (100%) rename pkg/client/clientset/versioned/typed/volumesnapshot/{v1alpha1 => v1beta1}/fake/fake_volumesnapshot.go (70%) rename pkg/client/clientset/versioned/typed/volumesnapshot/{v1alpha1 => v1beta1}/fake/fake_volumesnapshot_client.go (66%) rename pkg/client/clientset/versioned/typed/volumesnapshot/{v1alpha1 => v1beta1}/fake/fake_volumesnapshotclass.go (72%) rename pkg/client/clientset/versioned/typed/volumesnapshot/{v1alpha1 => v1beta1}/fake/fake_volumesnapshotcontent.go (71%) rename pkg/client/clientset/versioned/typed/volumesnapshot/{v1alpha1 => v1beta1}/generated_expansion.go (97%) rename pkg/client/clientset/versioned/typed/volumesnapshot/{v1alpha1 => v1beta1}/volumesnapshot.go (77%) rename pkg/client/clientset/versioned/typed/volumesnapshot/{v1alpha1 => v1beta1}/volumesnapshot_client.go (61%) rename pkg/client/clientset/versioned/typed/volumesnapshot/{v1alpha1 => v1beta1}/volumesnapshotclass.go (79%) rename pkg/client/clientset/versioned/typed/volumesnapshot/{v1alpha1 => v1beta1}/volumesnapshotcontent.go (80%) rename pkg/client/informers/externalversions/volumesnapshot/{v1alpha1 => v1beta1}/interface.go (99%) rename pkg/client/informers/externalversions/volumesnapshot/{v1alpha1 => v1beta1}/volumesnapshot.go (81%) rename pkg/client/informers/externalversions/volumesnapshot/{v1alpha1 => v1beta1}/volumesnapshotclass.go (81%) rename pkg/client/informers/externalversions/volumesnapshot/{v1alpha1 => v1beta1}/volumesnapshotcontent.go (81%) rename pkg/client/listers/volumesnapshot/{v1alpha1 => v1beta1}/expansion_generated.go (98%) rename pkg/client/listers/volumesnapshot/{v1alpha1 => v1beta1}/volumesnapshot.go (79%) rename pkg/client/listers/volumesnapshot/{v1alpha1 => v1beta1}/volumesnapshotclass.go (75%) rename pkg/client/listers/volumesnapshot/{v1alpha1 => v1beta1}/volumesnapshotcontent.go (74%) diff --git a/cmd/csi-snapshotter/create_crd.go b/cmd/csi-snapshotter/create_crd.go index 0460f691f..36fb8ae8d 100644 --- a/cmd/csi-snapshotter/create_crd.go +++ b/cmd/csi-snapshotter/create_crd.go @@ -16,7 +16,7 @@ package main import ( "reflect" - crdv1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + crdv1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" apiextensionsclient "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" apierrors "k8s.io/apimachinery/pkg/api/errors" diff --git a/cmd/csi-snapshotter/main.go b/cmd/csi-snapshotter/main.go index df1b11663..6e6b3cdc7 100644 --- a/cmd/csi-snapshotter/main.go +++ b/cmd/csi-snapshotter/main.go @@ -185,9 +185,9 @@ func main() { snapClient, kubeClient, *snapshotterName, - factory.Snapshot().V1alpha1().VolumeSnapshots(), - factory.Snapshot().V1alpha1().VolumeSnapshotContents(), - factory.Snapshot().V1alpha1().VolumeSnapshotClasses(), + factory.Snapshot().V1beta1().VolumeSnapshots(), + factory.Snapshot().V1beta1().VolumeSnapshotContents(), + factory.Snapshot().V1beta1().VolumeSnapshotClasses(), coreFactory.Core().V1().PersistentVolumeClaims(), *createSnapshotContentRetryCount, *createSnapshotContentInterval, diff --git a/config/crd/snapshot.storage.k8s.io_volumesnapshotclasses.yaml b/config/crd/snapshot.storage.k8s.io_volumesnapshotclasses.yaml new file mode 100644 index 000000000..f4e83af9f --- /dev/null +++ b/config/crd/snapshot.storage.k8s.io_volumesnapshotclasses.yaml @@ -0,0 +1,59 @@ + +--- +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + creationTimestamp: null + name: volumesnapshotclasses.snapshot.storage.k8s.io +spec: + group: snapshot.storage.k8s.io + names: + kind: VolumeSnapshotClass + plural: volumesnapshotclasses + scope: "" + version: v1beta1 + versions: + - name: v1beta1 + schema: + openAPIV3Schema: + description: VolumeSnapshotClass describes the parameters used by storage + system when provisioning VolumeSnapshots from PVCs. The name of a VolumeSnapshotClass + object is significant, and is how users can request a particular class. + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources' + type: string + deletionPolicy: + description: 'Optional: what happens to a snapshot content when released + from its snapshot. The default policy is Delete if not specified.' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds' + type: string + metadata: + description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata' + type: object + parameters: + additionalProperties: + type: string + description: Parameters holds parameters for the snapshotter. These values + are opaque to the system and are passed directly to the snapshotter. + type: object + snapshotter: + description: Snapshotter is the driver expected to handle this VolumeSnapshotClass. + type: string + required: + - snapshotter + type: object + served: true + storage: true +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] diff --git a/config/crd/snapshot.storage.k8s.io_volumesnapshotcontents.yaml b/config/crd/snapshot.storage.k8s.io_volumesnapshotcontents.yaml new file mode 100644 index 000000000..5b9b8379a --- /dev/null +++ b/config/crd/snapshot.storage.k8s.io_volumesnapshotcontents.yaml @@ -0,0 +1,170 @@ + +--- +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + creationTimestamp: null + name: volumesnapshotcontents.snapshot.storage.k8s.io +spec: + group: snapshot.storage.k8s.io + names: + kind: VolumeSnapshotContent + plural: volumesnapshotcontents + scope: "" + version: v1beta1 + versions: + - name: v1beta1 + schema: + openAPIV3Schema: + description: VolumeSnapshotContent represents the actual "on-disk" snapshot + object + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds' + type: string + metadata: + description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata' + type: object + spec: + description: Spec represents the desired state of the snapshot content + properties: + csiVolumeSnapshotSource: + description: CSI (Container Storage Interface) represents storage + that handled by an external CSI Volume Driver (Alpha feature). + properties: + creationTime: + description: Timestamp when the point-in-time snapshot is taken + on the storage system. This timestamp will be generated by the + CSI volume driver after the snapshot is cut. The format of this + field should be 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. This field is + required in the CSI spec but optional here to support static + binding. + format: int64 + type: integer + driver: + description: Driver is the name of the driver to use for this + snapshot. This MUST be the same name returned by the CSI GetPluginName() + call for that driver. Required. + type: string + restoreSize: + description: When restoring volume from the snapshot, the volume + size should be equal to or larger than the RestoreSize if it + is specified. If RestoreSize is set to nil, it means that the + storage plugin does not have this information available. + format: int64 + type: integer + snapshotHandle: + description: SnapshotHandle is the unique snapshot id returned + by the CSI volume plugin’s CreateSnapshot to refer to the snapshot + on all subsequent calls. Required. + type: string + required: + - driver + - snapshotHandle + type: object + deletionPolicy: + description: 'Optional: what happens to a snapshot content when released + from its snapshot. It will be set to Delete by default if not specified' + type: string + persistentVolumeRef: + description: PersistentVolumeRef represents the PersistentVolume that + the snapshot has been taken from. It becomes non-nil when VolumeSnapshot + and VolumeSnapshotContent are bound. + properties: + apiVersion: + description: API version of the referent. + type: string + fieldPath: + description: 'If referring to a piece of an object instead of + an entire object, this string should contain a valid JSON/Go + field access statement, such as desiredState.manifest.containers[2]. + For example, if the object reference is to a container within + a pod, this would take on a value like: "spec.containers{name}" + (where "name" refers to the name of the container that triggered + the event) or if no container name is specified "spec.containers[2]" + (container with index 2 in this pod). This syntax is chosen + only to have some well-defined way of referencing a part of + an object. TODO: this design is not final and this field is + subject to change in the future.' + type: string + kind: + description: 'Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds' + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names' + type: string + namespace: + description: 'Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/' + type: string + resourceVersion: + description: 'Specific resourceVersion to which this reference + is made, if any. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#concurrency-control-and-consistency' + type: string + uid: + description: 'UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids' + type: string + type: object + snapshotClassName: + description: Name of the VolumeSnapshotClass used by the VolumeSnapshot. + If not specified, a default snapshot class will be used if it is + available. + type: string + volumeSnapshotRef: + description: VolumeSnapshotRef is part of bi-directional binding between + VolumeSnapshot and VolumeSnapshotContent. It becomes non-nil when + bound. + properties: + apiVersion: + description: API version of the referent. + type: string + fieldPath: + description: 'If referring to a piece of an object instead of + an entire object, this string should contain a valid JSON/Go + field access statement, such as desiredState.manifest.containers[2]. + For example, if the object reference is to a container within + a pod, this would take on a value like: "spec.containers{name}" + (where "name" refers to the name of the container that triggered + the event) or if no container name is specified "spec.containers[2]" + (container with index 2 in this pod). This syntax is chosen + only to have some well-defined way of referencing a part of + an object. TODO: this design is not final and this field is + subject to change in the future.' + type: string + kind: + description: 'Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds' + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names' + type: string + namespace: + description: 'Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/' + type: string + resourceVersion: + description: 'Specific resourceVersion to which this reference + is made, if any. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#concurrency-control-and-consistency' + type: string + uid: + description: 'UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids' + type: string + type: object + type: object + required: + - spec + type: object + served: true + storage: true +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] diff --git a/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml b/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml new file mode 100644 index 000000000..7b4182456 --- /dev/null +++ b/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml @@ -0,0 +1,121 @@ + +--- +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + creationTimestamp: null + name: volumesnapshots.snapshot.storage.k8s.io +spec: + group: snapshot.storage.k8s.io + names: + kind: VolumeSnapshot + plural: volumesnapshots + scope: "" + version: v1beta1 + versions: + - name: v1beta1 + schema: + openAPIV3Schema: + description: VolumeSnapshot is a user's request for taking a snapshot. Upon + successful creation of the actual snapshot by the volume provider it is + bound to the corresponding VolumeSnapshotContent. Only the VolumeSnapshot + object is accessible to the user in the namespace. + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds' + type: string + metadata: + description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata' + type: object + spec: + description: Spec defines the desired characteristics of a snapshot requested + by a user. + properties: + snapshotClassName: + description: Name of the VolumeSnapshotClass used by the VolumeSnapshot. + If not specified, a default snapshot class will be used if it is + available. + type: string + snapshotContentName: + description: SnapshotContentName binds the VolumeSnapshot object with + the VolumeSnapshotContent + type: string + source: + description: Source has the information about where the snapshot is + created from. In Alpha version, only PersistentVolumeClaim is supported + as the source. If not specified, user can create VolumeSnapshotContent + and bind it with VolumeSnapshot manually. + properties: + apiGroup: + description: APIGroup is the group for the resource being referenced. + If APIGroup is not specified, the specified Kind must be in + the core API group. For any other third-party types, APIGroup + is required. + type: string + kind: + description: Kind is the type of resource being referenced + type: string + name: + description: Name is the name of resource being referenced + type: string + required: + - kind + - name + type: object + type: object + status: + description: Status represents the latest observed state of the snapshot + properties: + creationTime: + description: CreationTime is the time the snapshot was successfully + created. If it is set, it means the snapshot was created; Otherwise + the snapshot was not created. + format: date-time + type: string + error: + description: The last error encountered during create snapshot operation, + if any. This field must only be set by the entity completing the + create snapshot operation, i.e. the external-snapshotter. + properties: + message: + description: String detailing the error encountered during Attach + or Detach operation. This string may be logged, so it should + not contain sensitive information. + type: string + time: + description: Time the error was encountered. + format: date-time + type: string + type: object + readyToUse: + description: ReadyToUse is set to true only if the snapshot is ready + to use (e.g., finish uploading if there is an uploading phase) and + also VolumeSnapshot and its VolumeSnapshotContent bind correctly + with each other. If any of the above condition is not true, ReadyToUse + is set to false + type: boolean + restoreSize: + description: When restoring volume from the snapshot, the volume size + should be equal to or larger than the RestoreSize if it is specified. + If RestoreSize is set to nil, it means that the storage plugin does + not have this information available. + type: string + type: object + required: + - spec + type: object + served: true + storage: true +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] diff --git a/hack/update-generated-code.sh b/hack/update-generated-code.sh index f48150d77..d682028f2 100755 --- a/hack/update-generated-code.sh +++ b/hack/update-generated-code.sh @@ -29,7 +29,7 @@ CODEGEN_PKG=${CODEGEN_PKG:-$(cd ${SCRIPT_ROOT}; ls -d -1 ./vendor/k8s.io/code-ge # instead of the $GOPATH directly. For normal projects this can be dropped. ${CODEGEN_PKG}/generate-groups.sh "deepcopy,client,informer,lister" \ github.com/kubernetes-csi/external-snapshotter/pkg/client github.com/kubernetes-csi/external-snapshotter/pkg/apis \ - volumesnapshot:v1alpha1 \ + volumesnapshot:v1beta1 \ --go-header-file ${SCRIPT_ROOT}/hack/boilerplate.go.txt # To use your own boilerplate text use: diff --git a/pkg/apis/volumesnapshot/v1alpha1/doc.go b/pkg/apis/volumesnapshot/v1beta1/doc.go similarity index 97% rename from pkg/apis/volumesnapshot/v1alpha1/doc.go rename to pkg/apis/volumesnapshot/v1beta1/doc.go index 90642a58b..d8a1f5dad 100644 --- a/pkg/apis/volumesnapshot/v1alpha1/doc.go +++ b/pkg/apis/volumesnapshot/v1beta1/doc.go @@ -17,4 +17,4 @@ limitations under the License. // +k8s:deepcopy-gen=package // +groupName=snapshot.storage.k8s.io -package v1alpha1 +package v1beta1 diff --git a/pkg/apis/volumesnapshot/v1alpha1/register.go b/pkg/apis/volumesnapshot/v1beta1/register.go similarity index 98% rename from pkg/apis/volumesnapshot/v1alpha1/register.go rename to pkg/apis/volumesnapshot/v1beta1/register.go index e7c38b6ba..91f451424 100644 --- a/pkg/apis/volumesnapshot/v1alpha1/register.go +++ b/pkg/apis/volumesnapshot/v1beta1/register.go @@ -11,7 +11,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1alpha1 +package v1beta1 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -28,7 +28,7 @@ var ( // AddToScheme adds to scheme AddToScheme = SchemeBuilder.AddToScheme // SchemeGroupVersion is the group version used to register these objects. - SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"} + SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1beta1"} ) // Resource takes an unqualified resource and returns a Group-qualified GroupResource. diff --git a/pkg/apis/volumesnapshot/v1alpha1/types.go b/pkg/apis/volumesnapshot/v1beta1/types.go similarity index 99% rename from pkg/apis/volumesnapshot/v1alpha1/types.go rename to pkg/apis/volumesnapshot/v1beta1/types.go index 65c1aafaa..2fb0b8e75 100644 --- a/pkg/apis/volumesnapshot/v1alpha1/types.go +++ b/pkg/apis/volumesnapshot/v1beta1/types.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1alpha1 +package v1beta1 import ( core_v1 "k8s.io/api/core/v1" diff --git a/pkg/apis/volumesnapshot/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/volumesnapshot/v1beta1/zz_generated.deepcopy.go similarity index 99% rename from pkg/apis/volumesnapshot/v1alpha1/zz_generated.deepcopy.go rename to pkg/apis/volumesnapshot/v1beta1/zz_generated.deepcopy.go index 38db004a8..5bc2c2028 100644 --- a/pkg/apis/volumesnapshot/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/volumesnapshot/v1beta1/zz_generated.deepcopy.go @@ -18,11 +18,11 @@ limitations under the License. // Code generated by deepcopy-gen. DO NOT EDIT. -package v1alpha1 +package v1beta1 import ( v1 "k8s.io/api/core/v1" - v1beta1 "k8s.io/api/storage/v1beta1" + storagev1beta1 "k8s.io/api/storage/v1beta1" runtime "k8s.io/apimachinery/pkg/runtime" ) @@ -342,7 +342,7 @@ func (in *VolumeSnapshotStatus) DeepCopyInto(out *VolumeSnapshotStatus) { } if in.Error != nil { in, out := &in.Error, &out.Error - *out = new(v1beta1.VolumeError) + *out = new(storagev1beta1.VolumeError) (*in).DeepCopyInto(*out) } return diff --git a/pkg/client/clientset/versioned/clientset.go b/pkg/client/clientset/versioned/clientset.go index 5bcff9985..25be21b49 100644 --- a/pkg/client/clientset/versioned/clientset.go +++ b/pkg/client/clientset/versioned/clientset.go @@ -19,7 +19,7 @@ limitations under the License. package versioned import ( - snapshotv1alpha1 "github.com/kubernetes-csi/external-snapshotter/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1" + snapshotv1beta1 "github.com/kubernetes-csi/external-snapshotter/pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1" discovery "k8s.io/client-go/discovery" rest "k8s.io/client-go/rest" flowcontrol "k8s.io/client-go/util/flowcontrol" @@ -27,19 +27,19 @@ import ( type Interface interface { Discovery() discovery.DiscoveryInterface - SnapshotV1alpha1() snapshotv1alpha1.SnapshotV1alpha1Interface + SnapshotV1beta1() snapshotv1beta1.SnapshotV1beta1Interface } // Clientset contains the clients for groups. Each group has exactly one // version included in a Clientset. type Clientset struct { *discovery.DiscoveryClient - snapshotV1alpha1 *snapshotv1alpha1.SnapshotV1alpha1Client + snapshotV1beta1 *snapshotv1beta1.SnapshotV1beta1Client } -// SnapshotV1alpha1 retrieves the SnapshotV1alpha1Client -func (c *Clientset) SnapshotV1alpha1() snapshotv1alpha1.SnapshotV1alpha1Interface { - return c.snapshotV1alpha1 +// SnapshotV1beta1 retrieves the SnapshotV1beta1Client +func (c *Clientset) SnapshotV1beta1() snapshotv1beta1.SnapshotV1beta1Interface { + return c.snapshotV1beta1 } // Discovery retrieves the DiscoveryClient @@ -58,7 +58,7 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { } var cs Clientset var err error - cs.snapshotV1alpha1, err = snapshotv1alpha1.NewForConfig(&configShallowCopy) + cs.snapshotV1beta1, err = snapshotv1beta1.NewForConfig(&configShallowCopy) if err != nil { return nil, err } @@ -74,7 +74,7 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { // panics if there is an error in the config. func NewForConfigOrDie(c *rest.Config) *Clientset { var cs Clientset - cs.snapshotV1alpha1 = snapshotv1alpha1.NewForConfigOrDie(c) + cs.snapshotV1beta1 = snapshotv1beta1.NewForConfigOrDie(c) cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) return &cs @@ -83,7 +83,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset { // New creates a new Clientset for the given RESTClient. func New(c rest.Interface) *Clientset { var cs Clientset - cs.snapshotV1alpha1 = snapshotv1alpha1.New(c) + cs.snapshotV1beta1 = snapshotv1beta1.New(c) cs.DiscoveryClient = discovery.NewDiscoveryClient(c) return &cs diff --git a/pkg/client/clientset/versioned/fake/clientset_generated.go b/pkg/client/clientset/versioned/fake/clientset_generated.go index 0c5b82937..b05e85ea7 100644 --- a/pkg/client/clientset/versioned/fake/clientset_generated.go +++ b/pkg/client/clientset/versioned/fake/clientset_generated.go @@ -20,8 +20,8 @@ package fake import ( clientset "github.com/kubernetes-csi/external-snapshotter/pkg/client/clientset/versioned" - snapshotv1alpha1 "github.com/kubernetes-csi/external-snapshotter/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1" - fakesnapshotv1alpha1 "github.com/kubernetes-csi/external-snapshotter/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/fake" + snapshotv1beta1 "github.com/kubernetes-csi/external-snapshotter/pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1" + fakesnapshotv1beta1 "github.com/kubernetes-csi/external-snapshotter/pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/fake" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/watch" "k8s.io/client-go/discovery" @@ -71,7 +71,7 @@ func (c *Clientset) Discovery() discovery.DiscoveryInterface { var _ clientset.Interface = &Clientset{} -// SnapshotV1alpha1 retrieves the SnapshotV1alpha1Client -func (c *Clientset) SnapshotV1alpha1() snapshotv1alpha1.SnapshotV1alpha1Interface { - return &fakesnapshotv1alpha1.FakeSnapshotV1alpha1{Fake: &c.Fake} +// SnapshotV1beta1 retrieves the SnapshotV1beta1Client +func (c *Clientset) SnapshotV1beta1() snapshotv1beta1.SnapshotV1beta1Interface { + return &fakesnapshotv1beta1.FakeSnapshotV1beta1{Fake: &c.Fake} } diff --git a/pkg/client/clientset/versioned/fake/register.go b/pkg/client/clientset/versioned/fake/register.go index 903889fd9..4c92bf112 100644 --- a/pkg/client/clientset/versioned/fake/register.go +++ b/pkg/client/clientset/versioned/fake/register.go @@ -19,7 +19,7 @@ limitations under the License. package fake import ( - snapshotv1alpha1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + snapshotv1beta1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -31,7 +31,7 @@ var scheme = runtime.NewScheme() var codecs = serializer.NewCodecFactory(scheme) var parameterCodec = runtime.NewParameterCodec(scheme) var localSchemeBuilder = runtime.SchemeBuilder{ - snapshotv1alpha1.AddToScheme, + snapshotv1beta1.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition diff --git a/pkg/client/clientset/versioned/scheme/register.go b/pkg/client/clientset/versioned/scheme/register.go index 46efa8fe5..296f7fa70 100644 --- a/pkg/client/clientset/versioned/scheme/register.go +++ b/pkg/client/clientset/versioned/scheme/register.go @@ -19,7 +19,7 @@ limitations under the License. package scheme import ( - snapshotv1alpha1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + snapshotv1beta1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -31,7 +31,7 @@ var Scheme = runtime.NewScheme() var Codecs = serializer.NewCodecFactory(Scheme) var ParameterCodec = runtime.NewParameterCodec(Scheme) var localSchemeBuilder = runtime.SchemeBuilder{ - snapshotv1alpha1.AddToScheme, + snapshotv1beta1.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition diff --git a/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/doc.go b/pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/doc.go similarity index 97% rename from pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/doc.go rename to pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/doc.go index 9752e759c..305440eb2 100644 --- a/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/doc.go +++ b/pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/doc.go @@ -17,4 +17,4 @@ limitations under the License. // Code generated by client-gen. DO NOT EDIT. // This package has the automatically generated typed clients. -package v1alpha1 +package v1beta1 diff --git a/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/fake/doc.go b/pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/fake/doc.go similarity index 100% rename from pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/fake/doc.go rename to pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/fake/doc.go diff --git a/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/fake/fake_volumesnapshot.go b/pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/fake/fake_volumesnapshot.go similarity index 70% rename from pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/fake/fake_volumesnapshot.go rename to pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/fake/fake_volumesnapshot.go index 05016a1a2..72faad7d8 100644 --- a/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/fake/fake_volumesnapshot.go +++ b/pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/fake/fake_volumesnapshot.go @@ -19,7 +19,7 @@ limitations under the License. package fake import ( - v1alpha1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + v1beta1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -30,29 +30,29 @@ import ( // FakeVolumeSnapshots implements VolumeSnapshotInterface type FakeVolumeSnapshots struct { - Fake *FakeSnapshotV1alpha1 + Fake *FakeSnapshotV1beta1 ns string } -var volumesnapshotsResource = schema.GroupVersionResource{Group: "snapshot.storage.k8s.io", Version: "v1alpha1", Resource: "volumesnapshots"} +var volumesnapshotsResource = schema.GroupVersionResource{Group: "snapshot.storage.k8s.io", Version: "v1beta1", Resource: "volumesnapshots"} -var volumesnapshotsKind = schema.GroupVersionKind{Group: "snapshot.storage.k8s.io", Version: "v1alpha1", Kind: "VolumeSnapshot"} +var volumesnapshotsKind = schema.GroupVersionKind{Group: "snapshot.storage.k8s.io", Version: "v1beta1", Kind: "VolumeSnapshot"} // Get takes name of the volumeSnapshot, and returns the corresponding volumeSnapshot object, and an error if there is any. -func (c *FakeVolumeSnapshots) Get(name string, options v1.GetOptions) (result *v1alpha1.VolumeSnapshot, err error) { +func (c *FakeVolumeSnapshots) Get(name string, options v1.GetOptions) (result *v1beta1.VolumeSnapshot, err error) { obj, err := c.Fake. - Invokes(testing.NewGetAction(volumesnapshotsResource, c.ns, name), &v1alpha1.VolumeSnapshot{}) + Invokes(testing.NewGetAction(volumesnapshotsResource, c.ns, name), &v1beta1.VolumeSnapshot{}) if obj == nil { return nil, err } - return obj.(*v1alpha1.VolumeSnapshot), err + return obj.(*v1beta1.VolumeSnapshot), err } // List takes label and field selectors, and returns the list of VolumeSnapshots that match those selectors. -func (c *FakeVolumeSnapshots) List(opts v1.ListOptions) (result *v1alpha1.VolumeSnapshotList, err error) { +func (c *FakeVolumeSnapshots) List(opts v1.ListOptions) (result *v1beta1.VolumeSnapshotList, err error) { obj, err := c.Fake. - Invokes(testing.NewListAction(volumesnapshotsResource, volumesnapshotsKind, c.ns, opts), &v1alpha1.VolumeSnapshotList{}) + Invokes(testing.NewListAction(volumesnapshotsResource, volumesnapshotsKind, c.ns, opts), &v1beta1.VolumeSnapshotList{}) if obj == nil { return nil, err @@ -62,8 +62,8 @@ func (c *FakeVolumeSnapshots) List(opts v1.ListOptions) (result *v1alpha1.Volume if label == nil { label = labels.Everything() } - list := &v1alpha1.VolumeSnapshotList{ListMeta: obj.(*v1alpha1.VolumeSnapshotList).ListMeta} - for _, item := range obj.(*v1alpha1.VolumeSnapshotList).Items { + list := &v1beta1.VolumeSnapshotList{ListMeta: obj.(*v1beta1.VolumeSnapshotList).ListMeta} + for _, item := range obj.(*v1beta1.VolumeSnapshotList).Items { if label.Matches(labels.Set(item.Labels)) { list.Items = append(list.Items, item) } @@ -79,43 +79,43 @@ func (c *FakeVolumeSnapshots) Watch(opts v1.ListOptions) (watch.Interface, error } // Create takes the representation of a volumeSnapshot and creates it. Returns the server's representation of the volumeSnapshot, and an error, if there is any. -func (c *FakeVolumeSnapshots) Create(volumeSnapshot *v1alpha1.VolumeSnapshot) (result *v1alpha1.VolumeSnapshot, err error) { +func (c *FakeVolumeSnapshots) Create(volumeSnapshot *v1beta1.VolumeSnapshot) (result *v1beta1.VolumeSnapshot, err error) { obj, err := c.Fake. - Invokes(testing.NewCreateAction(volumesnapshotsResource, c.ns, volumeSnapshot), &v1alpha1.VolumeSnapshot{}) + Invokes(testing.NewCreateAction(volumesnapshotsResource, c.ns, volumeSnapshot), &v1beta1.VolumeSnapshot{}) if obj == nil { return nil, err } - return obj.(*v1alpha1.VolumeSnapshot), err + return obj.(*v1beta1.VolumeSnapshot), err } // Update takes the representation of a volumeSnapshot and updates it. Returns the server's representation of the volumeSnapshot, and an error, if there is any. -func (c *FakeVolumeSnapshots) Update(volumeSnapshot *v1alpha1.VolumeSnapshot) (result *v1alpha1.VolumeSnapshot, err error) { +func (c *FakeVolumeSnapshots) Update(volumeSnapshot *v1beta1.VolumeSnapshot) (result *v1beta1.VolumeSnapshot, err error) { obj, err := c.Fake. - Invokes(testing.NewUpdateAction(volumesnapshotsResource, c.ns, volumeSnapshot), &v1alpha1.VolumeSnapshot{}) + Invokes(testing.NewUpdateAction(volumesnapshotsResource, c.ns, volumeSnapshot), &v1beta1.VolumeSnapshot{}) if obj == nil { return nil, err } - return obj.(*v1alpha1.VolumeSnapshot), err + return obj.(*v1beta1.VolumeSnapshot), err } // UpdateStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeVolumeSnapshots) UpdateStatus(volumeSnapshot *v1alpha1.VolumeSnapshot) (*v1alpha1.VolumeSnapshot, error) { +func (c *FakeVolumeSnapshots) UpdateStatus(volumeSnapshot *v1beta1.VolumeSnapshot) (*v1beta1.VolumeSnapshot, error) { obj, err := c.Fake. - Invokes(testing.NewUpdateSubresourceAction(volumesnapshotsResource, "status", c.ns, volumeSnapshot), &v1alpha1.VolumeSnapshot{}) + Invokes(testing.NewUpdateSubresourceAction(volumesnapshotsResource, "status", c.ns, volumeSnapshot), &v1beta1.VolumeSnapshot{}) if obj == nil { return nil, err } - return obj.(*v1alpha1.VolumeSnapshot), err + return obj.(*v1beta1.VolumeSnapshot), err } // Delete takes name of the volumeSnapshot and deletes it. Returns an error if one occurs. func (c *FakeVolumeSnapshots) Delete(name string, options *v1.DeleteOptions) error { _, err := c.Fake. - Invokes(testing.NewDeleteAction(volumesnapshotsResource, c.ns, name), &v1alpha1.VolumeSnapshot{}) + Invokes(testing.NewDeleteAction(volumesnapshotsResource, c.ns, name), &v1beta1.VolumeSnapshot{}) return err } @@ -124,17 +124,17 @@ func (c *FakeVolumeSnapshots) Delete(name string, options *v1.DeleteOptions) err func (c *FakeVolumeSnapshots) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { action := testing.NewDeleteCollectionAction(volumesnapshotsResource, c.ns, listOptions) - _, err := c.Fake.Invokes(action, &v1alpha1.VolumeSnapshotList{}) + _, err := c.Fake.Invokes(action, &v1beta1.VolumeSnapshotList{}) return err } // Patch applies the patch and returns the patched volumeSnapshot. -func (c *FakeVolumeSnapshots) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.VolumeSnapshot, err error) { +func (c *FakeVolumeSnapshots) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.VolumeSnapshot, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(volumesnapshotsResource, c.ns, name, pt, data, subresources...), &v1alpha1.VolumeSnapshot{}) + Invokes(testing.NewPatchSubresourceAction(volumesnapshotsResource, c.ns, name, pt, data, subresources...), &v1beta1.VolumeSnapshot{}) if obj == nil { return nil, err } - return obj.(*v1alpha1.VolumeSnapshot), err + return obj.(*v1beta1.VolumeSnapshot), err } diff --git a/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/fake/fake_volumesnapshot_client.go b/pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/fake/fake_volumesnapshot_client.go similarity index 66% rename from pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/fake/fake_volumesnapshot_client.go rename to pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/fake/fake_volumesnapshot_client.go index 6c8b11a57..56f7a0dd1 100644 --- a/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/fake/fake_volumesnapshot_client.go +++ b/pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/fake/fake_volumesnapshot_client.go @@ -19,30 +19,30 @@ limitations under the License. package fake import ( - v1alpha1 "github.com/kubernetes-csi/external-snapshotter/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1" + v1beta1 "github.com/kubernetes-csi/external-snapshotter/pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1" rest "k8s.io/client-go/rest" testing "k8s.io/client-go/testing" ) -type FakeSnapshotV1alpha1 struct { +type FakeSnapshotV1beta1 struct { *testing.Fake } -func (c *FakeSnapshotV1alpha1) VolumeSnapshots(namespace string) v1alpha1.VolumeSnapshotInterface { +func (c *FakeSnapshotV1beta1) VolumeSnapshots(namespace string) v1beta1.VolumeSnapshotInterface { return &FakeVolumeSnapshots{c, namespace} } -func (c *FakeSnapshotV1alpha1) VolumeSnapshotClasses() v1alpha1.VolumeSnapshotClassInterface { +func (c *FakeSnapshotV1beta1) VolumeSnapshotClasses() v1beta1.VolumeSnapshotClassInterface { return &FakeVolumeSnapshotClasses{c} } -func (c *FakeSnapshotV1alpha1) VolumeSnapshotContents() v1alpha1.VolumeSnapshotContentInterface { +func (c *FakeSnapshotV1beta1) VolumeSnapshotContents() v1beta1.VolumeSnapshotContentInterface { return &FakeVolumeSnapshotContents{c} } // RESTClient returns a RESTClient that is used to communicate // with API server by this client implementation. -func (c *FakeSnapshotV1alpha1) RESTClient() rest.Interface { +func (c *FakeSnapshotV1beta1) RESTClient() rest.Interface { var ret *rest.RESTClient return ret } diff --git a/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/fake/fake_volumesnapshotclass.go b/pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/fake/fake_volumesnapshotclass.go similarity index 72% rename from pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/fake/fake_volumesnapshotclass.go rename to pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/fake/fake_volumesnapshotclass.go index 5c756b20b..bd4013c39 100644 --- a/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/fake/fake_volumesnapshotclass.go +++ b/pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/fake/fake_volumesnapshotclass.go @@ -19,7 +19,7 @@ limitations under the License. package fake import ( - v1alpha1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + v1beta1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -30,27 +30,27 @@ import ( // FakeVolumeSnapshotClasses implements VolumeSnapshotClassInterface type FakeVolumeSnapshotClasses struct { - Fake *FakeSnapshotV1alpha1 + Fake *FakeSnapshotV1beta1 } -var volumesnapshotclassesResource = schema.GroupVersionResource{Group: "snapshot.storage.k8s.io", Version: "v1alpha1", Resource: "volumesnapshotclasses"} +var volumesnapshotclassesResource = schema.GroupVersionResource{Group: "snapshot.storage.k8s.io", Version: "v1beta1", Resource: "volumesnapshotclasses"} -var volumesnapshotclassesKind = schema.GroupVersionKind{Group: "snapshot.storage.k8s.io", Version: "v1alpha1", Kind: "VolumeSnapshotClass"} +var volumesnapshotclassesKind = schema.GroupVersionKind{Group: "snapshot.storage.k8s.io", Version: "v1beta1", Kind: "VolumeSnapshotClass"} // Get takes name of the volumeSnapshotClass, and returns the corresponding volumeSnapshotClass object, and an error if there is any. -func (c *FakeVolumeSnapshotClasses) Get(name string, options v1.GetOptions) (result *v1alpha1.VolumeSnapshotClass, err error) { +func (c *FakeVolumeSnapshotClasses) Get(name string, options v1.GetOptions) (result *v1beta1.VolumeSnapshotClass, err error) { obj, err := c.Fake. - Invokes(testing.NewRootGetAction(volumesnapshotclassesResource, name), &v1alpha1.VolumeSnapshotClass{}) + Invokes(testing.NewRootGetAction(volumesnapshotclassesResource, name), &v1beta1.VolumeSnapshotClass{}) if obj == nil { return nil, err } - return obj.(*v1alpha1.VolumeSnapshotClass), err + return obj.(*v1beta1.VolumeSnapshotClass), err } // List takes label and field selectors, and returns the list of VolumeSnapshotClasses that match those selectors. -func (c *FakeVolumeSnapshotClasses) List(opts v1.ListOptions) (result *v1alpha1.VolumeSnapshotClassList, err error) { +func (c *FakeVolumeSnapshotClasses) List(opts v1.ListOptions) (result *v1beta1.VolumeSnapshotClassList, err error) { obj, err := c.Fake. - Invokes(testing.NewRootListAction(volumesnapshotclassesResource, volumesnapshotclassesKind, opts), &v1alpha1.VolumeSnapshotClassList{}) + Invokes(testing.NewRootListAction(volumesnapshotclassesResource, volumesnapshotclassesKind, opts), &v1beta1.VolumeSnapshotClassList{}) if obj == nil { return nil, err } @@ -59,8 +59,8 @@ func (c *FakeVolumeSnapshotClasses) List(opts v1.ListOptions) (result *v1alpha1. if label == nil { label = labels.Everything() } - list := &v1alpha1.VolumeSnapshotClassList{ListMeta: obj.(*v1alpha1.VolumeSnapshotClassList).ListMeta} - for _, item := range obj.(*v1alpha1.VolumeSnapshotClassList).Items { + list := &v1beta1.VolumeSnapshotClassList{ListMeta: obj.(*v1beta1.VolumeSnapshotClassList).ListMeta} + for _, item := range obj.(*v1beta1.VolumeSnapshotClassList).Items { if label.Matches(labels.Set(item.Labels)) { list.Items = append(list.Items, item) } @@ -75,29 +75,29 @@ func (c *FakeVolumeSnapshotClasses) Watch(opts v1.ListOptions) (watch.Interface, } // Create takes the representation of a volumeSnapshotClass and creates it. Returns the server's representation of the volumeSnapshotClass, and an error, if there is any. -func (c *FakeVolumeSnapshotClasses) Create(volumeSnapshotClass *v1alpha1.VolumeSnapshotClass) (result *v1alpha1.VolumeSnapshotClass, err error) { +func (c *FakeVolumeSnapshotClasses) Create(volumeSnapshotClass *v1beta1.VolumeSnapshotClass) (result *v1beta1.VolumeSnapshotClass, err error) { obj, err := c.Fake. - Invokes(testing.NewRootCreateAction(volumesnapshotclassesResource, volumeSnapshotClass), &v1alpha1.VolumeSnapshotClass{}) + Invokes(testing.NewRootCreateAction(volumesnapshotclassesResource, volumeSnapshotClass), &v1beta1.VolumeSnapshotClass{}) if obj == nil { return nil, err } - return obj.(*v1alpha1.VolumeSnapshotClass), err + return obj.(*v1beta1.VolumeSnapshotClass), err } // Update takes the representation of a volumeSnapshotClass and updates it. Returns the server's representation of the volumeSnapshotClass, and an error, if there is any. -func (c *FakeVolumeSnapshotClasses) Update(volumeSnapshotClass *v1alpha1.VolumeSnapshotClass) (result *v1alpha1.VolumeSnapshotClass, err error) { +func (c *FakeVolumeSnapshotClasses) Update(volumeSnapshotClass *v1beta1.VolumeSnapshotClass) (result *v1beta1.VolumeSnapshotClass, err error) { obj, err := c.Fake. - Invokes(testing.NewRootUpdateAction(volumesnapshotclassesResource, volumeSnapshotClass), &v1alpha1.VolumeSnapshotClass{}) + Invokes(testing.NewRootUpdateAction(volumesnapshotclassesResource, volumeSnapshotClass), &v1beta1.VolumeSnapshotClass{}) if obj == nil { return nil, err } - return obj.(*v1alpha1.VolumeSnapshotClass), err + return obj.(*v1beta1.VolumeSnapshotClass), err } // Delete takes name of the volumeSnapshotClass and deletes it. Returns an error if one occurs. func (c *FakeVolumeSnapshotClasses) Delete(name string, options *v1.DeleteOptions) error { _, err := c.Fake. - Invokes(testing.NewRootDeleteAction(volumesnapshotclassesResource, name), &v1alpha1.VolumeSnapshotClass{}) + Invokes(testing.NewRootDeleteAction(volumesnapshotclassesResource, name), &v1beta1.VolumeSnapshotClass{}) return err } @@ -105,16 +105,16 @@ func (c *FakeVolumeSnapshotClasses) Delete(name string, options *v1.DeleteOption func (c *FakeVolumeSnapshotClasses) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { action := testing.NewRootDeleteCollectionAction(volumesnapshotclassesResource, listOptions) - _, err := c.Fake.Invokes(action, &v1alpha1.VolumeSnapshotClassList{}) + _, err := c.Fake.Invokes(action, &v1beta1.VolumeSnapshotClassList{}) return err } // Patch applies the patch and returns the patched volumeSnapshotClass. -func (c *FakeVolumeSnapshotClasses) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.VolumeSnapshotClass, err error) { +func (c *FakeVolumeSnapshotClasses) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.VolumeSnapshotClass, err error) { obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceAction(volumesnapshotclassesResource, name, pt, data, subresources...), &v1alpha1.VolumeSnapshotClass{}) + Invokes(testing.NewRootPatchSubresourceAction(volumesnapshotclassesResource, name, pt, data, subresources...), &v1beta1.VolumeSnapshotClass{}) if obj == nil { return nil, err } - return obj.(*v1alpha1.VolumeSnapshotClass), err + return obj.(*v1beta1.VolumeSnapshotClass), err } diff --git a/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/fake/fake_volumesnapshotcontent.go b/pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/fake/fake_volumesnapshotcontent.go similarity index 71% rename from pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/fake/fake_volumesnapshotcontent.go rename to pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/fake/fake_volumesnapshotcontent.go index f646d1d9d..3593a8448 100644 --- a/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/fake/fake_volumesnapshotcontent.go +++ b/pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/fake/fake_volumesnapshotcontent.go @@ -19,7 +19,7 @@ limitations under the License. package fake import ( - v1alpha1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + v1beta1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -30,27 +30,27 @@ import ( // FakeVolumeSnapshotContents implements VolumeSnapshotContentInterface type FakeVolumeSnapshotContents struct { - Fake *FakeSnapshotV1alpha1 + Fake *FakeSnapshotV1beta1 } -var volumesnapshotcontentsResource = schema.GroupVersionResource{Group: "snapshot.storage.k8s.io", Version: "v1alpha1", Resource: "volumesnapshotcontents"} +var volumesnapshotcontentsResource = schema.GroupVersionResource{Group: "snapshot.storage.k8s.io", Version: "v1beta1", Resource: "volumesnapshotcontents"} -var volumesnapshotcontentsKind = schema.GroupVersionKind{Group: "snapshot.storage.k8s.io", Version: "v1alpha1", Kind: "VolumeSnapshotContent"} +var volumesnapshotcontentsKind = schema.GroupVersionKind{Group: "snapshot.storage.k8s.io", Version: "v1beta1", Kind: "VolumeSnapshotContent"} // Get takes name of the volumeSnapshotContent, and returns the corresponding volumeSnapshotContent object, and an error if there is any. -func (c *FakeVolumeSnapshotContents) Get(name string, options v1.GetOptions) (result *v1alpha1.VolumeSnapshotContent, err error) { +func (c *FakeVolumeSnapshotContents) Get(name string, options v1.GetOptions) (result *v1beta1.VolumeSnapshotContent, err error) { obj, err := c.Fake. - Invokes(testing.NewRootGetAction(volumesnapshotcontentsResource, name), &v1alpha1.VolumeSnapshotContent{}) + Invokes(testing.NewRootGetAction(volumesnapshotcontentsResource, name), &v1beta1.VolumeSnapshotContent{}) if obj == nil { return nil, err } - return obj.(*v1alpha1.VolumeSnapshotContent), err + return obj.(*v1beta1.VolumeSnapshotContent), err } // List takes label and field selectors, and returns the list of VolumeSnapshotContents that match those selectors. -func (c *FakeVolumeSnapshotContents) List(opts v1.ListOptions) (result *v1alpha1.VolumeSnapshotContentList, err error) { +func (c *FakeVolumeSnapshotContents) List(opts v1.ListOptions) (result *v1beta1.VolumeSnapshotContentList, err error) { obj, err := c.Fake. - Invokes(testing.NewRootListAction(volumesnapshotcontentsResource, volumesnapshotcontentsKind, opts), &v1alpha1.VolumeSnapshotContentList{}) + Invokes(testing.NewRootListAction(volumesnapshotcontentsResource, volumesnapshotcontentsKind, opts), &v1beta1.VolumeSnapshotContentList{}) if obj == nil { return nil, err } @@ -59,8 +59,8 @@ func (c *FakeVolumeSnapshotContents) List(opts v1.ListOptions) (result *v1alpha1 if label == nil { label = labels.Everything() } - list := &v1alpha1.VolumeSnapshotContentList{ListMeta: obj.(*v1alpha1.VolumeSnapshotContentList).ListMeta} - for _, item := range obj.(*v1alpha1.VolumeSnapshotContentList).Items { + list := &v1beta1.VolumeSnapshotContentList{ListMeta: obj.(*v1beta1.VolumeSnapshotContentList).ListMeta} + for _, item := range obj.(*v1beta1.VolumeSnapshotContentList).Items { if label.Matches(labels.Set(item.Labels)) { list.Items = append(list.Items, item) } @@ -75,29 +75,29 @@ func (c *FakeVolumeSnapshotContents) Watch(opts v1.ListOptions) (watch.Interface } // Create takes the representation of a volumeSnapshotContent and creates it. Returns the server's representation of the volumeSnapshotContent, and an error, if there is any. -func (c *FakeVolumeSnapshotContents) Create(volumeSnapshotContent *v1alpha1.VolumeSnapshotContent) (result *v1alpha1.VolumeSnapshotContent, err error) { +func (c *FakeVolumeSnapshotContents) Create(volumeSnapshotContent *v1beta1.VolumeSnapshotContent) (result *v1beta1.VolumeSnapshotContent, err error) { obj, err := c.Fake. - Invokes(testing.NewRootCreateAction(volumesnapshotcontentsResource, volumeSnapshotContent), &v1alpha1.VolumeSnapshotContent{}) + Invokes(testing.NewRootCreateAction(volumesnapshotcontentsResource, volumeSnapshotContent), &v1beta1.VolumeSnapshotContent{}) if obj == nil { return nil, err } - return obj.(*v1alpha1.VolumeSnapshotContent), err + return obj.(*v1beta1.VolumeSnapshotContent), err } // Update takes the representation of a volumeSnapshotContent and updates it. Returns the server's representation of the volumeSnapshotContent, and an error, if there is any. -func (c *FakeVolumeSnapshotContents) Update(volumeSnapshotContent *v1alpha1.VolumeSnapshotContent) (result *v1alpha1.VolumeSnapshotContent, err error) { +func (c *FakeVolumeSnapshotContents) Update(volumeSnapshotContent *v1beta1.VolumeSnapshotContent) (result *v1beta1.VolumeSnapshotContent, err error) { obj, err := c.Fake. - Invokes(testing.NewRootUpdateAction(volumesnapshotcontentsResource, volumeSnapshotContent), &v1alpha1.VolumeSnapshotContent{}) + Invokes(testing.NewRootUpdateAction(volumesnapshotcontentsResource, volumeSnapshotContent), &v1beta1.VolumeSnapshotContent{}) if obj == nil { return nil, err } - return obj.(*v1alpha1.VolumeSnapshotContent), err + return obj.(*v1beta1.VolumeSnapshotContent), err } // Delete takes name of the volumeSnapshotContent and deletes it. Returns an error if one occurs. func (c *FakeVolumeSnapshotContents) Delete(name string, options *v1.DeleteOptions) error { _, err := c.Fake. - Invokes(testing.NewRootDeleteAction(volumesnapshotcontentsResource, name), &v1alpha1.VolumeSnapshotContent{}) + Invokes(testing.NewRootDeleteAction(volumesnapshotcontentsResource, name), &v1beta1.VolumeSnapshotContent{}) return err } @@ -105,16 +105,16 @@ func (c *FakeVolumeSnapshotContents) Delete(name string, options *v1.DeleteOptio func (c *FakeVolumeSnapshotContents) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { action := testing.NewRootDeleteCollectionAction(volumesnapshotcontentsResource, listOptions) - _, err := c.Fake.Invokes(action, &v1alpha1.VolumeSnapshotContentList{}) + _, err := c.Fake.Invokes(action, &v1beta1.VolumeSnapshotContentList{}) return err } // Patch applies the patch and returns the patched volumeSnapshotContent. -func (c *FakeVolumeSnapshotContents) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.VolumeSnapshotContent, err error) { +func (c *FakeVolumeSnapshotContents) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.VolumeSnapshotContent, err error) { obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceAction(volumesnapshotcontentsResource, name, pt, data, subresources...), &v1alpha1.VolumeSnapshotContent{}) + Invokes(testing.NewRootPatchSubresourceAction(volumesnapshotcontentsResource, name, pt, data, subresources...), &v1beta1.VolumeSnapshotContent{}) if obj == nil { return nil, err } - return obj.(*v1alpha1.VolumeSnapshotContent), err + return obj.(*v1beta1.VolumeSnapshotContent), err } diff --git a/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/generated_expansion.go b/pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/generated_expansion.go similarity index 97% rename from pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/generated_expansion.go rename to pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/generated_expansion.go index 9b641f106..3ed3d11f2 100644 --- a/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/generated_expansion.go +++ b/pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/generated_expansion.go @@ -16,7 +16,7 @@ limitations under the License. // Code generated by client-gen. DO NOT EDIT. -package v1alpha1 +package v1beta1 type VolumeSnapshotExpansion interface{} diff --git a/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/volumesnapshot.go b/pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/volumesnapshot.go similarity index 77% rename from pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/volumesnapshot.go rename to pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/volumesnapshot.go index a2f80805a..f9ef41512 100644 --- a/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/volumesnapshot.go +++ b/pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/volumesnapshot.go @@ -16,12 +16,12 @@ limitations under the License. // Code generated by client-gen. DO NOT EDIT. -package v1alpha1 +package v1beta1 import ( "time" - v1alpha1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + v1beta1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" scheme "github.com/kubernetes-csi/external-snapshotter/pkg/client/clientset/versioned/scheme" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" types "k8s.io/apimachinery/pkg/types" @@ -37,15 +37,15 @@ type VolumeSnapshotsGetter interface { // VolumeSnapshotInterface has methods to work with VolumeSnapshot resources. type VolumeSnapshotInterface interface { - Create(*v1alpha1.VolumeSnapshot) (*v1alpha1.VolumeSnapshot, error) - Update(*v1alpha1.VolumeSnapshot) (*v1alpha1.VolumeSnapshot, error) - UpdateStatus(*v1alpha1.VolumeSnapshot) (*v1alpha1.VolumeSnapshot, error) + Create(*v1beta1.VolumeSnapshot) (*v1beta1.VolumeSnapshot, error) + Update(*v1beta1.VolumeSnapshot) (*v1beta1.VolumeSnapshot, error) + UpdateStatus(*v1beta1.VolumeSnapshot) (*v1beta1.VolumeSnapshot, error) Delete(name string, options *v1.DeleteOptions) error DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error - Get(name string, options v1.GetOptions) (*v1alpha1.VolumeSnapshot, error) - List(opts v1.ListOptions) (*v1alpha1.VolumeSnapshotList, error) + Get(name string, options v1.GetOptions) (*v1beta1.VolumeSnapshot, error) + List(opts v1.ListOptions) (*v1beta1.VolumeSnapshotList, error) Watch(opts v1.ListOptions) (watch.Interface, error) - Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.VolumeSnapshot, err error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.VolumeSnapshot, err error) VolumeSnapshotExpansion } @@ -56,7 +56,7 @@ type volumeSnapshots struct { } // newVolumeSnapshots returns a VolumeSnapshots -func newVolumeSnapshots(c *SnapshotV1alpha1Client, namespace string) *volumeSnapshots { +func newVolumeSnapshots(c *SnapshotV1beta1Client, namespace string) *volumeSnapshots { return &volumeSnapshots{ client: c.RESTClient(), ns: namespace, @@ -64,8 +64,8 @@ func newVolumeSnapshots(c *SnapshotV1alpha1Client, namespace string) *volumeSnap } // Get takes name of the volumeSnapshot, and returns the corresponding volumeSnapshot object, and an error if there is any. -func (c *volumeSnapshots) Get(name string, options v1.GetOptions) (result *v1alpha1.VolumeSnapshot, err error) { - result = &v1alpha1.VolumeSnapshot{} +func (c *volumeSnapshots) Get(name string, options v1.GetOptions) (result *v1beta1.VolumeSnapshot, err error) { + result = &v1beta1.VolumeSnapshot{} err = c.client.Get(). Namespace(c.ns). Resource("volumesnapshots"). @@ -77,12 +77,12 @@ func (c *volumeSnapshots) Get(name string, options v1.GetOptions) (result *v1alp } // List takes label and field selectors, and returns the list of VolumeSnapshots that match those selectors. -func (c *volumeSnapshots) List(opts v1.ListOptions) (result *v1alpha1.VolumeSnapshotList, err error) { +func (c *volumeSnapshots) List(opts v1.ListOptions) (result *v1beta1.VolumeSnapshotList, err error) { var timeout time.Duration if opts.TimeoutSeconds != nil { timeout = time.Duration(*opts.TimeoutSeconds) * time.Second } - result = &v1alpha1.VolumeSnapshotList{} + result = &v1beta1.VolumeSnapshotList{} err = c.client.Get(). Namespace(c.ns). Resource("volumesnapshots"). @@ -109,8 +109,8 @@ func (c *volumeSnapshots) Watch(opts v1.ListOptions) (watch.Interface, error) { } // Create takes the representation of a volumeSnapshot and creates it. Returns the server's representation of the volumeSnapshot, and an error, if there is any. -func (c *volumeSnapshots) Create(volumeSnapshot *v1alpha1.VolumeSnapshot) (result *v1alpha1.VolumeSnapshot, err error) { - result = &v1alpha1.VolumeSnapshot{} +func (c *volumeSnapshots) Create(volumeSnapshot *v1beta1.VolumeSnapshot) (result *v1beta1.VolumeSnapshot, err error) { + result = &v1beta1.VolumeSnapshot{} err = c.client.Post(). Namespace(c.ns). Resource("volumesnapshots"). @@ -121,8 +121,8 @@ func (c *volumeSnapshots) Create(volumeSnapshot *v1alpha1.VolumeSnapshot) (resul } // Update takes the representation of a volumeSnapshot and updates it. Returns the server's representation of the volumeSnapshot, and an error, if there is any. -func (c *volumeSnapshots) Update(volumeSnapshot *v1alpha1.VolumeSnapshot) (result *v1alpha1.VolumeSnapshot, err error) { - result = &v1alpha1.VolumeSnapshot{} +func (c *volumeSnapshots) Update(volumeSnapshot *v1beta1.VolumeSnapshot) (result *v1beta1.VolumeSnapshot, err error) { + result = &v1beta1.VolumeSnapshot{} err = c.client.Put(). Namespace(c.ns). Resource("volumesnapshots"). @@ -136,8 +136,8 @@ func (c *volumeSnapshots) Update(volumeSnapshot *v1alpha1.VolumeSnapshot) (resul // UpdateStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *volumeSnapshots) UpdateStatus(volumeSnapshot *v1alpha1.VolumeSnapshot) (result *v1alpha1.VolumeSnapshot, err error) { - result = &v1alpha1.VolumeSnapshot{} +func (c *volumeSnapshots) UpdateStatus(volumeSnapshot *v1beta1.VolumeSnapshot) (result *v1beta1.VolumeSnapshot, err error) { + result = &v1beta1.VolumeSnapshot{} err = c.client.Put(). Namespace(c.ns). Resource("volumesnapshots"). @@ -177,8 +177,8 @@ func (c *volumeSnapshots) DeleteCollection(options *v1.DeleteOptions, listOption } // Patch applies the patch and returns the patched volumeSnapshot. -func (c *volumeSnapshots) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.VolumeSnapshot, err error) { - result = &v1alpha1.VolumeSnapshot{} +func (c *volumeSnapshots) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.VolumeSnapshot, err error) { + result = &v1beta1.VolumeSnapshot{} err = c.client.Patch(pt). Namespace(c.ns). Resource("volumesnapshots"). diff --git a/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/volumesnapshot_client.go b/pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/volumesnapshot_client.go similarity index 61% rename from pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/volumesnapshot_client.go rename to pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/volumesnapshot_client.go index ba06f6576..574860496 100644 --- a/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/volumesnapshot_client.go +++ b/pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/volumesnapshot_client.go @@ -16,41 +16,41 @@ limitations under the License. // Code generated by client-gen. DO NOT EDIT. -package v1alpha1 +package v1beta1 import ( - v1alpha1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + v1beta1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" "github.com/kubernetes-csi/external-snapshotter/pkg/client/clientset/versioned/scheme" serializer "k8s.io/apimachinery/pkg/runtime/serializer" rest "k8s.io/client-go/rest" ) -type SnapshotV1alpha1Interface interface { +type SnapshotV1beta1Interface interface { RESTClient() rest.Interface VolumeSnapshotsGetter VolumeSnapshotClassesGetter VolumeSnapshotContentsGetter } -// SnapshotV1alpha1Client is used to interact with features provided by the snapshot.storage.k8s.io group. -type SnapshotV1alpha1Client struct { +// SnapshotV1beta1Client is used to interact with features provided by the snapshot.storage.k8s.io group. +type SnapshotV1beta1Client struct { restClient rest.Interface } -func (c *SnapshotV1alpha1Client) VolumeSnapshots(namespace string) VolumeSnapshotInterface { +func (c *SnapshotV1beta1Client) VolumeSnapshots(namespace string) VolumeSnapshotInterface { return newVolumeSnapshots(c, namespace) } -func (c *SnapshotV1alpha1Client) VolumeSnapshotClasses() VolumeSnapshotClassInterface { +func (c *SnapshotV1beta1Client) VolumeSnapshotClasses() VolumeSnapshotClassInterface { return newVolumeSnapshotClasses(c) } -func (c *SnapshotV1alpha1Client) VolumeSnapshotContents() VolumeSnapshotContentInterface { +func (c *SnapshotV1beta1Client) VolumeSnapshotContents() VolumeSnapshotContentInterface { return newVolumeSnapshotContents(c) } -// NewForConfig creates a new SnapshotV1alpha1Client for the given config. -func NewForConfig(c *rest.Config) (*SnapshotV1alpha1Client, error) { +// NewForConfig creates a new SnapshotV1beta1Client for the given config. +func NewForConfig(c *rest.Config) (*SnapshotV1beta1Client, error) { config := *c if err := setConfigDefaults(&config); err != nil { return nil, err @@ -59,12 +59,12 @@ func NewForConfig(c *rest.Config) (*SnapshotV1alpha1Client, error) { if err != nil { return nil, err } - return &SnapshotV1alpha1Client{client}, nil + return &SnapshotV1beta1Client{client}, nil } -// NewForConfigOrDie creates a new SnapshotV1alpha1Client for the given config and +// NewForConfigOrDie creates a new SnapshotV1beta1Client for the given config and // panics if there is an error in the config. -func NewForConfigOrDie(c *rest.Config) *SnapshotV1alpha1Client { +func NewForConfigOrDie(c *rest.Config) *SnapshotV1beta1Client { client, err := NewForConfig(c) if err != nil { panic(err) @@ -72,13 +72,13 @@ func NewForConfigOrDie(c *rest.Config) *SnapshotV1alpha1Client { return client } -// New creates a new SnapshotV1alpha1Client for the given RESTClient. -func New(c rest.Interface) *SnapshotV1alpha1Client { - return &SnapshotV1alpha1Client{c} +// New creates a new SnapshotV1beta1Client for the given RESTClient. +func New(c rest.Interface) *SnapshotV1beta1Client { + return &SnapshotV1beta1Client{c} } func setConfigDefaults(config *rest.Config) error { - gv := v1alpha1.SchemeGroupVersion + gv := v1beta1.SchemeGroupVersion config.GroupVersion = &gv config.APIPath = "/apis" config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: scheme.Codecs} @@ -92,7 +92,7 @@ func setConfigDefaults(config *rest.Config) error { // RESTClient returns a RESTClient that is used to communicate // with API server by this client implementation. -func (c *SnapshotV1alpha1Client) RESTClient() rest.Interface { +func (c *SnapshotV1beta1Client) RESTClient() rest.Interface { if c == nil { return nil } diff --git a/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/volumesnapshotclass.go b/pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/volumesnapshotclass.go similarity index 79% rename from pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/volumesnapshotclass.go rename to pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/volumesnapshotclass.go index 8b788df4a..4a8e1d324 100644 --- a/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/volumesnapshotclass.go +++ b/pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/volumesnapshotclass.go @@ -16,12 +16,12 @@ limitations under the License. // Code generated by client-gen. DO NOT EDIT. -package v1alpha1 +package v1beta1 import ( "time" - v1alpha1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + v1beta1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" scheme "github.com/kubernetes-csi/external-snapshotter/pkg/client/clientset/versioned/scheme" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" types "k8s.io/apimachinery/pkg/types" @@ -37,14 +37,14 @@ type VolumeSnapshotClassesGetter interface { // VolumeSnapshotClassInterface has methods to work with VolumeSnapshotClass resources. type VolumeSnapshotClassInterface interface { - Create(*v1alpha1.VolumeSnapshotClass) (*v1alpha1.VolumeSnapshotClass, error) - Update(*v1alpha1.VolumeSnapshotClass) (*v1alpha1.VolumeSnapshotClass, error) + Create(*v1beta1.VolumeSnapshotClass) (*v1beta1.VolumeSnapshotClass, error) + Update(*v1beta1.VolumeSnapshotClass) (*v1beta1.VolumeSnapshotClass, error) Delete(name string, options *v1.DeleteOptions) error DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error - Get(name string, options v1.GetOptions) (*v1alpha1.VolumeSnapshotClass, error) - List(opts v1.ListOptions) (*v1alpha1.VolumeSnapshotClassList, error) + Get(name string, options v1.GetOptions) (*v1beta1.VolumeSnapshotClass, error) + List(opts v1.ListOptions) (*v1beta1.VolumeSnapshotClassList, error) Watch(opts v1.ListOptions) (watch.Interface, error) - Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.VolumeSnapshotClass, err error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.VolumeSnapshotClass, err error) VolumeSnapshotClassExpansion } @@ -54,15 +54,15 @@ type volumeSnapshotClasses struct { } // newVolumeSnapshotClasses returns a VolumeSnapshotClasses -func newVolumeSnapshotClasses(c *SnapshotV1alpha1Client) *volumeSnapshotClasses { +func newVolumeSnapshotClasses(c *SnapshotV1beta1Client) *volumeSnapshotClasses { return &volumeSnapshotClasses{ client: c.RESTClient(), } } // Get takes name of the volumeSnapshotClass, and returns the corresponding volumeSnapshotClass object, and an error if there is any. -func (c *volumeSnapshotClasses) Get(name string, options v1.GetOptions) (result *v1alpha1.VolumeSnapshotClass, err error) { - result = &v1alpha1.VolumeSnapshotClass{} +func (c *volumeSnapshotClasses) Get(name string, options v1.GetOptions) (result *v1beta1.VolumeSnapshotClass, err error) { + result = &v1beta1.VolumeSnapshotClass{} err = c.client.Get(). Resource("volumesnapshotclasses"). Name(name). @@ -73,12 +73,12 @@ func (c *volumeSnapshotClasses) Get(name string, options v1.GetOptions) (result } // List takes label and field selectors, and returns the list of VolumeSnapshotClasses that match those selectors. -func (c *volumeSnapshotClasses) List(opts v1.ListOptions) (result *v1alpha1.VolumeSnapshotClassList, err error) { +func (c *volumeSnapshotClasses) List(opts v1.ListOptions) (result *v1beta1.VolumeSnapshotClassList, err error) { var timeout time.Duration if opts.TimeoutSeconds != nil { timeout = time.Duration(*opts.TimeoutSeconds) * time.Second } - result = &v1alpha1.VolumeSnapshotClassList{} + result = &v1beta1.VolumeSnapshotClassList{} err = c.client.Get(). Resource("volumesnapshotclasses"). VersionedParams(&opts, scheme.ParameterCodec). @@ -103,8 +103,8 @@ func (c *volumeSnapshotClasses) Watch(opts v1.ListOptions) (watch.Interface, err } // Create takes the representation of a volumeSnapshotClass and creates it. Returns the server's representation of the volumeSnapshotClass, and an error, if there is any. -func (c *volumeSnapshotClasses) Create(volumeSnapshotClass *v1alpha1.VolumeSnapshotClass) (result *v1alpha1.VolumeSnapshotClass, err error) { - result = &v1alpha1.VolumeSnapshotClass{} +func (c *volumeSnapshotClasses) Create(volumeSnapshotClass *v1beta1.VolumeSnapshotClass) (result *v1beta1.VolumeSnapshotClass, err error) { + result = &v1beta1.VolumeSnapshotClass{} err = c.client.Post(). Resource("volumesnapshotclasses"). Body(volumeSnapshotClass). @@ -114,8 +114,8 @@ func (c *volumeSnapshotClasses) Create(volumeSnapshotClass *v1alpha1.VolumeSnaps } // Update takes the representation of a volumeSnapshotClass and updates it. Returns the server's representation of the volumeSnapshotClass, and an error, if there is any. -func (c *volumeSnapshotClasses) Update(volumeSnapshotClass *v1alpha1.VolumeSnapshotClass) (result *v1alpha1.VolumeSnapshotClass, err error) { - result = &v1alpha1.VolumeSnapshotClass{} +func (c *volumeSnapshotClasses) Update(volumeSnapshotClass *v1beta1.VolumeSnapshotClass) (result *v1beta1.VolumeSnapshotClass, err error) { + result = &v1beta1.VolumeSnapshotClass{} err = c.client.Put(). Resource("volumesnapshotclasses"). Name(volumeSnapshotClass.Name). @@ -151,8 +151,8 @@ func (c *volumeSnapshotClasses) DeleteCollection(options *v1.DeleteOptions, list } // Patch applies the patch and returns the patched volumeSnapshotClass. -func (c *volumeSnapshotClasses) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.VolumeSnapshotClass, err error) { - result = &v1alpha1.VolumeSnapshotClass{} +func (c *volumeSnapshotClasses) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.VolumeSnapshotClass, err error) { + result = &v1beta1.VolumeSnapshotClass{} err = c.client.Patch(pt). Resource("volumesnapshotclasses"). SubResource(subresources...). diff --git a/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/volumesnapshotcontent.go b/pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/volumesnapshotcontent.go similarity index 80% rename from pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/volumesnapshotcontent.go rename to pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/volumesnapshotcontent.go index e393ccdfe..5f5e3d7a6 100644 --- a/pkg/client/clientset/versioned/typed/volumesnapshot/v1alpha1/volumesnapshotcontent.go +++ b/pkg/client/clientset/versioned/typed/volumesnapshot/v1beta1/volumesnapshotcontent.go @@ -16,12 +16,12 @@ limitations under the License. // Code generated by client-gen. DO NOT EDIT. -package v1alpha1 +package v1beta1 import ( "time" - v1alpha1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + v1beta1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" scheme "github.com/kubernetes-csi/external-snapshotter/pkg/client/clientset/versioned/scheme" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" types "k8s.io/apimachinery/pkg/types" @@ -37,14 +37,14 @@ type VolumeSnapshotContentsGetter interface { // VolumeSnapshotContentInterface has methods to work with VolumeSnapshotContent resources. type VolumeSnapshotContentInterface interface { - Create(*v1alpha1.VolumeSnapshotContent) (*v1alpha1.VolumeSnapshotContent, error) - Update(*v1alpha1.VolumeSnapshotContent) (*v1alpha1.VolumeSnapshotContent, error) + Create(*v1beta1.VolumeSnapshotContent) (*v1beta1.VolumeSnapshotContent, error) + Update(*v1beta1.VolumeSnapshotContent) (*v1beta1.VolumeSnapshotContent, error) Delete(name string, options *v1.DeleteOptions) error DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error - Get(name string, options v1.GetOptions) (*v1alpha1.VolumeSnapshotContent, error) - List(opts v1.ListOptions) (*v1alpha1.VolumeSnapshotContentList, error) + Get(name string, options v1.GetOptions) (*v1beta1.VolumeSnapshotContent, error) + List(opts v1.ListOptions) (*v1beta1.VolumeSnapshotContentList, error) Watch(opts v1.ListOptions) (watch.Interface, error) - Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.VolumeSnapshotContent, err error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.VolumeSnapshotContent, err error) VolumeSnapshotContentExpansion } @@ -54,15 +54,15 @@ type volumeSnapshotContents struct { } // newVolumeSnapshotContents returns a VolumeSnapshotContents -func newVolumeSnapshotContents(c *SnapshotV1alpha1Client) *volumeSnapshotContents { +func newVolumeSnapshotContents(c *SnapshotV1beta1Client) *volumeSnapshotContents { return &volumeSnapshotContents{ client: c.RESTClient(), } } // Get takes name of the volumeSnapshotContent, and returns the corresponding volumeSnapshotContent object, and an error if there is any. -func (c *volumeSnapshotContents) Get(name string, options v1.GetOptions) (result *v1alpha1.VolumeSnapshotContent, err error) { - result = &v1alpha1.VolumeSnapshotContent{} +func (c *volumeSnapshotContents) Get(name string, options v1.GetOptions) (result *v1beta1.VolumeSnapshotContent, err error) { + result = &v1beta1.VolumeSnapshotContent{} err = c.client.Get(). Resource("volumesnapshotcontents"). Name(name). @@ -73,12 +73,12 @@ func (c *volumeSnapshotContents) Get(name string, options v1.GetOptions) (result } // List takes label and field selectors, and returns the list of VolumeSnapshotContents that match those selectors. -func (c *volumeSnapshotContents) List(opts v1.ListOptions) (result *v1alpha1.VolumeSnapshotContentList, err error) { +func (c *volumeSnapshotContents) List(opts v1.ListOptions) (result *v1beta1.VolumeSnapshotContentList, err error) { var timeout time.Duration if opts.TimeoutSeconds != nil { timeout = time.Duration(*opts.TimeoutSeconds) * time.Second } - result = &v1alpha1.VolumeSnapshotContentList{} + result = &v1beta1.VolumeSnapshotContentList{} err = c.client.Get(). Resource("volumesnapshotcontents"). VersionedParams(&opts, scheme.ParameterCodec). @@ -103,8 +103,8 @@ func (c *volumeSnapshotContents) Watch(opts v1.ListOptions) (watch.Interface, er } // Create takes the representation of a volumeSnapshotContent and creates it. Returns the server's representation of the volumeSnapshotContent, and an error, if there is any. -func (c *volumeSnapshotContents) Create(volumeSnapshotContent *v1alpha1.VolumeSnapshotContent) (result *v1alpha1.VolumeSnapshotContent, err error) { - result = &v1alpha1.VolumeSnapshotContent{} +func (c *volumeSnapshotContents) Create(volumeSnapshotContent *v1beta1.VolumeSnapshotContent) (result *v1beta1.VolumeSnapshotContent, err error) { + result = &v1beta1.VolumeSnapshotContent{} err = c.client.Post(). Resource("volumesnapshotcontents"). Body(volumeSnapshotContent). @@ -114,8 +114,8 @@ func (c *volumeSnapshotContents) Create(volumeSnapshotContent *v1alpha1.VolumeSn } // Update takes the representation of a volumeSnapshotContent and updates it. Returns the server's representation of the volumeSnapshotContent, and an error, if there is any. -func (c *volumeSnapshotContents) Update(volumeSnapshotContent *v1alpha1.VolumeSnapshotContent) (result *v1alpha1.VolumeSnapshotContent, err error) { - result = &v1alpha1.VolumeSnapshotContent{} +func (c *volumeSnapshotContents) Update(volumeSnapshotContent *v1beta1.VolumeSnapshotContent) (result *v1beta1.VolumeSnapshotContent, err error) { + result = &v1beta1.VolumeSnapshotContent{} err = c.client.Put(). Resource("volumesnapshotcontents"). Name(volumeSnapshotContent.Name). @@ -151,8 +151,8 @@ func (c *volumeSnapshotContents) DeleteCollection(options *v1.DeleteOptions, lis } // Patch applies the patch and returns the patched volumeSnapshotContent. -func (c *volumeSnapshotContents) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.VolumeSnapshotContent, err error) { - result = &v1alpha1.VolumeSnapshotContent{} +func (c *volumeSnapshotContents) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.VolumeSnapshotContent, err error) { + result = &v1beta1.VolumeSnapshotContent{} err = c.client.Patch(pt). Resource("volumesnapshotcontents"). SubResource(subresources...). diff --git a/pkg/client/informers/externalversions/generic.go b/pkg/client/informers/externalversions/generic.go index 193942d0e..abf7d5fa8 100644 --- a/pkg/client/informers/externalversions/generic.go +++ b/pkg/client/informers/externalversions/generic.go @@ -21,7 +21,7 @@ package externalversions import ( "fmt" - v1alpha1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + v1beta1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" schema "k8s.io/apimachinery/pkg/runtime/schema" cache "k8s.io/client-go/tools/cache" ) @@ -52,13 +52,13 @@ func (f *genericInformer) Lister() cache.GenericLister { // TODO extend this to unknown resources with a client pool func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { switch resource { - // Group=snapshot.storage.k8s.io, Version=v1alpha1 - case v1alpha1.SchemeGroupVersion.WithResource("volumesnapshots"): - return &genericInformer{resource: resource.GroupResource(), informer: f.Snapshot().V1alpha1().VolumeSnapshots().Informer()}, nil - case v1alpha1.SchemeGroupVersion.WithResource("volumesnapshotclasses"): - return &genericInformer{resource: resource.GroupResource(), informer: f.Snapshot().V1alpha1().VolumeSnapshotClasses().Informer()}, nil - case v1alpha1.SchemeGroupVersion.WithResource("volumesnapshotcontents"): - return &genericInformer{resource: resource.GroupResource(), informer: f.Snapshot().V1alpha1().VolumeSnapshotContents().Informer()}, nil + // Group=snapshot.storage.k8s.io, Version=v1beta1 + case v1beta1.SchemeGroupVersion.WithResource("volumesnapshots"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Snapshot().V1beta1().VolumeSnapshots().Informer()}, nil + case v1beta1.SchemeGroupVersion.WithResource("volumesnapshotclasses"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Snapshot().V1beta1().VolumeSnapshotClasses().Informer()}, nil + case v1beta1.SchemeGroupVersion.WithResource("volumesnapshotcontents"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Snapshot().V1beta1().VolumeSnapshotContents().Informer()}, nil } diff --git a/pkg/client/informers/externalversions/volumesnapshot/interface.go b/pkg/client/informers/externalversions/volumesnapshot/interface.go index ba406ea94..874ea3dc1 100644 --- a/pkg/client/informers/externalversions/volumesnapshot/interface.go +++ b/pkg/client/informers/externalversions/volumesnapshot/interface.go @@ -20,13 +20,13 @@ package snapshot import ( internalinterfaces "github.com/kubernetes-csi/external-snapshotter/pkg/client/informers/externalversions/internalinterfaces" - v1alpha1 "github.com/kubernetes-csi/external-snapshotter/pkg/client/informers/externalversions/volumesnapshot/v1alpha1" + v1beta1 "github.com/kubernetes-csi/external-snapshotter/pkg/client/informers/externalversions/volumesnapshot/v1beta1" ) // Interface provides access to each of this group's versions. type Interface interface { - // V1alpha1 provides access to shared informers for resources in V1alpha1. - V1alpha1() v1alpha1.Interface + // V1beta1 provides access to shared informers for resources in V1beta1. + V1beta1() v1beta1.Interface } type group struct { @@ -40,7 +40,7 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} } -// V1alpha1 returns a new v1alpha1.Interface. -func (g *group) V1alpha1() v1alpha1.Interface { - return v1alpha1.New(g.factory, g.namespace, g.tweakListOptions) +// V1beta1 returns a new v1beta1.Interface. +func (g *group) V1beta1() v1beta1.Interface { + return v1beta1.New(g.factory, g.namespace, g.tweakListOptions) } diff --git a/pkg/client/informers/externalversions/volumesnapshot/v1alpha1/interface.go b/pkg/client/informers/externalversions/volumesnapshot/v1beta1/interface.go similarity index 99% rename from pkg/client/informers/externalversions/volumesnapshot/v1alpha1/interface.go rename to pkg/client/informers/externalversions/volumesnapshot/v1beta1/interface.go index ded10e911..ecccf563e 100644 --- a/pkg/client/informers/externalversions/volumesnapshot/v1alpha1/interface.go +++ b/pkg/client/informers/externalversions/volumesnapshot/v1beta1/interface.go @@ -16,7 +16,7 @@ limitations under the License. // Code generated by informer-gen. DO NOT EDIT. -package v1alpha1 +package v1beta1 import ( internalinterfaces "github.com/kubernetes-csi/external-snapshotter/pkg/client/informers/externalversions/internalinterfaces" diff --git a/pkg/client/informers/externalversions/volumesnapshot/v1alpha1/volumesnapshot.go b/pkg/client/informers/externalversions/volumesnapshot/v1beta1/volumesnapshot.go similarity index 81% rename from pkg/client/informers/externalversions/volumesnapshot/v1alpha1/volumesnapshot.go rename to pkg/client/informers/externalversions/volumesnapshot/v1beta1/volumesnapshot.go index babb79b87..211b6f5f1 100644 --- a/pkg/client/informers/externalversions/volumesnapshot/v1alpha1/volumesnapshot.go +++ b/pkg/client/informers/externalversions/volumesnapshot/v1beta1/volumesnapshot.go @@ -16,15 +16,15 @@ limitations under the License. // Code generated by informer-gen. DO NOT EDIT. -package v1alpha1 +package v1beta1 import ( time "time" - volumesnapshotv1alpha1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + volumesnapshotv1beta1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" versioned "github.com/kubernetes-csi/external-snapshotter/pkg/client/clientset/versioned" internalinterfaces "github.com/kubernetes-csi/external-snapshotter/pkg/client/informers/externalversions/internalinterfaces" - v1alpha1 "github.com/kubernetes-csi/external-snapshotter/pkg/client/listers/volumesnapshot/v1alpha1" + v1beta1 "github.com/kubernetes-csi/external-snapshotter/pkg/client/listers/volumesnapshot/v1beta1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" watch "k8s.io/apimachinery/pkg/watch" @@ -35,7 +35,7 @@ import ( // VolumeSnapshots. type VolumeSnapshotInformer interface { Informer() cache.SharedIndexInformer - Lister() v1alpha1.VolumeSnapshotLister + Lister() v1beta1.VolumeSnapshotLister } type volumeSnapshotInformer struct { @@ -61,16 +61,16 @@ func NewFilteredVolumeSnapshotInformer(client versioned.Interface, namespace str if tweakListOptions != nil { tweakListOptions(&options) } - return client.SnapshotV1alpha1().VolumeSnapshots(namespace).List(options) + return client.SnapshotV1beta1().VolumeSnapshots(namespace).List(options) }, WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.SnapshotV1alpha1().VolumeSnapshots(namespace).Watch(options) + return client.SnapshotV1beta1().VolumeSnapshots(namespace).Watch(options) }, }, - &volumesnapshotv1alpha1.VolumeSnapshot{}, + &volumesnapshotv1beta1.VolumeSnapshot{}, resyncPeriod, indexers, ) @@ -81,9 +81,9 @@ func (f *volumeSnapshotInformer) defaultInformer(client versioned.Interface, res } func (f *volumeSnapshotInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&volumesnapshotv1alpha1.VolumeSnapshot{}, f.defaultInformer) + return f.factory.InformerFor(&volumesnapshotv1beta1.VolumeSnapshot{}, f.defaultInformer) } -func (f *volumeSnapshotInformer) Lister() v1alpha1.VolumeSnapshotLister { - return v1alpha1.NewVolumeSnapshotLister(f.Informer().GetIndexer()) +func (f *volumeSnapshotInformer) Lister() v1beta1.VolumeSnapshotLister { + return v1beta1.NewVolumeSnapshotLister(f.Informer().GetIndexer()) } diff --git a/pkg/client/informers/externalversions/volumesnapshot/v1alpha1/volumesnapshotclass.go b/pkg/client/informers/externalversions/volumesnapshot/v1beta1/volumesnapshotclass.go similarity index 81% rename from pkg/client/informers/externalversions/volumesnapshot/v1alpha1/volumesnapshotclass.go rename to pkg/client/informers/externalversions/volumesnapshot/v1beta1/volumesnapshotclass.go index 0026e5572..800e12428 100644 --- a/pkg/client/informers/externalversions/volumesnapshot/v1alpha1/volumesnapshotclass.go +++ b/pkg/client/informers/externalversions/volumesnapshot/v1beta1/volumesnapshotclass.go @@ -16,15 +16,15 @@ limitations under the License. // Code generated by informer-gen. DO NOT EDIT. -package v1alpha1 +package v1beta1 import ( time "time" - volumesnapshotv1alpha1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + volumesnapshotv1beta1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" versioned "github.com/kubernetes-csi/external-snapshotter/pkg/client/clientset/versioned" internalinterfaces "github.com/kubernetes-csi/external-snapshotter/pkg/client/informers/externalversions/internalinterfaces" - v1alpha1 "github.com/kubernetes-csi/external-snapshotter/pkg/client/listers/volumesnapshot/v1alpha1" + v1beta1 "github.com/kubernetes-csi/external-snapshotter/pkg/client/listers/volumesnapshot/v1beta1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" watch "k8s.io/apimachinery/pkg/watch" @@ -35,7 +35,7 @@ import ( // VolumeSnapshotClasses. type VolumeSnapshotClassInformer interface { Informer() cache.SharedIndexInformer - Lister() v1alpha1.VolumeSnapshotClassLister + Lister() v1beta1.VolumeSnapshotClassLister } type volumeSnapshotClassInformer struct { @@ -60,16 +60,16 @@ func NewFilteredVolumeSnapshotClassInformer(client versioned.Interface, resyncPe if tweakListOptions != nil { tweakListOptions(&options) } - return client.SnapshotV1alpha1().VolumeSnapshotClasses().List(options) + return client.SnapshotV1beta1().VolumeSnapshotClasses().List(options) }, WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.SnapshotV1alpha1().VolumeSnapshotClasses().Watch(options) + return client.SnapshotV1beta1().VolumeSnapshotClasses().Watch(options) }, }, - &volumesnapshotv1alpha1.VolumeSnapshotClass{}, + &volumesnapshotv1beta1.VolumeSnapshotClass{}, resyncPeriod, indexers, ) @@ -80,9 +80,9 @@ func (f *volumeSnapshotClassInformer) defaultInformer(client versioned.Interface } func (f *volumeSnapshotClassInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&volumesnapshotv1alpha1.VolumeSnapshotClass{}, f.defaultInformer) + return f.factory.InformerFor(&volumesnapshotv1beta1.VolumeSnapshotClass{}, f.defaultInformer) } -func (f *volumeSnapshotClassInformer) Lister() v1alpha1.VolumeSnapshotClassLister { - return v1alpha1.NewVolumeSnapshotClassLister(f.Informer().GetIndexer()) +func (f *volumeSnapshotClassInformer) Lister() v1beta1.VolumeSnapshotClassLister { + return v1beta1.NewVolumeSnapshotClassLister(f.Informer().GetIndexer()) } diff --git a/pkg/client/informers/externalversions/volumesnapshot/v1alpha1/volumesnapshotcontent.go b/pkg/client/informers/externalversions/volumesnapshot/v1beta1/volumesnapshotcontent.go similarity index 81% rename from pkg/client/informers/externalversions/volumesnapshot/v1alpha1/volumesnapshotcontent.go rename to pkg/client/informers/externalversions/volumesnapshot/v1beta1/volumesnapshotcontent.go index 2b34344d5..835292145 100644 --- a/pkg/client/informers/externalversions/volumesnapshot/v1alpha1/volumesnapshotcontent.go +++ b/pkg/client/informers/externalversions/volumesnapshot/v1beta1/volumesnapshotcontent.go @@ -16,15 +16,15 @@ limitations under the License. // Code generated by informer-gen. DO NOT EDIT. -package v1alpha1 +package v1beta1 import ( time "time" - volumesnapshotv1alpha1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + volumesnapshotv1beta1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" versioned "github.com/kubernetes-csi/external-snapshotter/pkg/client/clientset/versioned" internalinterfaces "github.com/kubernetes-csi/external-snapshotter/pkg/client/informers/externalversions/internalinterfaces" - v1alpha1 "github.com/kubernetes-csi/external-snapshotter/pkg/client/listers/volumesnapshot/v1alpha1" + v1beta1 "github.com/kubernetes-csi/external-snapshotter/pkg/client/listers/volumesnapshot/v1beta1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" watch "k8s.io/apimachinery/pkg/watch" @@ -35,7 +35,7 @@ import ( // VolumeSnapshotContents. type VolumeSnapshotContentInformer interface { Informer() cache.SharedIndexInformer - Lister() v1alpha1.VolumeSnapshotContentLister + Lister() v1beta1.VolumeSnapshotContentLister } type volumeSnapshotContentInformer struct { @@ -60,16 +60,16 @@ func NewFilteredVolumeSnapshotContentInformer(client versioned.Interface, resync if tweakListOptions != nil { tweakListOptions(&options) } - return client.SnapshotV1alpha1().VolumeSnapshotContents().List(options) + return client.SnapshotV1beta1().VolumeSnapshotContents().List(options) }, WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.SnapshotV1alpha1().VolumeSnapshotContents().Watch(options) + return client.SnapshotV1beta1().VolumeSnapshotContents().Watch(options) }, }, - &volumesnapshotv1alpha1.VolumeSnapshotContent{}, + &volumesnapshotv1beta1.VolumeSnapshotContent{}, resyncPeriod, indexers, ) @@ -80,9 +80,9 @@ func (f *volumeSnapshotContentInformer) defaultInformer(client versioned.Interfa } func (f *volumeSnapshotContentInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&volumesnapshotv1alpha1.VolumeSnapshotContent{}, f.defaultInformer) + return f.factory.InformerFor(&volumesnapshotv1beta1.VolumeSnapshotContent{}, f.defaultInformer) } -func (f *volumeSnapshotContentInformer) Lister() v1alpha1.VolumeSnapshotContentLister { - return v1alpha1.NewVolumeSnapshotContentLister(f.Informer().GetIndexer()) +func (f *volumeSnapshotContentInformer) Lister() v1beta1.VolumeSnapshotContentLister { + return v1beta1.NewVolumeSnapshotContentLister(f.Informer().GetIndexer()) } diff --git a/pkg/client/listers/volumesnapshot/v1alpha1/expansion_generated.go b/pkg/client/listers/volumesnapshot/v1beta1/expansion_generated.go similarity index 98% rename from pkg/client/listers/volumesnapshot/v1alpha1/expansion_generated.go rename to pkg/client/listers/volumesnapshot/v1beta1/expansion_generated.go index f92624ed7..100865bcb 100644 --- a/pkg/client/listers/volumesnapshot/v1alpha1/expansion_generated.go +++ b/pkg/client/listers/volumesnapshot/v1beta1/expansion_generated.go @@ -16,7 +16,7 @@ limitations under the License. // Code generated by lister-gen. DO NOT EDIT. -package v1alpha1 +package v1beta1 // VolumeSnapshotListerExpansion allows custom methods to be added to // VolumeSnapshotLister. diff --git a/pkg/client/listers/volumesnapshot/v1alpha1/volumesnapshot.go b/pkg/client/listers/volumesnapshot/v1beta1/volumesnapshot.go similarity index 79% rename from pkg/client/listers/volumesnapshot/v1alpha1/volumesnapshot.go rename to pkg/client/listers/volumesnapshot/v1beta1/volumesnapshot.go index ffa8f16d8..4309a30e6 100644 --- a/pkg/client/listers/volumesnapshot/v1alpha1/volumesnapshot.go +++ b/pkg/client/listers/volumesnapshot/v1beta1/volumesnapshot.go @@ -16,10 +16,10 @@ limitations under the License. // Code generated by lister-gen. DO NOT EDIT. -package v1alpha1 +package v1beta1 import ( - v1alpha1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + v1beta1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" "k8s.io/client-go/tools/cache" @@ -28,7 +28,7 @@ import ( // VolumeSnapshotLister helps list VolumeSnapshots. type VolumeSnapshotLister interface { // List lists all VolumeSnapshots in the indexer. - List(selector labels.Selector) (ret []*v1alpha1.VolumeSnapshot, err error) + List(selector labels.Selector) (ret []*v1beta1.VolumeSnapshot, err error) // VolumeSnapshots returns an object that can list and get VolumeSnapshots. VolumeSnapshots(namespace string) VolumeSnapshotNamespaceLister VolumeSnapshotListerExpansion @@ -45,9 +45,9 @@ func NewVolumeSnapshotLister(indexer cache.Indexer) VolumeSnapshotLister { } // List lists all VolumeSnapshots in the indexer. -func (s *volumeSnapshotLister) List(selector labels.Selector) (ret []*v1alpha1.VolumeSnapshot, err error) { +func (s *volumeSnapshotLister) List(selector labels.Selector) (ret []*v1beta1.VolumeSnapshot, err error) { err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.VolumeSnapshot)) + ret = append(ret, m.(*v1beta1.VolumeSnapshot)) }) return ret, err } @@ -60,9 +60,9 @@ func (s *volumeSnapshotLister) VolumeSnapshots(namespace string) VolumeSnapshotN // VolumeSnapshotNamespaceLister helps list and get VolumeSnapshots. type VolumeSnapshotNamespaceLister interface { // List lists all VolumeSnapshots in the indexer for a given namespace. - List(selector labels.Selector) (ret []*v1alpha1.VolumeSnapshot, err error) + List(selector labels.Selector) (ret []*v1beta1.VolumeSnapshot, err error) // Get retrieves the VolumeSnapshot from the indexer for a given namespace and name. - Get(name string) (*v1alpha1.VolumeSnapshot, error) + Get(name string) (*v1beta1.VolumeSnapshot, error) VolumeSnapshotNamespaceListerExpansion } @@ -74,21 +74,21 @@ type volumeSnapshotNamespaceLister struct { } // List lists all VolumeSnapshots in the indexer for a given namespace. -func (s volumeSnapshotNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.VolumeSnapshot, err error) { +func (s volumeSnapshotNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.VolumeSnapshot, err error) { err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.VolumeSnapshot)) + ret = append(ret, m.(*v1beta1.VolumeSnapshot)) }) return ret, err } // Get retrieves the VolumeSnapshot from the indexer for a given namespace and name. -func (s volumeSnapshotNamespaceLister) Get(name string) (*v1alpha1.VolumeSnapshot, error) { +func (s volumeSnapshotNamespaceLister) Get(name string) (*v1beta1.VolumeSnapshot, error) { obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) if err != nil { return nil, err } if !exists { - return nil, errors.NewNotFound(v1alpha1.Resource("volumesnapshot"), name) + return nil, errors.NewNotFound(v1beta1.Resource("volumesnapshot"), name) } - return obj.(*v1alpha1.VolumeSnapshot), nil + return obj.(*v1beta1.VolumeSnapshot), nil } diff --git a/pkg/client/listers/volumesnapshot/v1alpha1/volumesnapshotclass.go b/pkg/client/listers/volumesnapshot/v1beta1/volumesnapshotclass.go similarity index 75% rename from pkg/client/listers/volumesnapshot/v1alpha1/volumesnapshotclass.go rename to pkg/client/listers/volumesnapshot/v1beta1/volumesnapshotclass.go index 505d397bf..2d56d5d54 100644 --- a/pkg/client/listers/volumesnapshot/v1alpha1/volumesnapshotclass.go +++ b/pkg/client/listers/volumesnapshot/v1beta1/volumesnapshotclass.go @@ -16,10 +16,10 @@ limitations under the License. // Code generated by lister-gen. DO NOT EDIT. -package v1alpha1 +package v1beta1 import ( - v1alpha1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + v1beta1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" "k8s.io/client-go/tools/cache" @@ -28,9 +28,9 @@ import ( // VolumeSnapshotClassLister helps list VolumeSnapshotClasses. type VolumeSnapshotClassLister interface { // List lists all VolumeSnapshotClasses in the indexer. - List(selector labels.Selector) (ret []*v1alpha1.VolumeSnapshotClass, err error) + List(selector labels.Selector) (ret []*v1beta1.VolumeSnapshotClass, err error) // Get retrieves the VolumeSnapshotClass from the index for a given name. - Get(name string) (*v1alpha1.VolumeSnapshotClass, error) + Get(name string) (*v1beta1.VolumeSnapshotClass, error) VolumeSnapshotClassListerExpansion } @@ -45,21 +45,21 @@ func NewVolumeSnapshotClassLister(indexer cache.Indexer) VolumeSnapshotClassList } // List lists all VolumeSnapshotClasses in the indexer. -func (s *volumeSnapshotClassLister) List(selector labels.Selector) (ret []*v1alpha1.VolumeSnapshotClass, err error) { +func (s *volumeSnapshotClassLister) List(selector labels.Selector) (ret []*v1beta1.VolumeSnapshotClass, err error) { err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.VolumeSnapshotClass)) + ret = append(ret, m.(*v1beta1.VolumeSnapshotClass)) }) return ret, err } // Get retrieves the VolumeSnapshotClass from the index for a given name. -func (s *volumeSnapshotClassLister) Get(name string) (*v1alpha1.VolumeSnapshotClass, error) { +func (s *volumeSnapshotClassLister) Get(name string) (*v1beta1.VolumeSnapshotClass, error) { obj, exists, err := s.indexer.GetByKey(name) if err != nil { return nil, err } if !exists { - return nil, errors.NewNotFound(v1alpha1.Resource("volumesnapshotclass"), name) + return nil, errors.NewNotFound(v1beta1.Resource("volumesnapshotclass"), name) } - return obj.(*v1alpha1.VolumeSnapshotClass), nil + return obj.(*v1beta1.VolumeSnapshotClass), nil } diff --git a/pkg/client/listers/volumesnapshot/v1alpha1/volumesnapshotcontent.go b/pkg/client/listers/volumesnapshot/v1beta1/volumesnapshotcontent.go similarity index 74% rename from pkg/client/listers/volumesnapshot/v1alpha1/volumesnapshotcontent.go rename to pkg/client/listers/volumesnapshot/v1beta1/volumesnapshotcontent.go index 97d4e90aa..87edbc8fc 100644 --- a/pkg/client/listers/volumesnapshot/v1alpha1/volumesnapshotcontent.go +++ b/pkg/client/listers/volumesnapshot/v1beta1/volumesnapshotcontent.go @@ -16,10 +16,10 @@ limitations under the License. // Code generated by lister-gen. DO NOT EDIT. -package v1alpha1 +package v1beta1 import ( - v1alpha1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + v1beta1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" "k8s.io/client-go/tools/cache" @@ -28,9 +28,9 @@ import ( // VolumeSnapshotContentLister helps list VolumeSnapshotContents. type VolumeSnapshotContentLister interface { // List lists all VolumeSnapshotContents in the indexer. - List(selector labels.Selector) (ret []*v1alpha1.VolumeSnapshotContent, err error) + List(selector labels.Selector) (ret []*v1beta1.VolumeSnapshotContent, err error) // Get retrieves the VolumeSnapshotContent from the index for a given name. - Get(name string) (*v1alpha1.VolumeSnapshotContent, error) + Get(name string) (*v1beta1.VolumeSnapshotContent, error) VolumeSnapshotContentListerExpansion } @@ -45,21 +45,21 @@ func NewVolumeSnapshotContentLister(indexer cache.Indexer) VolumeSnapshotContent } // List lists all VolumeSnapshotContents in the indexer. -func (s *volumeSnapshotContentLister) List(selector labels.Selector) (ret []*v1alpha1.VolumeSnapshotContent, err error) { +func (s *volumeSnapshotContentLister) List(selector labels.Selector) (ret []*v1beta1.VolumeSnapshotContent, err error) { err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.VolumeSnapshotContent)) + ret = append(ret, m.(*v1beta1.VolumeSnapshotContent)) }) return ret, err } // Get retrieves the VolumeSnapshotContent from the index for a given name. -func (s *volumeSnapshotContentLister) Get(name string) (*v1alpha1.VolumeSnapshotContent, error) { +func (s *volumeSnapshotContentLister) Get(name string) (*v1beta1.VolumeSnapshotContent, error) { obj, exists, err := s.indexer.GetByKey(name) if err != nil { return nil, err } if !exists { - return nil, errors.NewNotFound(v1alpha1.Resource("volumesnapshotcontent"), name) + return nil, errors.NewNotFound(v1beta1.Resource("volumesnapshotcontent"), name) } - return obj.(*v1alpha1.VolumeSnapshotContent), nil + return obj.(*v1beta1.VolumeSnapshotContent), nil } diff --git a/pkg/controller/csi_handler.go b/pkg/controller/csi_handler.go index 3b3a9000a..881f8a7b1 100644 --- a/pkg/controller/csi_handler.go +++ b/pkg/controller/csi_handler.go @@ -22,7 +22,7 @@ import ( "strings" "time" - crdv1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + crdv1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" "github.com/kubernetes-csi/external-snapshotter/pkg/snapshotter" "k8s.io/api/core/v1" diff --git a/pkg/controller/framework_test.go b/pkg/controller/framework_test.go index a197d82c2..cf5c4e859 100644 --- a/pkg/controller/framework_test.go +++ b/pkg/controller/framework_test.go @@ -29,12 +29,12 @@ import ( "testing" "time" - crdv1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + crdv1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" clientset "github.com/kubernetes-csi/external-snapshotter/pkg/client/clientset/versioned" "github.com/kubernetes-csi/external-snapshotter/pkg/client/clientset/versioned/fake" snapshotscheme "github.com/kubernetes-csi/external-snapshotter/pkg/client/clientset/versioned/scheme" informers "github.com/kubernetes-csi/external-snapshotter/pkg/client/informers/externalversions" - storagelisters "github.com/kubernetes-csi/external-snapshotter/pkg/client/listers/volumesnapshot/v1alpha1" + storagelisters "github.com/kubernetes-csi/external-snapshotter/pkg/client/listers/volumesnapshot/v1beta1" "k8s.io/api/core/v1" storagev1 "k8s.io/api/storage/v1" storagev1beta1 "k8s.io/api/storage/v1beta1" @@ -766,9 +766,9 @@ func newTestController(kubeClient kubernetes.Interface, clientset clientset.Inte clientset, kubeClient, mockDriverName, - informerFactory.Snapshot().V1alpha1().VolumeSnapshots(), - informerFactory.Snapshot().V1alpha1().VolumeSnapshotContents(), - informerFactory.Snapshot().V1alpha1().VolumeSnapshotClasses(), + informerFactory.Snapshot().V1beta1().VolumeSnapshots(), + informerFactory.Snapshot().V1beta1().VolumeSnapshotContents(), + informerFactory.Snapshot().V1beta1().VolumeSnapshotClasses(), coreFactory.Core().V1().PersistentVolumeClaims(), 3, 5*time.Millisecond, @@ -820,7 +820,7 @@ func newContent(name, className, snapshotHandle, volumeUID, volumeName, boundToS if boundToSnapshotName != "" { content.Spec.VolumeSnapshotRef = &v1.ObjectReference{ Kind: "VolumeSnapshot", - APIVersion: "snapshot.storage.k8s.io/v1alpha1", + APIVersion: "snapshot.storage.k8s.io/v1beta1", UID: types.UID(boundToSnapshotUID), Namespace: testNamespace, Name: boundToSnapshotName, @@ -854,7 +854,7 @@ func newSnapshot(name, className, boundToContent, snapshotUID, claimName string, Namespace: testNamespace, UID: types.UID(snapshotUID), ResourceVersion: "1", - SelfLink: "/apis/snapshot.storage.k8s.io/v1alpha1/namespaces/" + testNamespace + "/volumesnapshots/" + name, + SelfLink: "/apis/snapshot.storage.k8s.io/v1beta1/namespaces/" + testNamespace + "/volumesnapshots/" + name, }, Spec: crdv1.VolumeSnapshotSpec{ VolumeSnapshotClassName: &className, diff --git a/pkg/controller/snapshot_controller.go b/pkg/controller/snapshot_controller.go index 5333c63f4..9f102d9cf 100644 --- a/pkg/controller/snapshot_controller.go +++ b/pkg/controller/snapshot_controller.go @@ -21,7 +21,7 @@ import ( "strings" "time" - crdv1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + crdv1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" "k8s.io/api/core/v1" storagev1 "k8s.io/api/storage/v1" storage "k8s.io/api/storage/v1beta1" @@ -423,7 +423,7 @@ func (ctrl *csiSnapshotController) updateSnapshotErrorStatusWithEvent(snapshot * } snapshotClone.Status.Error = statusError snapshotClone.Status.ReadyToUse = false - newSnapshot, err := ctrl.clientset.SnapshotV1alpha1().VolumeSnapshots(snapshotClone.Namespace).UpdateStatus(snapshotClone) + newSnapshot, err := ctrl.clientset.SnapshotV1beta1().VolumeSnapshots(snapshotClone.Namespace).UpdateStatus(snapshotClone) if err != nil { klog.V(4).Infof("updating VolumeSnapshot[%s] error status failed %v", snapshotKey(snapshot), err) @@ -458,7 +458,7 @@ func IsSnapshotBound(snapshot *crdv1.VolumeSnapshot, content *crdv1.VolumeSnapsh // isSnapshotConentBeingUsed checks if snapshot content is bound to snapshot. func (ctrl *csiSnapshotController) isSnapshotContentBeingUsed(content *crdv1.VolumeSnapshotContent) bool { if content.Spec.VolumeSnapshotRef != nil { - snapshotObj, err := ctrl.clientset.SnapshotV1alpha1().VolumeSnapshots(content.Spec.VolumeSnapshotRef.Namespace).Get(content.Spec.VolumeSnapshotRef.Name, metav1.GetOptions{}) + snapshotObj, err := ctrl.clientset.SnapshotV1beta1().VolumeSnapshots(content.Spec.VolumeSnapshotRef.Namespace).Get(content.Spec.VolumeSnapshotRef.Name, metav1.GetOptions{}) if err != nil { klog.Infof("isSnapshotContentBeingUsed: Cannot get snapshot %s from api server: [%v]. VolumeSnapshot object may be deleted already.", content.Spec.VolumeSnapshotRef.Name, err) return false @@ -510,7 +510,7 @@ func (ctrl *csiSnapshotController) checkandBindSnapshotContent(snapshot *crdv1.V contentClone.Spec.VolumeSnapshotRef.UID = snapshot.UID className := *(snapshot.Spec.VolumeSnapshotClassName) contentClone.Spec.VolumeSnapshotClassName = &className - newContent, err := ctrl.clientset.SnapshotV1alpha1().VolumeSnapshotContents().Update(contentClone) + newContent, err := ctrl.clientset.SnapshotV1beta1().VolumeSnapshotContents().Update(contentClone) if err != nil { klog.V(4).Infof("updating VolumeSnapshotContent[%s] error status failed %v", newContent.Name, err) return nil, err @@ -691,7 +691,7 @@ func (ctrl *csiSnapshotController) createSnapshotOperation(snapshot *crdv1.Volum // Try to create the VolumeSnapshotContent object several times for i := 0; i < ctrl.createSnapshotContentRetryCount; i++ { klog.V(5).Infof("createSnapshot [%s]: trying to save volume snapshot content %s", snapshotKey(snapshot), snapshotContent.Name) - if _, err = ctrl.clientset.SnapshotV1alpha1().VolumeSnapshotContents().Create(snapshotContent); err == nil || apierrs.IsAlreadyExists(err) { + if _, err = ctrl.clientset.SnapshotV1beta1().VolumeSnapshotContents().Create(snapshotContent); err == nil || apierrs.IsAlreadyExists(err) { // Save succeeded. if err != nil { klog.V(3).Infof("volume snapshot content %q for snapshot %q already exists, reusing", snapshotContent.Name, snapshotKey(snapshot)) @@ -758,7 +758,7 @@ func (ctrl *csiSnapshotController) deleteSnapshotContentOperation(content *crdv1 return fmt.Errorf("failed to delete snapshot %#v, err: %v", content.Name, err) } - err = ctrl.clientset.SnapshotV1alpha1().VolumeSnapshotContents().Delete(content.Name, &metav1.DeleteOptions{}) + err = ctrl.clientset.SnapshotV1beta1().VolumeSnapshotContents().Delete(content.Name, &metav1.DeleteOptions{}) if err != nil { ctrl.eventRecorder.Event(content, v1.EventTypeWarning, "SnapshotContentObjectDeleteError", "Failed to delete snapshot content API object") return fmt.Errorf("failed to delete VolumeSnapshotContent %s from API server: %q", content.Name, err) @@ -769,7 +769,7 @@ func (ctrl *csiSnapshotController) deleteSnapshotContentOperation(content *crdv1 func (ctrl *csiSnapshotController) bindandUpdateVolumeSnapshot(snapshotContent *crdv1.VolumeSnapshotContent, snapshot *crdv1.VolumeSnapshot) (*crdv1.VolumeSnapshot, error) { klog.V(5).Infof("bindandUpdateVolumeSnapshot for snapshot [%s]: snapshotContent [%s]", snapshot.Name, snapshotContent.Name) - snapshotObj, err := ctrl.clientset.SnapshotV1alpha1().VolumeSnapshots(snapshot.Namespace).Get(snapshot.Name, metav1.GetOptions{}) + snapshotObj, err := ctrl.clientset.SnapshotV1beta1().VolumeSnapshots(snapshot.Namespace).Get(snapshot.Name, metav1.GetOptions{}) if err != nil { return nil, fmt.Errorf("error get snapshot %s from api server: %v", snapshotKey(snapshot), err) } @@ -782,7 +782,7 @@ func (ctrl *csiSnapshotController) bindandUpdateVolumeSnapshot(snapshotContent * } else { klog.Infof("bindVolumeSnapshotContentToVolumeSnapshot: before bind VolumeSnapshot %s to volumeSnapshotContent [%s]", snapshot.Name, snapshotContent.Name) snapshotCopy.Spec.SnapshotContentName = snapshotContent.Name - updateSnapshot, err := ctrl.clientset.SnapshotV1alpha1().VolumeSnapshots(snapshot.Namespace).Update(snapshotCopy) + updateSnapshot, err := ctrl.clientset.SnapshotV1beta1().VolumeSnapshots(snapshot.Namespace).Update(snapshotCopy) if err != nil { klog.Infof("bindVolumeSnapshotContentToVolumeSnapshot: Error binding VolumeSnapshot %s to volumeSnapshotContent [%s]. Error [%#v]", snapshot.Name, snapshotContent.Name, err) return nil, newControllerUpdateError(snapshotKey(snapshot), err.Error()) @@ -808,7 +808,7 @@ func (ctrl *csiSnapshotController) updateSnapshotContentSize(content *crdv1.Volu } contentClone := content.DeepCopy() contentClone.Spec.VolumeSnapshotSource.CSI.RestoreSize = &size - _, err := ctrl.clientset.SnapshotV1alpha1().VolumeSnapshotContents().Update(contentClone) + _, err := ctrl.clientset.SnapshotV1beta1().VolumeSnapshotContents().Update(contentClone) if err != nil { return newControllerUpdateError(content.Name, err.Error()) } @@ -848,7 +848,7 @@ func (ctrl *csiSnapshotController) updateSnapshotStatus(snapshot *crdv1.VolumeSn status.RestoreSize = resource.NewQuantity(size, resource.BinarySI) } snapshotClone.Status = status - newSnapshotObj, err := ctrl.clientset.SnapshotV1alpha1().VolumeSnapshots(snapshotClone.Namespace).UpdateStatus(snapshotClone) + newSnapshotObj, err := ctrl.clientset.SnapshotV1beta1().VolumeSnapshots(snapshotClone.Namespace).UpdateStatus(snapshotClone) if err != nil { return nil, newControllerUpdateError(snapshotKey(snapshot), err.Error()) } @@ -949,7 +949,7 @@ func (ctrl *csiSnapshotController) SetDefaultSnapshotClass(snapshot *crdv1.Volum klog.V(5).Infof("setDefaultSnapshotClass [%s]: default VolumeSnapshotClassName [%s]", snapshot.Name, defaultClasses[0].Name) snapshotClone := snapshot.DeepCopy() snapshotClone.Spec.VolumeSnapshotClassName = &(defaultClasses[0].Name) - newSnapshot, err := ctrl.clientset.SnapshotV1alpha1().VolumeSnapshots(snapshotClone.Namespace).Update(snapshotClone) + newSnapshot, err := ctrl.clientset.SnapshotV1beta1().VolumeSnapshots(snapshotClone.Namespace).Update(snapshotClone) if err != nil { klog.V(4).Infof("updating VolumeSnapshot[%s] default class failed %v", snapshotKey(snapshot), err) } @@ -1016,7 +1016,7 @@ func (ctrl *csiSnapshotController) addContentFinalizer(content *crdv1.VolumeSnap contentClone := content.DeepCopy() contentClone.ObjectMeta.Finalizers = append(contentClone.ObjectMeta.Finalizers, VolumeSnapshotContentFinalizer) - _, err := ctrl.clientset.SnapshotV1alpha1().VolumeSnapshotContents().Update(contentClone) + _, err := ctrl.clientset.SnapshotV1beta1().VolumeSnapshotContents().Update(contentClone) if err != nil { return newControllerUpdateError(content.Name, err.Error()) } @@ -1035,7 +1035,7 @@ func (ctrl *csiSnapshotController) removeContentFinalizer(content *crdv1.VolumeS contentClone := content.DeepCopy() contentClone.ObjectMeta.Finalizers = slice.RemoveString(contentClone.ObjectMeta.Finalizers, VolumeSnapshotContentFinalizer, nil) - _, err := ctrl.clientset.SnapshotV1alpha1().VolumeSnapshotContents().Update(contentClone) + _, err := ctrl.clientset.SnapshotV1beta1().VolumeSnapshotContents().Update(contentClone) if err != nil { return newControllerUpdateError(content.Name, err.Error()) } @@ -1053,7 +1053,7 @@ func (ctrl *csiSnapshotController) removeContentFinalizer(content *crdv1.VolumeS func (ctrl *csiSnapshotController) addSnapshotFinalizer(snapshot *crdv1.VolumeSnapshot) error { snapshotClone := snapshot.DeepCopy() snapshotClone.ObjectMeta.Finalizers = append(snapshotClone.ObjectMeta.Finalizers, VolumeSnapshotFinalizer) - _, err := ctrl.clientset.SnapshotV1alpha1().VolumeSnapshots(snapshotClone.Namespace).Update(snapshotClone) + _, err := ctrl.clientset.SnapshotV1beta1().VolumeSnapshots(snapshotClone.Namespace).Update(snapshotClone) if err != nil { return newControllerUpdateError(snapshot.Name, err.Error()) } @@ -1072,7 +1072,7 @@ func (ctrl *csiSnapshotController) removeSnapshotFinalizer(snapshot *crdv1.Volum snapshotClone := snapshot.DeepCopy() snapshotClone.ObjectMeta.Finalizers = slice.RemoveString(snapshotClone.ObjectMeta.Finalizers, VolumeSnapshotFinalizer, nil) - _, err := ctrl.clientset.SnapshotV1alpha1().VolumeSnapshots(snapshotClone.Namespace).Update(snapshotClone) + _, err := ctrl.clientset.SnapshotV1beta1().VolumeSnapshots(snapshotClone.Namespace).Update(snapshotClone) if err != nil { return newControllerUpdateError(snapshot.Name, err.Error()) } diff --git a/pkg/controller/snapshot_controller_base.go b/pkg/controller/snapshot_controller_base.go index 5458b1bcf..286adc5a2 100644 --- a/pkg/controller/snapshot_controller_base.go +++ b/pkg/controller/snapshot_controller_base.go @@ -20,10 +20,10 @@ import ( "fmt" "time" - crdv1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + crdv1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" clientset "github.com/kubernetes-csi/external-snapshotter/pkg/client/clientset/versioned" - storageinformers "github.com/kubernetes-csi/external-snapshotter/pkg/client/informers/externalversions/volumesnapshot/v1alpha1" - storagelisters "github.com/kubernetes-csi/external-snapshotter/pkg/client/listers/volumesnapshot/v1alpha1" + storageinformers "github.com/kubernetes-csi/external-snapshotter/pkg/client/informers/externalversions/volumesnapshot/v1beta1" + storagelisters "github.com/kubernetes-csi/external-snapshotter/pkg/client/listers/volumesnapshot/v1beta1" "github.com/kubernetes-csi/external-snapshotter/pkg/snapshotter" "k8s.io/api/core/v1" diff --git a/pkg/controller/snapshot_controller_test.go b/pkg/controller/snapshot_controller_test.go index 625f9d700..c8c41a021 100644 --- a/pkg/controller/snapshot_controller_test.go +++ b/pkg/controller/snapshot_controller_test.go @@ -17,7 +17,7 @@ limitations under the License. package controller import ( - crdv1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + crdv1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" "k8s.io/client-go/tools/cache" "testing" ) diff --git a/pkg/controller/snapshot_create_test.go b/pkg/controller/snapshot_create_test.go index 53358b238..385cf79c7 100644 --- a/pkg/controller/snapshot_create_test.go +++ b/pkg/controller/snapshot_create_test.go @@ -21,7 +21,7 @@ import ( "testing" "time" - crdv1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + crdv1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" "k8s.io/api/core/v1" storage "k8s.io/api/storage/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -327,7 +327,7 @@ func TestCreateSnapshotSync(t *testing.T) { }, }, errors: []reactorError{ - // Inject error to the forth client.VolumesnapshotV1alpha1().VolumeSnapshots().Update call. + // Inject error to the forth client.VolumesnapshotV1beta1().VolumeSnapshots().Update call. // All other calls will succeed. {"update", "volumesnapshots", errors.New("mock update error")}, {"update", "volumesnapshots", errors.New("mock update error")}, diff --git a/pkg/controller/snapshot_delete_test.go b/pkg/controller/snapshot_delete_test.go index 6be2be119..1f5878ee0 100644 --- a/pkg/controller/snapshot_delete_test.go +++ b/pkg/controller/snapshot_delete_test.go @@ -20,7 +20,7 @@ import ( "errors" "testing" - crdv1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + crdv1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -195,7 +195,7 @@ func TestDeleteSync(t *testing.T) { expectedDeleteCalls: []deleteCall{{"sid1-6", map[string]string{"foo": "bar"}, nil}}, expectedEvents: []string{"Warning SnapshotContentObjectDeleteError"}, errors: []reactorError{ - // Inject error to the first client.VolumesnapshotV1alpha1().VolumeSnapshotContents().Delete call. + // Inject error to the first client.VolumesnapshotV1beta1().VolumeSnapshotContents().Delete call. // All other calls will succeed. {"delete", "volumesnapshotcontents", errors.New("mock delete error")}, }, diff --git a/pkg/controller/snapshot_ready_test.go b/pkg/controller/snapshot_ready_test.go index 1ccb6bd90..01223e8e0 100644 --- a/pkg/controller/snapshot_ready_test.go +++ b/pkg/controller/snapshot_ready_test.go @@ -186,7 +186,7 @@ func TestSync(t *testing.T) { }, }, errors: []reactorError{ - // Inject error to the first client.VolumesnapshotV1alpha1().VolumeSnapshots().Update call. + // Inject error to the first client.VolumesnapshotV1beta1().VolumeSnapshots().Update call. // All other calls will succeed. {"update", "volumesnapshots", errors.New("mock update error")}, }, diff --git a/pkg/controller/util.go b/pkg/controller/util.go index b91f32591..22e491b25 100644 --- a/pkg/controller/util.go +++ b/pkg/controller/util.go @@ -20,7 +20,7 @@ import ( "fmt" "strings" - crdv1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + crdv1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/controller/util_test.go b/pkg/controller/util_test.go index 4da945761..a73c3ab3f 100644 --- a/pkg/controller/util_test.go +++ b/pkg/controller/util_test.go @@ -17,7 +17,7 @@ limitations under the License. package controller import ( - crdv1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1" + crdv1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "reflect" From 31bf112a64e6bf18243b3761c6f52def6a798ba8 Mon Sep 17 00:00:00 2001 From: xiangqian Date: Thu, 22 Aug 2019 22:31:10 -0700 Subject: [PATCH 05/11] generate crds, modify api --- ....storage.k8s.io_volumesnapshotclasses.yaml | 76 ++--- ...storage.k8s.io_volumesnapshotcontents.yaml | 297 +++++++++--------- ...apshot.storage.k8s.io_volumesnapshots.yaml | 202 ++++++------ pkg/apis/volumesnapshot/v1beta1/types.go | 160 ++++++---- 4 files changed, 389 insertions(+), 346 deletions(-) diff --git a/config/crd/snapshot.storage.k8s.io_volumesnapshotclasses.yaml b/config/crd/snapshot.storage.k8s.io_volumesnapshotclasses.yaml index f4e83af9f..076df1f41 100644 --- a/config/crd/snapshot.storage.k8s.io_volumesnapshotclasses.yaml +++ b/config/crd/snapshot.storage.k8s.io_volumesnapshotclasses.yaml @@ -11,44 +11,50 @@ spec: kind: VolumeSnapshotClass plural: volumesnapshotclasses scope: "" + validation: + openAPIV3Schema: + description: VolumeSnapshotClass describes the parameters for a class of storage + snapshotter for which VolumeSnapshot can be dynamically taken for a given + PersistentVolumeClaim VolumeSnapshotClasses are non-namespaced. The name of + a VolumeSnapshotClass object is significant, it serves as the unique identifier + for a user to request a snapshot to be created using the specific VolumeSnapshotClass + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources' + type: string + deletionPolicy: + description: DeletionPolicy defines whether a VolumeSnapshotContent and + its associated physical snapshot on underlying storage system should be + deleted or not when released from its corresponding VolumeSnapshot. If + not specified, the default will be VolumeSnapshotContentRetain for static + binding, and VolumeSnapshotContentDelete for dynamic snapshot creation. + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds' + type: string + metadata: + description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata' + type: object + parameters: + additionalProperties: + type: string + description: Parameters holds parameters for underlying storage system. + These values are opaque to Kubernetes. + type: object + snapshotter: + description: Snapshotter is the name of the driver expected to handle VolumeSnapshot + requests of this VolumeSnapshotClass. + type: string + required: + - snapshotter + type: object version: v1beta1 versions: - name: v1beta1 - schema: - openAPIV3Schema: - description: VolumeSnapshotClass describes the parameters used by storage - system when provisioning VolumeSnapshots from PVCs. The name of a VolumeSnapshotClass - object is significant, and is how users can request a particular class. - properties: - apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources' - type: string - deletionPolicy: - description: 'Optional: what happens to a snapshot content when released - from its snapshot. The default policy is Delete if not specified.' - type: string - kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds' - type: string - metadata: - description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata' - type: object - parameters: - additionalProperties: - type: string - description: Parameters holds parameters for the snapshotter. These values - are opaque to the system and are passed directly to the snapshotter. - type: object - snapshotter: - description: Snapshotter is the driver expected to handle this VolumeSnapshotClass. - type: string - required: - - snapshotter - type: object served: true storage: true status: diff --git a/config/crd/snapshot.storage.k8s.io_volumesnapshotcontents.yaml b/config/crd/snapshot.storage.k8s.io_volumesnapshotcontents.yaml index 5b9b8379a..e52973518 100644 --- a/config/crd/snapshot.storage.k8s.io_volumesnapshotcontents.yaml +++ b/config/crd/snapshot.storage.k8s.io_volumesnapshotcontents.yaml @@ -11,155 +11,160 @@ spec: kind: VolumeSnapshotContent plural: volumesnapshotcontents scope: "" + validation: + openAPIV3Schema: + description: VolumeSnapshotContent represents the actual "on-disk" snapshot + object in the underlying storage system + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds' + type: string + metadata: + description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata' + type: object + spec: + description: Spec represents the desired state of the snapshot content + properties: + csiVolumeSnapshotSource: + description: CSI (Container Storage Interface) represents storage that + handled by an external CSI Volume Driver (Alpha feature). + properties: + creationTime: + description: Timestamp when the point-in-time snapshot is taken + by the underlying storage system. This timestamp will be generated + and returned by the CSI volume driver after the snapshot is cut. + 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 (aka, epoch time) since 1970-01-01 00:00:00 + UTC. This field is required in the CSI spec however made optional + here to support static binding. + format: int64 + type: integer + driver: + description: Driver is the name of the driver used to create a physical + snapshot on underlying storage system. This MUST be the same name + returned by the CSI GetPluginName() call for that driver. Required. + type: string + restoreSize: + description: When restoring a volume from a snapshot, the volume + size needs to be equal to or larger than the RestoreSize if it + is specified. If RestoreSize is set to nil, in the dynamic snapshot + creation case, it means that the underlying storage system does + not have this information available; in the static binding case, + this piece of information is not available. + format: int64 + type: integer + snapshotHandle: + description: SnapshotHandle is the unique id returned from the underlying + storage system by the CSI driver's CreationSnapshot gRPC call. + It serves as the only and sufficient handle when communicating + with underlying storage systems via CSI driver for all subsequent + calls on the specific VolumeSnapshot Required. + type: string + required: + - driver + - snapshotHandle + type: object + deletionPolicy: + description: DeletionPolicy defines whether a VolumeSnapshotContent + and its associated physical snapshot on underlying storage system + should be deleted or not when released from its corresponding VolumeSnapshot. + If not specified, the default will be VolumeSnapshotContentRetain + for static binding, and VolumeSnapshotContentDelete for dynamic snapshot + creation. + type: string + persistentVolumeRef: + description: PersistentVolumeRef represents the PersistentVolume that + the snapshot has been taken from. In dynamic snapshot creation case, + the field will be specified when VolumeSnapshot and VolumeSnapshotContent + are bound. + properties: + apiVersion: + description: API version of the referent. + type: string + fieldPath: + description: 'If referring to a piece of an object instead of an + entire object, this string should contain a valid JSON/Go field + access statement, such as desiredState.manifest.containers[2]. + For example, if the object reference is to a container within + a pod, this would take on a value like: "spec.containers{name}" + (where "name" refers to the name of the container that triggered + the event) or if no container name is specified "spec.containers[2]" + (container with index 2 in this pod). This syntax is chosen only + to have some well-defined way of referencing a part of an object. + TODO: this design is not final and this field is subject to change + in the future.' + type: string + kind: + description: 'Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds' + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names' + type: string + namespace: + description: 'Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/' + type: string + resourceVersion: + description: 'Specific resourceVersion to which this reference is + made, if any. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#concurrency-control-and-consistency' + type: string + uid: + description: 'UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids' + type: string + type: object + volumeSnapshotRef: + description: VolumeSnapshotRef is part of bi-directional binding between + VolumeSnapshot and VolumeSnapshotContent. Expect to be non-nil when + bound. VolumeSnapshot.VolumeSnapshotContentName is the authoritative + bind between VolumeSnapshot and VolumeSnapshotContent + properties: + apiVersion: + description: API version of the referent. + type: string + fieldPath: + description: 'If referring to a piece of an object instead of an + entire object, this string should contain a valid JSON/Go field + access statement, such as desiredState.manifest.containers[2]. + For example, if the object reference is to a container within + a pod, this would take on a value like: "spec.containers{name}" + (where "name" refers to the name of the container that triggered + the event) or if no container name is specified "spec.containers[2]" + (container with index 2 in this pod). This syntax is chosen only + to have some well-defined way of referencing a part of an object. + TODO: this design is not final and this field is subject to change + in the future.' + type: string + kind: + description: 'Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds' + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names' + type: string + namespace: + description: 'Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/' + type: string + resourceVersion: + description: 'Specific resourceVersion to which this reference is + made, if any. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#concurrency-control-and-consistency' + type: string + uid: + description: 'UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids' + type: string + type: object + type: object + required: + - spec + type: object version: v1beta1 versions: - name: v1beta1 - schema: - openAPIV3Schema: - description: VolumeSnapshotContent represents the actual "on-disk" snapshot - object - properties: - apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources' - type: string - kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds' - type: string - metadata: - description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata' - type: object - spec: - description: Spec represents the desired state of the snapshot content - properties: - csiVolumeSnapshotSource: - description: CSI (Container Storage Interface) represents storage - that handled by an external CSI Volume Driver (Alpha feature). - properties: - creationTime: - description: Timestamp when the point-in-time snapshot is taken - on the storage system. This timestamp will be generated by the - CSI volume driver after the snapshot is cut. The format of this - field should be 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. This field is - required in the CSI spec but optional here to support static - binding. - format: int64 - type: integer - driver: - description: Driver is the name of the driver to use for this - snapshot. This MUST be the same name returned by the CSI GetPluginName() - call for that driver. Required. - type: string - restoreSize: - description: When restoring volume from the snapshot, the volume - size should be equal to or larger than the RestoreSize if it - is specified. If RestoreSize is set to nil, it means that the - storage plugin does not have this information available. - format: int64 - type: integer - snapshotHandle: - description: SnapshotHandle is the unique snapshot id returned - by the CSI volume plugin’s CreateSnapshot to refer to the snapshot - on all subsequent calls. Required. - type: string - required: - - driver - - snapshotHandle - type: object - deletionPolicy: - description: 'Optional: what happens to a snapshot content when released - from its snapshot. It will be set to Delete by default if not specified' - type: string - persistentVolumeRef: - description: PersistentVolumeRef represents the PersistentVolume that - the snapshot has been taken from. It becomes non-nil when VolumeSnapshot - and VolumeSnapshotContent are bound. - properties: - apiVersion: - description: API version of the referent. - type: string - fieldPath: - description: 'If referring to a piece of an object instead of - an entire object, this string should contain a valid JSON/Go - field access statement, such as desiredState.manifest.containers[2]. - For example, if the object reference is to a container within - a pod, this would take on a value like: "spec.containers{name}" - (where "name" refers to the name of the container that triggered - the event) or if no container name is specified "spec.containers[2]" - (container with index 2 in this pod). This syntax is chosen - only to have some well-defined way of referencing a part of - an object. TODO: this design is not final and this field is - subject to change in the future.' - type: string - kind: - description: 'Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds' - type: string - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names' - type: string - namespace: - description: 'Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/' - type: string - resourceVersion: - description: 'Specific resourceVersion to which this reference - is made, if any. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#concurrency-control-and-consistency' - type: string - uid: - description: 'UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids' - type: string - type: object - snapshotClassName: - description: Name of the VolumeSnapshotClass used by the VolumeSnapshot. - If not specified, a default snapshot class will be used if it is - available. - type: string - volumeSnapshotRef: - description: VolumeSnapshotRef is part of bi-directional binding between - VolumeSnapshot and VolumeSnapshotContent. It becomes non-nil when - bound. - properties: - apiVersion: - description: API version of the referent. - type: string - fieldPath: - description: 'If referring to a piece of an object instead of - an entire object, this string should contain a valid JSON/Go - field access statement, such as desiredState.manifest.containers[2]. - For example, if the object reference is to a container within - a pod, this would take on a value like: "spec.containers{name}" - (where "name" refers to the name of the container that triggered - the event) or if no container name is specified "spec.containers[2]" - (container with index 2 in this pod). This syntax is chosen - only to have some well-defined way of referencing a part of - an object. TODO: this design is not final and this field is - subject to change in the future.' - type: string - kind: - description: 'Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds' - type: string - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names' - type: string - namespace: - description: 'Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/' - type: string - resourceVersion: - description: 'Specific resourceVersion to which this reference - is made, if any. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#concurrency-control-and-consistency' - type: string - uid: - description: 'UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids' - type: string - type: object - type: object - required: - - spec - type: object served: true storage: true status: diff --git a/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml b/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml index 7b4182456..f57eb387d 100644 --- a/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml +++ b/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml @@ -11,106 +11,114 @@ spec: kind: VolumeSnapshot plural: volumesnapshots scope: "" + validation: + openAPIV3Schema: + description: VolumeSnapshot is a user's request for taking a point in time snapshot + of a volume. Upon successful creation of the snapshot by the volume provider, + it is bound to a corresponding VolumeSnapshotContent. VolumeSnapshot objects + are namespaced + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds' + type: string + metadata: + description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata' + type: object + spec: + description: 'Spec defines the desired characteristics of a snapshot requested + by a user. More info: https:s//kubernetes.io/docs/concepts/storage/volume-snapshots#volumesnapshots' + properties: + source: + description: Source has the information about where a snapshot should + be created from. Currently PersistentVolumeClaim is the only supported + source type. If specified, and VolumeSnapshotContentName is not specified + (i.e., nil), snapshot will be dynamically created from the given source. + If not specified, user can statically bind a VolumeSnapshot to a VolumeSnapshotContent + by specifying VolumeSnapshotContentName. + properties: + apiGroup: + description: APIGroup is the group for the resource being referenced. + If APIGroup is not specified, the specified Kind must be in the + core API group. For any other third-party types, APIGroup is required. + type: string + kind: + description: Kind is the type of resource being referenced + type: string + name: + description: Name is the name of resource being referenced + type: string + required: + - kind + - name + type: object + volumeSnapshotClassName: + description: 'Name of the VolumeSnapshotClass requested by the VolumeSnapshot. + If not specified, the default snapshot class will be used if there + exists one. More info: https://kubernetes.io/docs/concepts/storage/volume-snapshot-classes' + type: string + volumeSnapshotContentName: + description: VolumeSnapshotContentName is the binding reference to the + VolumeSnapshotContent backing the VolumeSnapshot. In dynamic snapshot + creation case, VolumeSnapshotContentName must NOT be specified. + type: string + type: object + status: + description: 'Status represents the current status/information of a volume + snapshot. NOTE: Status is subjected to change by sources other than snapshot + controller, for example, undesired corruption from human operation + errors. It is only informational to provide necessary transparency + of a snapshot''s status to users. It is highly recommended not to + rely on this piece of information programmatically.' + properties: + creationTime: + description: CreationTime, if not nil, represents the timestamp when + a snapshot was successfully cut by the underlying storage system. + In static binding, CreationTime might not be available. + format: date-time + type: string + error: + description: The lastest observed error during snapshot creation operation, + if any. + properties: + message: + description: String detailing the error encountered during Attach + or Detach operation. This string may be logged, so it should not + contain sensitive information. + type: string + time: + description: Time the error was encountered. + format: date-time + type: string + type: object + readyToUse: + description: ReadyToUse is a status/informational flag which provides + transparency to users. In the dynamic snapshot creation case, ReadyToUse + will be set to true when underlying storage system has successfully + finished all procedures out-of-bound to make a snapshot available + AND snapshot controller has bound the VolumeSnapshot to a VolumeSnapshotContent + successfully. + type: boolean + restoreSize: + description: RestoreSize, if not nil, represents the minimum volume + size to restore from a VolumeSnapshot It is a storage system level + property of a snapshot when the underlying storage system supports. + The field could be nil if the underlying storage system does not have + the information available, , or in cases like manual/static binding. + type: string + required: + - readyToUse + type: object + type: object version: v1beta1 versions: - name: v1beta1 - schema: - openAPIV3Schema: - description: VolumeSnapshot is a user's request for taking a snapshot. Upon - successful creation of the actual snapshot by the volume provider it is - bound to the corresponding VolumeSnapshotContent. Only the VolumeSnapshot - object is accessible to the user in the namespace. - properties: - apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources' - type: string - kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds' - type: string - metadata: - description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata' - type: object - spec: - description: Spec defines the desired characteristics of a snapshot requested - by a user. - properties: - snapshotClassName: - description: Name of the VolumeSnapshotClass used by the VolumeSnapshot. - If not specified, a default snapshot class will be used if it is - available. - type: string - snapshotContentName: - description: SnapshotContentName binds the VolumeSnapshot object with - the VolumeSnapshotContent - type: string - source: - description: Source has the information about where the snapshot is - created from. In Alpha version, only PersistentVolumeClaim is supported - as the source. If not specified, user can create VolumeSnapshotContent - and bind it with VolumeSnapshot manually. - properties: - apiGroup: - description: APIGroup is the group for the resource being referenced. - If APIGroup is not specified, the specified Kind must be in - the core API group. For any other third-party types, APIGroup - is required. - type: string - kind: - description: Kind is the type of resource being referenced - type: string - name: - description: Name is the name of resource being referenced - type: string - required: - - kind - - name - type: object - type: object - status: - description: Status represents the latest observed state of the snapshot - properties: - creationTime: - description: CreationTime is the time the snapshot was successfully - created. If it is set, it means the snapshot was created; Otherwise - the snapshot was not created. - format: date-time - type: string - error: - description: The last error encountered during create snapshot operation, - if any. This field must only be set by the entity completing the - create snapshot operation, i.e. the external-snapshotter. - properties: - message: - description: String detailing the error encountered during Attach - or Detach operation. This string may be logged, so it should - not contain sensitive information. - type: string - time: - description: Time the error was encountered. - format: date-time - type: string - type: object - readyToUse: - description: ReadyToUse is set to true only if the snapshot is ready - to use (e.g., finish uploading if there is an uploading phase) and - also VolumeSnapshot and its VolumeSnapshotContent bind correctly - with each other. If any of the above condition is not true, ReadyToUse - is set to false - type: boolean - restoreSize: - description: When restoring volume from the snapshot, the volume size - should be equal to or larger than the RestoreSize if it is specified. - If RestoreSize is set to nil, it means that the storage plugin does - not have this information available. - type: string - type: object - required: - - spec - type: object served: true storage: true status: diff --git a/pkg/apis/volumesnapshot/v1beta1/types.go b/pkg/apis/volumesnapshot/v1beta1/types.go index 2fb0b8e75..a5d859037 100644 --- a/pkg/apis/volumesnapshot/v1beta1/types.go +++ b/pkg/apis/volumesnapshot/v1beta1/types.go @@ -35,9 +35,10 @@ const ( // +genclient // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// VolumeSnapshot is a user's request for taking a snapshot. Upon successful creation of the actual -// snapshot by the volume provider it is bound to the corresponding VolumeSnapshotContent. -// Only the VolumeSnapshot object is accessible to the user in the namespace. +// VolumeSnapshot is a user's request for taking a point in time snapshot of a volume. +// Upon successful creation of the snapshot by the volume provider, it is bound to a +// corresponding VolumeSnapshotContent. +// VolumeSnapshot objects are namespaced type VolumeSnapshot struct { metav1.TypeMeta `json:",inline"` // Standard object's metadata. @@ -46,9 +47,15 @@ type VolumeSnapshot struct { metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` // Spec defines the desired characteristics of a snapshot requested by a user. - Spec VolumeSnapshotSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"` + // More info: https:s//kubernetes.io/docs/concepts/storage/volume-snapshots#volumesnapshots + // +optional + Spec VolumeSnapshotSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` - // Status represents the latest observed state of the snapshot + // Status represents the current status/information of a volume snapshot. + // NOTE: Status is subjected to change by sources other than snapshot controller, + // for example, undesired corruption from human operation errors. It is only informational to + // provide necessary transparency of a snapshot's status to users. It is highly recommended + // not to rely on this piece of information programmatically. // +optional Status VolumeSnapshotStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` } @@ -61,51 +68,57 @@ type VolumeSnapshotList struct { // +optional metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` - // Items is the list of VolumeSnapshots + // List of VolumeSnapshots Items []VolumeSnapshot `json:"items" protobuf:"bytes,2,rep,name=items"` } // VolumeSnapshotSpec describes the common attributes of a volume snapshot type VolumeSnapshotSpec struct { - // Source has the information about where the snapshot is created from. - // In Alpha version, only PersistentVolumeClaim is supported as the source. - // If not specified, user can create VolumeSnapshotContent and bind it with VolumeSnapshot manually. + // Source has the information about where a snapshot should be created from. + // Currently PersistentVolumeClaim is the only supported source type. + // If specified, and VolumeSnapshotContentName is not specified (i.e., nil), + // snapshot will be dynamically created from the given source. + // If not specified, user can statically bind a VolumeSnapshot to a + // VolumeSnapshotContent by specifying VolumeSnapshotContentName. // +optional - Source *core_v1.TypedLocalObjectReference `json:"source" protobuf:"bytes,1,opt,name=source"` + Source *core_v1.TypedLocalObjectReference `json:"source,omitempty" protobuf:"bytes,1,opt,name=source"` - // SnapshotContentName binds the VolumeSnapshot object with the VolumeSnapshotContent + // VolumeSnapshotContentName is the binding reference to the VolumeSnapshotContent backing the VolumeSnapshot. + // In dynamic snapshot creation case, VolumeSnapshotContentName must NOT be specified. // +optional - SnapshotContentName string `json:"snapshotContentName" protobuf:"bytes,2,opt,name=snapshotContentName"` + VolumeSnapshotContentName *string `json:"volumeSnapshotContentName,omitempty" protobuf:"bytes,2,opt,name=volumeSnapshotContentName"` - // Name of the VolumeSnapshotClass used by the VolumeSnapshot. If not specified, a default snapshot class will - // be used if it is available. + // Name of the VolumeSnapshotClass requested by the VolumeSnapshot. + // If not specified, the default snapshot class will be used if there exists one. + // More info: https://kubernetes.io/docs/concepts/storage/volume-snapshot-classes // +optional - VolumeSnapshotClassName *string `json:"snapshotClassName" protobuf:"bytes,3,opt,name=snapshotClassName"` + VolumeSnapshotClassName *string `json:"volumeSnapshotClassName,omitempty" protobuf:"bytes,3,opt,name=volumeSnapshotClassName"` } // VolumeSnapshotStatus is the status of the VolumeSnapshot type VolumeSnapshotStatus struct { - // CreationTime is the time the snapshot was successfully created. If it is set, - // it means the snapshot was created; Otherwise the snapshot was not created. - // +optional - CreationTime *metav1.Time `json:"creationTime" protobuf:"bytes,1,opt,name=creationTime"` + // NOTE: All fields in VolumeSnapshotStatus are informational for user references. + // Controllers MUST NOT rely on any fields programmatically. - // When restoring volume from the snapshot, the volume size should be equal to or - // larger than the RestoreSize if it is specified. If RestoreSize is set to nil, it means - // that the storage plugin does not have this information available. + // CreationTime, if not nil, represents the timestamp when a snapshot was successfully + // cut by the underlying storage system. In static binding, CreationTime might not be available. // +optional - RestoreSize *resource.Quantity `json:"restoreSize" protobuf:"bytes,2,opt,name=restoreSize"` + CreationTime *metav1.Time `json:"creationTime,omitempty" protobuf:"bytes,1,opt,name=creationTime"` - // ReadyToUse is set to true only if the snapshot is ready to use (e.g., finish uploading if - // there is an uploading phase) and also VolumeSnapshot and its VolumeSnapshotContent - // bind correctly with each other. If any of the above condition is not true, ReadyToUse is - // set to false - // +optional + // ReadyToUse is a status/informational flag which provides transparency to users. + // In the dynamic snapshot creation case, ReadyToUse will be set to true when underlying storage + // system has successfully finished all procedures out-of-bound to make a snapshot available AND + // snapshot controller has bound the VolumeSnapshot to a VolumeSnapshotContent successfully. ReadyToUse bool `json:"readyToUse" protobuf:"varint,3,opt,name=readyToUse"` - // The last error encountered during create snapshot operation, if any. - // This field must only be set by the entity completing the create snapshot - // operation, i.e. the external-snapshotter. + // RestoreSize, if not nil, represents the minimum volume size to restore from a VolumeSnapshot + // It is a storage system level property of a snapshot when the underlying storage system supports. + // The field could be nil if the underlying storage system does not have the information available, + // , or in cases like manual/static binding. + // +optional + RestoreSize *resource.Quantity `json:"restoreSize,omitempty" protobuf:"bytes,2,opt,name=restoreSize"` + + // The lastest observed error during snapshot creation operation, if any. // +optional Error *storage.VolumeError `json:"error,omitempty" protobuf:"bytes,4,opt,name=error,casttype=VolumeError"` } @@ -114,9 +127,11 @@ type VolumeSnapshotStatus struct { // +genclient:nonNamespaced // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// VolumeSnapshotClass describes the parameters used by storage system when -// provisioning VolumeSnapshots from PVCs. -// The name of a VolumeSnapshotClass object is significant, and is how users can request a particular class. +// VolumeSnapshotClass describes the parameters for a class of storage snapshotter +// for which VolumeSnapshot can be dynamically taken for a given PersistentVolumeClaim +// VolumeSnapshotClasses are non-namespaced. +// The name of a VolumeSnapshotClass object is significant, it serves as the unique identifier +// for a user to request a snapshot to be created using the specific VolumeSnapshotClass type VolumeSnapshotClass struct { metav1.TypeMeta `json:",inline"` // Standard object's metadata. @@ -124,24 +139,26 @@ type VolumeSnapshotClass struct { // +optional metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` - // Snapshotter is the driver expected to handle this VolumeSnapshotClass. + // Snapshotter is the name of the driver expected to handle VolumeSnapshot requests of this VolumeSnapshotClass. Snapshotter string `json:"snapshotter" protobuf:"bytes,2,opt,name=snapshotter"` - // Parameters holds parameters for the snapshotter. - // These values are opaque to the system and are passed directly - // to the snapshotter. + // Parameters holds parameters for underlying storage system. + // These values are opaque to Kubernetes. // +optional Parameters map[string]string `json:"parameters,omitempty" protobuf:"bytes,3,rep,name=parameters"` - // Optional: what happens to a snapshot content when released from its snapshot. - // The default policy is Delete if not specified. + // DeletionPolicy defines whether a VolumeSnapshotContent and its + // associated physical snapshot on underlying storage system + // should be deleted or not when released from its corresponding VolumeSnapshot. + // If not specified, the default will be VolumeSnapshotContentRetain for static binding, + // and VolumeSnapshotContentDelete for dynamic snapshot creation. // +optional DeletionPolicy *DeletionPolicy `json:"deletionPolicy,omitempty" protobuf:"bytes,4,opt,name=deletionPolicy"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// VolumeSnapshotClassList is a collection of snapshot classes. +// VolumeSnapshotClassList is a collection of VolumeSnapshotClasses. type VolumeSnapshotClassList struct { metav1.TypeMeta `json:",inline"` // Standard list metadata @@ -157,7 +174,8 @@ type VolumeSnapshotClassList struct { // +genclient:nonNamespaced // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// VolumeSnapshotContent represents the actual "on-disk" snapshot object +// VolumeSnapshotContent represents the actual "on-disk" snapshot object in the +// underlying storage system type VolumeSnapshotContent struct { metav1.TypeMeta `json:",inline"` // Standard object's metadata. @@ -181,30 +199,31 @@ type VolumeSnapshotContentList struct { Items []VolumeSnapshotContent `json:"items" protobuf:"bytes,2,rep,name=items"` } -// VolumeSnapshotContentSpec is the spec of the volume snapshot content +// VolumeSnapshotContentSpec is the specification of a VolumeSnapshotContent type VolumeSnapshotContentSpec struct { - // Source represents the location and type of the volume snapshot + // VolumeSnapshotSource holds critical metadata where the snapshot on underlying storage + // system has been created from. VolumeSnapshotSource `json:",inline" protobuf:"bytes,1,opt,name=volumeSnapshotSource"` // VolumeSnapshotRef is part of bi-directional binding between VolumeSnapshot - // and VolumeSnapshotContent. It becomes non-nil when bound. - // +optional - VolumeSnapshotRef *core_v1.ObjectReference `json:"volumeSnapshotRef" protobuf:"bytes,2,opt,name=volumeSnapshotRef"` - - // PersistentVolumeRef represents the PersistentVolume that the snapshot has been - // taken from. It becomes non-nil when VolumeSnapshot and VolumeSnapshotContent are bound. + // and VolumeSnapshotContent. + // Expect to be non-nil when bound. + // VolumeSnapshot.VolumeSnapshotContentName is the authoritative bind between VolumeSnapshot and VolumeSnapshotContent // +optional - PersistentVolumeRef *core_v1.ObjectReference `json:"persistentVolumeRef" protobuf:"bytes,3,opt,name=persistentVolumeRef"` + VolumeSnapshotRef *core_v1.ObjectReference `json:"volumeSnapshotRef,omitempty" protobuf:"bytes,2,opt,name=volumeSnapshotRef"` - // Name of the VolumeSnapshotClass used by the VolumeSnapshot. If not specified, a default snapshot class will - // be used if it is available. + // PersistentVolumeRef represents the PersistentVolume that the snapshot has been taken from. + // In dynamic snapshot creation case, the field will be specified when VolumeSnapshot and VolumeSnapshotContent are bound. // +optional - VolumeSnapshotClassName *string `json:"snapshotClassName" protobuf:"bytes,4,opt,name=snapshotClassName"` + PersistentVolumeRef *core_v1.ObjectReference `json:"persistentVolumeRef,omitempty" protobuf:"bytes,3,opt,name=persistentVolumeRef"` - // Optional: what happens to a snapshot content when released from its snapshot. It will be set to Delete by default - // if not specified + // DeletionPolicy defines whether a VolumeSnapshotContent and its + // associated physical snapshot on underlying storage system + // should be deleted or not when released from its corresponding VolumeSnapshot. + // If not specified, the default will be VolumeSnapshotContentRetain for static binding, + // and VolumeSnapshotContentDelete for dynamic snapshot creation. // +optional - DeletionPolicy *DeletionPolicy `json:"deletionPolicy" protobuf:"bytes,5,opt,name=deletionPolicy"` + DeletionPolicy *DeletionPolicy `json:"deletionPolicy,omitempty" protobuf:"bytes,5,opt,name=deletionPolicy"` } // VolumeSnapshotSource represents the actual location and type of the snapshot. Only one of its members may be specified. @@ -216,29 +235,34 @@ type VolumeSnapshotSource struct { // CSIVolumeSnapshotSource represents the source from CSI volume snapshot type CSIVolumeSnapshotSource struct { - // Driver is the name of the driver to use for this snapshot. + // Driver is the name of the driver used to create a physical snapshot on + // underlying storage system. // This MUST be the same name returned by the CSI GetPluginName() call for // that driver. // Required. Driver string `json:"driver" protobuf:"bytes,1,opt,name=driver"` - // SnapshotHandle is the unique snapshot id returned by the CSI volume - // plugin’s CreateSnapshot to refer to the snapshot on all subsequent calls. + // SnapshotHandle is the unique id returned from the underlying storage system + // by the CSI driver's CreationSnapshot gRPC call. It serves as the only and sufficient + // handle when communicating with underlying storage systems via CSI driver for + // all subsequent calls on the specific VolumeSnapshot // Required. SnapshotHandle string `json:"snapshotHandle" protobuf:"bytes,2,opt,name=snapshotHandle"` - // Timestamp when the point-in-time snapshot is taken on the storage - // system. This timestamp will be generated by the CSI volume driver after - // the snapshot is cut. The format of this field should be a Unix nanoseconds + // Timestamp when the point-in-time snapshot is taken by the underlying storage + // system. This timestamp will be generated and returned by the CSI volume driver after + // the snapshot is cut. 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. - // This field is required in the CSI spec but optional here to support static binding. + // the current time in nanoseconds (aka, epoch time) since 1970-01-01 00:00:00 UTC. + // This field is required in the CSI spec however made optional here to support static binding. // +optional CreationTime *int64 `json:"creationTime,omitempty" protobuf:"varint,3,opt,name=creationTime"` - // When restoring volume from the snapshot, the volume size should be equal to or - // larger than the RestoreSize if it is specified. If RestoreSize is set to nil, it means - // that the storage plugin does not have this information available. + // When restoring a volume from a snapshot, the volume size needs to be equal to or + // larger than the RestoreSize if it is specified. + // If RestoreSize is set to nil, in the dynamic snapshot creation case, it means + // that the underlying storage system does not have this information available; + // in the static binding case, this piece of information is not available. // +optional RestoreSize *int64 `json:"restoreSize,omitempty" protobuf:"bytes,4,opt,name=restoreSize"` } From 8efee6197850b578c7e0b8cefc410cf30b0c452e Mon Sep 17 00:00:00 2001 From: xiangqian Date: Fri, 23 Aug 2019 16:53:09 -0700 Subject: [PATCH 06/11] final adjustment on types.go based on feedback rename variable names in comments to follow OpenAPIV3Schema, enforces namespaced or cluster comments update feedback from Tim --- ....storage.k8s.io_volumesnapshotclasses.yaml | 39 ++-- ...storage.k8s.io_volumesnapshotcontents.yaml | 116 ++++-------- ...apshot.storage.k8s.io_volumesnapshots.yaml | 94 +++++----- pkg/apis/volumesnapshot/v1beta1/types.go | 172 +++++++++--------- 4 files changed, 200 insertions(+), 221 deletions(-) diff --git a/config/crd/snapshot.storage.k8s.io_volumesnapshotclasses.yaml b/config/crd/snapshot.storage.k8s.io_volumesnapshotclasses.yaml index 076df1f41..75dba2f39 100644 --- a/config/crd/snapshot.storage.k8s.io_volumesnapshotclasses.yaml +++ b/config/crd/snapshot.storage.k8s.io_volumesnapshotclasses.yaml @@ -10,14 +10,13 @@ spec: names: kind: VolumeSnapshotClass plural: volumesnapshotclasses - scope: "" + scope: Cluster validation: openAPIV3Schema: - description: VolumeSnapshotClass describes the parameters for a class of storage - snapshotter for which VolumeSnapshot can be dynamically taken for a given - PersistentVolumeClaim VolumeSnapshotClasses are non-namespaced. The name of - a VolumeSnapshotClass object is significant, it serves as the unique identifier - for a user to request a snapshot to be created using the specific VolumeSnapshotClass + description: VolumeSnapshotClass specifies parameters that a underlying storage + system uses when creating a volume snapshot. A specific VolumeSnapshotClass + is used by specifying its name in a VolumeSnapshot object. VolumeSnapshotClasses + are non-namespaced properties: apiVersion: description: 'APIVersion defines the versioned schema of this representation @@ -25,11 +24,19 @@ spec: internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources' type: string deletionPolicy: - description: DeletionPolicy defines whether a VolumeSnapshotContent and - its associated physical snapshot on underlying storage system should be - deleted or not when released from its corresponding VolumeSnapshot. If - not specified, the default will be VolumeSnapshotContentRetain for static - binding, and VolumeSnapshotContentDelete for dynamic snapshot creation. + description: deletionPolicy determines whether a VolumeSnapshotContent created + through the VolumeSnapshotClass should be deleted when its bound VolumeSnapshot + is deleted. Supported values are "Retain" and "Delete". "Retain" means + that the VolumeSnapshotContent and its physical snapshot on underlying + storage system are kept. "Delete" means that the VolumeSnapshotContent + and its physical snapshot on underlying storage system are deleted. If + not specified, the default value is "Delete" + enum: + - Delete + - Retain + type: string + driver: + description: driver is the name of the driver that handles this VolumeSnapshotClass. type: string kind: description: 'Kind is a string value representing the REST resource this @@ -42,15 +49,11 @@ spec: parameters: additionalProperties: type: string - description: Parameters holds parameters for underlying storage system. - These values are opaque to Kubernetes. + description: parameters is a key-value map with storage driver specific + parameters for creating snapshots. These values are opaque to Kubernetes. type: object - snapshotter: - description: Snapshotter is the name of the driver expected to handle VolumeSnapshot - requests of this VolumeSnapshotClass. - type: string required: - - snapshotter + - driver type: object version: v1beta1 versions: diff --git a/config/crd/snapshot.storage.k8s.io_volumesnapshotcontents.yaml b/config/crd/snapshot.storage.k8s.io_volumesnapshotcontents.yaml index e52973518..205499386 100644 --- a/config/crd/snapshot.storage.k8s.io_volumesnapshotcontents.yaml +++ b/config/crd/snapshot.storage.k8s.io_volumesnapshotcontents.yaml @@ -10,7 +10,7 @@ spec: names: kind: VolumeSnapshotContent plural: volumesnapshotcontents - scope: "" + scope: Cluster validation: openAPIV3Schema: description: VolumeSnapshotContent represents the actual "on-disk" snapshot @@ -30,100 +30,64 @@ spec: description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata' type: object spec: - description: Spec represents the desired state of the snapshot content + description: spec defines properties of a VolumeSnapshotContent created + by underlying storage system. properties: - csiVolumeSnapshotSource: - description: CSI (Container Storage Interface) represents storage that - handled by an external CSI Volume Driver (Alpha feature). + csi: + description: csi represents a volume snapshot created by a CSI(Container + Storage Interface) driver. properties: creationTime: - description: Timestamp when the point-in-time snapshot is taken - by the underlying storage system. This timestamp will be generated - and returned by the CSI volume driver after the snapshot is cut. - 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 (aka, epoch time) since 1970-01-01 00:00:00 - UTC. This field is required in the CSI spec however made optional - here to support static binding. + description: creationTime is the timestamp when the point-in-time + snapshot is taken by the underlying storage system. This timestamp + is returned by the CSI driver after the snapshot is cut. 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 (aka, epoch time) since 1970-01-01 00:00:00 UTC. format: int64 type: integer driver: - description: Driver is the name of the driver used to create a physical - snapshot on underlying storage system. This MUST be the same name - returned by the CSI GetPluginName() call for that driver. Required. + description: driver is the name of the CSI driver used to create + the physical snapshot on the underlying storage system. This MUST + be the same name returned by the CSI GetPluginName() call for + that driver. Required. type: string restoreSize: - description: When restoring a volume from a snapshot, the volume - size needs to be equal to or larger than the RestoreSize if it - is specified. If RestoreSize is set to nil, in the dynamic snapshot - creation case, it means that the underlying storage system does - not have this information available; in the static binding case, - this piece of information is not available. + description: restoreSize specifies the number of bytes that the + snapshot's data would consume when restored to a volume. When + restoring a volume from a snapshot, the volume size needs to be + equal to or larger than the RestoreSize if it is specified. format: int64 type: integer snapshotHandle: - description: SnapshotHandle is the unique id returned from the underlying - storage system by the CSI driver's CreationSnapshot gRPC call. - It serves as the only and sufficient handle when communicating - with underlying storage systems via CSI driver for all subsequent - calls on the specific VolumeSnapshot Required. + description: snapshotHandle is the snapshot id returned by the CSI + driver in the CreateSnapshotResponse and is used as the snapshot + identifier for all subsequent CSI calls. Required. type: string required: - driver - snapshotHandle type: object deletionPolicy: - description: DeletionPolicy defines whether a VolumeSnapshotContent - and its associated physical snapshot on underlying storage system - should be deleted or not when released from its corresponding VolumeSnapshot. - If not specified, the default will be VolumeSnapshotContentRetain - for static binding, and VolumeSnapshotContentDelete for dynamic snapshot - creation. + description: deletionPolicy determines whether this VolumeSnapshotContent + and its bound physical snapshot on the underlying storage system should + be deleted when its VolumeSnapshot is deleted. Supported values are + "Retain" and "Delete". "Retain" means that the VolumeSnapshotContent + and its physical snapshot on underlying storage system are kept. "Delete" + means that the VolumeSnapshotContent and its physical snapshot on + underlying storage system are deleted. If not specified, the default + value is "Retain" + enum: + - Delete + - Retain type: string - persistentVolumeRef: - description: PersistentVolumeRef represents the PersistentVolume that - the snapshot has been taken from. In dynamic snapshot creation case, - the field will be specified when VolumeSnapshot and VolumeSnapshotContent - are bound. - properties: - apiVersion: - description: API version of the referent. - type: string - fieldPath: - description: 'If referring to a piece of an object instead of an - entire object, this string should contain a valid JSON/Go field - access statement, such as desiredState.manifest.containers[2]. - For example, if the object reference is to a container within - a pod, this would take on a value like: "spec.containers{name}" - (where "name" refers to the name of the container that triggered - the event) or if no container name is specified "spec.containers[2]" - (container with index 2 in this pod). This syntax is chosen only - to have some well-defined way of referencing a part of an object. - TODO: this design is not final and this field is subject to change - in the future.' - type: string - kind: - description: 'Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds' - type: string - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names' - type: string - namespace: - description: 'Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/' - type: string - resourceVersion: - description: 'Specific resourceVersion to which this reference is - made, if any. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#concurrency-control-and-consistency' - type: string - uid: - description: 'UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids' - type: string - type: object volumeSnapshotRef: - description: VolumeSnapshotRef is part of bi-directional binding between - VolumeSnapshot and VolumeSnapshotContent. Expect to be non-nil when - bound. VolumeSnapshot.VolumeSnapshotContentName is the authoritative - bind between VolumeSnapshot and VolumeSnapshotContent + description: volumeSnapshotRef specifies the VolumeSnapshot object that + this VolumeSnapshotContent is bound with. The VolumeSnapshot.Spec.VolumeSnapshotContentName + field must reference this VolumeSnapshotContent name for the binding + to be considered valid(a.k.a bi-directional binding). If the referenced + VolumeSnapshot object does not exist(i.e., deleted by user), then + the VolumeSnapshotContent.Spec.DeletionPolicy is triggered. properties: apiVersion: description: API version of the referent. diff --git a/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml b/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml index f57eb387d..ba77c98dd 100644 --- a/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml +++ b/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml @@ -10,13 +10,12 @@ spec: names: kind: VolumeSnapshot plural: volumesnapshots - scope: "" + scope: Namespaced validation: openAPIV3Schema: - description: VolumeSnapshot is a user's request for taking a point in time snapshot - of a volume. Upon successful creation of the snapshot by the volume provider, - it is bound to a corresponding VolumeSnapshotContent. VolumeSnapshot objects - are namespaced + description: VolumeSnapshot is a user's request for taking a point-in-time snapshot + of a PersistentVolumeClaim. Upon successful creation of a snapshot by the + underlying storage system, it is bound to a corresponding VolumeSnapshotContent. properties: apiVersion: description: 'APIVersion defines the versioned schema of this representation @@ -32,16 +31,16 @@ spec: description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata' type: object spec: - description: 'Spec defines the desired characteristics of a snapshot requested + description: 'spec defines the desired characteristics of a snapshot requested by a user. More info: https:s//kubernetes.io/docs/concepts/storage/volume-snapshots#volumesnapshots' properties: source: - description: Source has the information about where a snapshot should - be created from. Currently PersistentVolumeClaim is the only supported - source type. If specified, and VolumeSnapshotContentName is not specified - (i.e., nil), snapshot will be dynamically created from the given source. - If not specified, user can statically bind a VolumeSnapshot to a VolumeSnapshotContent - by specifying VolumeSnapshotContentName. + description: source specifies where a snapshot should be created from. + Currently, PersistentVolumeClaim is the only supported source type. + If specified, and VolumeSnapshotContentName is not specified(i.e., + nil), snapshot will be dynamically created from the given source. + If not specified, and VolumeSnapshotContentName is not specified, + system controller will fail on dynamic snapshot creation. properties: apiGroup: description: APIGroup is the group for the resource being referenced. @@ -59,37 +58,44 @@ spec: - name type: object volumeSnapshotClassName: - description: 'Name of the VolumeSnapshotClass requested by the VolumeSnapshot. - If not specified, the default snapshot class will be used if there - exists one. More info: https://kubernetes.io/docs/concepts/storage/volume-snapshot-classes' + description: 'volumeSnapshotClassName is the name of the VolumeSnapshotClass + requested by the VolumeSnapshot. If not specified, the default snapshot + class will be used if there exists one. If not specified, and there + is no default snapshot class, dynamic VolumeSnapshot creation will + fail. More info: https://kubernetes.io/docs/concepts/storage/volume-snapshot-classes' type: string volumeSnapshotContentName: - description: VolumeSnapshotContentName is the binding reference to the - VolumeSnapshotContent backing the VolumeSnapshot. In dynamic snapshot - creation case, VolumeSnapshotContentName must NOT be specified. + description: volumeSnapshotContentName is the name of the VolumeSnapshotContent + object backing the VolumeSnapshot. To request a pre-existing VolumeSnapshotContent + object, this field MUST be specified during VolumeSnapshot object + creation. Otherwise, a snapshot will be dynamically created, and this + field will be populated afterwards. type: string type: object status: - description: 'Status represents the current status/information of a volume - snapshot. NOTE: Status is subjected to change by sources other than snapshot - controller, for example, undesired corruption from human operation - errors. It is only informational to provide necessary transparency - of a snapshot''s status to users. It is highly recommended not to - rely on this piece of information programmatically.' + description: 'status represents the current information of a snapshot. NOTE: + status can be modified by sources other than system controllers, and + must not be depended upon for accuracy. Controllers should only + be using information from the VolumeSnapshotContent object after + verifying that the binding is accurate and complete.' properties: creationTime: - description: CreationTime, if not nil, represents the timestamp when + description: 'creationTime, if not nil, represents the timestamp when a snapshot was successfully cut by the underlying storage system. - In static binding, CreationTime might not be available. + In static binding, CreationTime might not be available. NOTE: Controllers + MUST NOT rely on this field programmatically' format: date-time type: string error: - description: The lastest observed error during snapshot creation operation, - if any. + description: error is the latest observed error during snapshot creation, + if any. This field could be helpful to upper level controllers(i.e., + application controller) to decide whether they should continue on + waiting for the snapshot to be created based on the type of error + reported. properties: message: - description: String detailing the error encountered during Attach - or Detach operation. This string may be logged, so it should not + description: String detailing the error encountered during snapshot + creation. This string may be logged, so it should not contain sensitive information. type: string time: @@ -98,22 +104,24 @@ spec: type: string type: object readyToUse: - description: ReadyToUse is a status/informational flag which provides - transparency to users. In the dynamic snapshot creation case, ReadyToUse - will be set to true when underlying storage system has successfully - finished all procedures out-of-bound to make a snapshot available - AND snapshot controller has bound the VolumeSnapshot to a VolumeSnapshotContent - successfully. + description: 'readyToUse is an informational flag which provides transparency + to users. In dynamic snapshot creation case, ReadyToUse will be set + to true when underlying storage system has successfully finished all + procedures out-of-bound to make a snapshot available AND snapshot + controller has bound the VolumeSnapshot to a VolumeSnapshotContent + successfully. If not specified(i.e., nil), it means the readiness + of the VolumeSnapshot is unknown to system controllers. NOTE: Controllers + MUST NOT rely on this field programmatically' type: boolean restoreSize: - description: RestoreSize, if not nil, represents the minimum volume - size to restore from a VolumeSnapshot It is a storage system level - property of a snapshot when the underlying storage system supports. - The field could be nil if the underlying storage system does not have - the information available, , or in cases like manual/static binding. + description: 'restoreSize specifies the number of bytes that the snapshot''s + data would consume when restored to a volume. When restoring a volume + from a snapshot, the volume size needs to be equal to or larger than + the RestoreSize if it is specified. The field could be nil if the + underlying storage system does not have the information available, + or in cases like static binding. NOTE: Controllers MUST NOT rely on + this field programmatically' type: string - required: - - readyToUse type: object type: object version: v1beta1 diff --git a/pkg/apis/volumesnapshot/v1beta1/types.go b/pkg/apis/volumesnapshot/v1beta1/types.go index a5d859037..91ed9aff8 100644 --- a/pkg/apis/volumesnapshot/v1beta1/types.go +++ b/pkg/apis/volumesnapshot/v1beta1/types.go @@ -23,22 +23,14 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -const ( - // VolumeSnapshotContentResourcePlural is "volumesnapshotcontents" - VolumeSnapshotContentResourcePlural = "volumesnapshotcontents" - // VolumeSnapshotResourcePlural is "volumesnapshots" - VolumeSnapshotResourcePlural = "volumesnapshots" - // VolumeSnapshotClassResourcePlural is "volumesnapshotclasses" - VolumeSnapshotClassResourcePlural = "volumesnapshotclasses" -) - // +genclient // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// VolumeSnapshot is a user's request for taking a point in time snapshot of a volume. -// Upon successful creation of the snapshot by the volume provider, it is bound to a +// VolumeSnapshot is a user's request for taking a point-in-time snapshot of a PersistentVolumeClaim. +// Upon successful creation of a snapshot by the underlying storage system, it is bound to a // corresponding VolumeSnapshotContent. -// VolumeSnapshot objects are namespaced +// +kubebuilder:object:root=true +// +kubebuilder:resource:scope=Namespaced type VolumeSnapshot struct { metav1.TypeMeta `json:",inline"` // Standard object's metadata. @@ -46,16 +38,16 @@ type VolumeSnapshot struct { // +optional metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` - // Spec defines the desired characteristics of a snapshot requested by a user. + // spec defines the desired characteristics of a snapshot requested by a user. // More info: https:s//kubernetes.io/docs/concepts/storage/volume-snapshots#volumesnapshots // +optional Spec VolumeSnapshotSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` - // Status represents the current status/information of a volume snapshot. - // NOTE: Status is subjected to change by sources other than snapshot controller, - // for example, undesired corruption from human operation errors. It is only informational to - // provide necessary transparency of a snapshot's status to users. It is highly recommended - // not to rely on this piece of information programmatically. + // status represents the current information of a snapshot. + // NOTE: status can be modified by sources other than system controllers, + // and must not be depended upon for accuracy. + // Controllers should only be using information from the VolumeSnapshotContent object + // after verifying that the binding is accurate and complete. // +optional Status VolumeSnapshotStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` } @@ -74,51 +66,66 @@ type VolumeSnapshotList struct { // VolumeSnapshotSpec describes the common attributes of a volume snapshot type VolumeSnapshotSpec struct { - // Source has the information about where a snapshot should be created from. - // Currently PersistentVolumeClaim is the only supported source type. - // If specified, and VolumeSnapshotContentName is not specified (i.e., nil), + // source specifies where a snapshot should be created from. + // Currently, PersistentVolumeClaim is the only supported source type. + // If specified, and VolumeSnapshotContentName is not specified(i.e., nil), // snapshot will be dynamically created from the given source. - // If not specified, user can statically bind a VolumeSnapshot to a - // VolumeSnapshotContent by specifying VolumeSnapshotContentName. + // If not specified, and VolumeSnapshotContentName is not specified, system + // controller will fail on dynamic snapshot creation. // +optional Source *core_v1.TypedLocalObjectReference `json:"source,omitempty" protobuf:"bytes,1,opt,name=source"` - // VolumeSnapshotContentName is the binding reference to the VolumeSnapshotContent backing the VolumeSnapshot. - // In dynamic snapshot creation case, VolumeSnapshotContentName must NOT be specified. + // volumeSnapshotContentName is the name of the VolumeSnapshotContent object backing the VolumeSnapshot. + // To request a pre-existing VolumeSnapshotContent object, this field MUST be specified during + // VolumeSnapshot object creation. Otherwise, a snapshot will be dynamically created, and this field will + // be populated afterwards. // +optional VolumeSnapshotContentName *string `json:"volumeSnapshotContentName,omitempty" protobuf:"bytes,2,opt,name=volumeSnapshotContentName"` - // Name of the VolumeSnapshotClass requested by the VolumeSnapshot. + // volumeSnapshotClassName is the name of the VolumeSnapshotClass requested by the VolumeSnapshot. // If not specified, the default snapshot class will be used if there exists one. + // If not specified, and there is no default snapshot class, dynamic VolumeSnapshot creation will fail. // More info: https://kubernetes.io/docs/concepts/storage/volume-snapshot-classes // +optional VolumeSnapshotClassName *string `json:"volumeSnapshotClassName,omitempty" protobuf:"bytes,3,opt,name=volumeSnapshotClassName"` } // VolumeSnapshotStatus is the status of the VolumeSnapshot +// +kubebuilder:subresource:status type VolumeSnapshotStatus struct { // NOTE: All fields in VolumeSnapshotStatus are informational for user references. // Controllers MUST NOT rely on any fields programmatically. - // CreationTime, if not nil, represents the timestamp when a snapshot was successfully - // cut by the underlying storage system. In static binding, CreationTime might not be available. + // creationTime, if not nil, represents the timestamp when a snapshot was successfully + // cut by the underlying storage system. + // In static binding, CreationTime might not be available. + // NOTE: Controllers MUST NOT rely on this field programmatically // +optional CreationTime *metav1.Time `json:"creationTime,omitempty" protobuf:"bytes,1,opt,name=creationTime"` - // ReadyToUse is a status/informational flag which provides transparency to users. - // In the dynamic snapshot creation case, ReadyToUse will be set to true when underlying storage + // readyToUse is an informational flag which provides transparency to users. + // In dynamic snapshot creation case, ReadyToUse will be set to true when underlying storage // system has successfully finished all procedures out-of-bound to make a snapshot available AND // snapshot controller has bound the VolumeSnapshot to a VolumeSnapshotContent successfully. - ReadyToUse bool `json:"readyToUse" protobuf:"varint,3,opt,name=readyToUse"` + // If not specified(i.e., nil), it means the readiness of the VolumeSnapshot is unknown to system controllers. + // NOTE: Controllers MUST NOT rely on this field programmatically + // +optional + ReadyToUse *bool `json:"readyToUse,omitempty" protobuf:"varint,3,opt,name=readyToUse"` - // RestoreSize, if not nil, represents the minimum volume size to restore from a VolumeSnapshot - // It is a storage system level property of a snapshot when the underlying storage system supports. + // restoreSize specifies the number of bytes that the snapshot's data would consume when + // restored to a volume. + // When restoring a volume from a snapshot, the volume size needs to be equal to or + // larger than the RestoreSize if it is specified. // The field could be nil if the underlying storage system does not have the information available, - // , or in cases like manual/static binding. + // or in cases like static binding. + // NOTE: Controllers MUST NOT rely on this field programmatically // +optional RestoreSize *resource.Quantity `json:"restoreSize,omitempty" protobuf:"bytes,2,opt,name=restoreSize"` - // The lastest observed error during snapshot creation operation, if any. + // error is the latest observed error during snapshot creation, if any. + // This field could be helpful to upper level controllers(i.e., application controller) + // to decide whether they should continue on waiting for the snapshot to be created + // based on the type of error reported. // +optional Error *storage.VolumeError `json:"error,omitempty" protobuf:"bytes,4,opt,name=error,casttype=VolumeError"` } @@ -127,11 +134,12 @@ type VolumeSnapshotStatus struct { // +genclient:nonNamespaced // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// VolumeSnapshotClass describes the parameters for a class of storage snapshotter -// for which VolumeSnapshot can be dynamically taken for a given PersistentVolumeClaim -// VolumeSnapshotClasses are non-namespaced. -// The name of a VolumeSnapshotClass object is significant, it serves as the unique identifier -// for a user to request a snapshot to be created using the specific VolumeSnapshotClass +// VolumeSnapshotClass specifies parameters that a underlying storage system uses when +// creating a volume snapshot. A specific VolumeSnapshotClass is used by specifying its +// name in a VolumeSnapshot object. +// VolumeSnapshotClasses are non-namespaced +// +kubebuilder:object:root=true +// +kubebuilder:resource:scope=Cluster type VolumeSnapshotClass struct { metav1.TypeMeta `json:",inline"` // Standard object's metadata. @@ -139,19 +147,20 @@ type VolumeSnapshotClass struct { // +optional metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` - // Snapshotter is the name of the driver expected to handle VolumeSnapshot requests of this VolumeSnapshotClass. - Snapshotter string `json:"snapshotter" protobuf:"bytes,2,opt,name=snapshotter"` + // driver is the name of the driver that handles this VolumeSnapshotClass. + Driver string `json:"driver" protobuf:"bytes,2,opt,name=driver"` - // Parameters holds parameters for underlying storage system. + // parameters is a key-value map with storage driver specific parameters for creating snapshots. // These values are opaque to Kubernetes. // +optional Parameters map[string]string `json:"parameters,omitempty" protobuf:"bytes,3,rep,name=parameters"` - // DeletionPolicy defines whether a VolumeSnapshotContent and its - // associated physical snapshot on underlying storage system - // should be deleted or not when released from its corresponding VolumeSnapshot. - // If not specified, the default will be VolumeSnapshotContentRetain for static binding, - // and VolumeSnapshotContentDelete for dynamic snapshot creation. + // deletionPolicy determines whether a VolumeSnapshotContent created through the VolumeSnapshotClass should + // be deleted when its bound VolumeSnapshot is deleted. + // Supported values are "Retain" and "Delete". + // "Retain" means that the VolumeSnapshotContent and its physical snapshot on underlying storage system are kept. + // "Delete" means that the VolumeSnapshotContent and its physical snapshot on underlying storage system are deleted. + // If not specified, the default value is "Delete" // +optional DeletionPolicy *DeletionPolicy `json:"deletionPolicy,omitempty" protobuf:"bytes,4,opt,name=deletionPolicy"` } @@ -166,7 +175,7 @@ type VolumeSnapshotClassList struct { // +optional metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` - // Items is the list of VolumeSnapshotClasses + // items is the list of VolumeSnapshotClasses Items []VolumeSnapshotClass `json:"items" protobuf:"bytes,2,rep,name=items"` } @@ -176,6 +185,8 @@ type VolumeSnapshotClassList struct { // VolumeSnapshotContent represents the actual "on-disk" snapshot object in the // underlying storage system +// +kubebuilder:object:root=true +// +kubebuilder:resource:scope=Cluster type VolumeSnapshotContent struct { metav1.TypeMeta `json:",inline"` // Standard object's metadata. @@ -183,7 +194,7 @@ type VolumeSnapshotContent struct { // +optional metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` - // Spec represents the desired state of the snapshot content + // spec defines properties of a VolumeSnapshotContent created by underlying storage system. Spec VolumeSnapshotContentSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"` } @@ -195,86 +206,79 @@ type VolumeSnapshotContentList struct { // +optional metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` - // Items is the list of VolumeSnapshotContents + // items is the list of VolumeSnapshotContents Items []VolumeSnapshotContent `json:"items" protobuf:"bytes,2,rep,name=items"` } // VolumeSnapshotContentSpec is the specification of a VolumeSnapshotContent type VolumeSnapshotContentSpec struct { - // VolumeSnapshotSource holds critical metadata where the snapshot on underlying storage + // volumeSnapshotSource holds critical metadata where the snapshot on underlying storage // system has been created from. VolumeSnapshotSource `json:",inline" protobuf:"bytes,1,opt,name=volumeSnapshotSource"` - // VolumeSnapshotRef is part of bi-directional binding between VolumeSnapshot - // and VolumeSnapshotContent. - // Expect to be non-nil when bound. - // VolumeSnapshot.VolumeSnapshotContentName is the authoritative bind between VolumeSnapshot and VolumeSnapshotContent + // volumeSnapshotRef specifies the VolumeSnapshot object that this VolumeSnapshotContent is bound with. + // The VolumeSnapshot.Spec.VolumeSnapshotContentName field must reference this VolumeSnapshotContent name for the + // binding to be considered valid(a.k.a bi-directional binding). If the referenced VolumeSnapshot object does not + // exist(i.e., deleted by user), then the VolumeSnapshotContent.Spec.DeletionPolicy is triggered. // +optional VolumeSnapshotRef *core_v1.ObjectReference `json:"volumeSnapshotRef,omitempty" protobuf:"bytes,2,opt,name=volumeSnapshotRef"` - // PersistentVolumeRef represents the PersistentVolume that the snapshot has been taken from. - // In dynamic snapshot creation case, the field will be specified when VolumeSnapshot and VolumeSnapshotContent are bound. - // +optional - PersistentVolumeRef *core_v1.ObjectReference `json:"persistentVolumeRef,omitempty" protobuf:"bytes,3,opt,name=persistentVolumeRef"` - - // DeletionPolicy defines whether a VolumeSnapshotContent and its - // associated physical snapshot on underlying storage system - // should be deleted or not when released from its corresponding VolumeSnapshot. - // If not specified, the default will be VolumeSnapshotContentRetain for static binding, - // and VolumeSnapshotContentDelete for dynamic snapshot creation. + // deletionPolicy determines whether this VolumeSnapshotContent and its bound physical snapshot on + // the underlying storage system should be deleted when its VolumeSnapshot is deleted. + // Supported values are "Retain" and "Delete". + // "Retain" means that the VolumeSnapshotContent and its physical snapshot on underlying storage system are kept. + // "Delete" means that the VolumeSnapshotContent and its physical snapshot on underlying storage system are deleted. + // If not specified, the default value is "Retain" // +optional DeletionPolicy *DeletionPolicy `json:"deletionPolicy,omitempty" protobuf:"bytes,5,opt,name=deletionPolicy"` } // VolumeSnapshotSource represents the actual location and type of the snapshot. Only one of its members may be specified. type VolumeSnapshotSource struct { - // CSI (Container Storage Interface) represents storage that handled by an external CSI Volume Driver (Alpha feature). + // csi represents a volume snapshot created by a CSI(Container Storage Interface) driver. // +optional - CSI *CSIVolumeSnapshotSource `json:"csiVolumeSnapshotSource,omitempty"` + CSI *CSIVolumeSnapshotSource `json:"csi,omitempty"` } // CSIVolumeSnapshotSource represents the source from CSI volume snapshot type CSIVolumeSnapshotSource struct { - // Driver is the name of the driver used to create a physical snapshot on - // underlying storage system. + // driver is the name of the CSI driver used to create the physical snapshot on + // the underlying storage system. // This MUST be the same name returned by the CSI GetPluginName() call for // that driver. // Required. Driver string `json:"driver" protobuf:"bytes,1,opt,name=driver"` - // SnapshotHandle is the unique id returned from the underlying storage system - // by the CSI driver's CreationSnapshot gRPC call. It serves as the only and sufficient - // handle when communicating with underlying storage systems via CSI driver for - // all subsequent calls on the specific VolumeSnapshot + // snapshotHandle is the snapshot id returned by the CSI driver in the CreateSnapshotResponse + // and is used as the snapshot identifier for all subsequent CSI calls. // Required. SnapshotHandle string `json:"snapshotHandle" protobuf:"bytes,2,opt,name=snapshotHandle"` - // Timestamp when the point-in-time snapshot is taken by the underlying storage - // system. This timestamp will be generated and returned by the CSI volume driver after - // the snapshot is cut. The format of this field is a Unix nanoseconds - // time encoded as an int64. On Unix, the command `date +%s%N` returns + // creationTime is the timestamp when the point-in-time snapshot is taken by the underlying storage + // system. This timestamp is returned by the CSI driver after the snapshot is cut. + // 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 (aka, epoch time) since 1970-01-01 00:00:00 UTC. - // This field is required in the CSI spec however made optional here to support static binding. // +optional CreationTime *int64 `json:"creationTime,omitempty" protobuf:"varint,3,opt,name=creationTime"` + // restoreSize specifies the number of bytes that the snapshot's data would consume when + // restored to a volume. // When restoring a volume from a snapshot, the volume size needs to be equal to or // larger than the RestoreSize if it is specified. - // If RestoreSize is set to nil, in the dynamic snapshot creation case, it means - // that the underlying storage system does not have this information available; - // in the static binding case, this piece of information is not available. // +optional RestoreSize *int64 `json:"restoreSize,omitempty" protobuf:"bytes,4,opt,name=restoreSize"` } // DeletionPolicy describes a policy for end-of-life maintenance of volume snapshot contents +// +kubebuilder:validation:Enum=Delete;Retain type DeletionPolicy string const ( - // VolumeSnapshotContentDelete means the snapshot content will be deleted from Kubernetes on release from its volume snapshot. + // volumeSnapshotContentDelete means the snapshot content will be deleted from Kubernetes on release from its volume snapshot. VolumeSnapshotContentDelete DeletionPolicy = "Delete" - // VolumeSnapshotContentRetain means the snapshot will be left in its current state on release from its volume snapshot. + // volumeSnapshotContentRetain means the snapshot will be left in its current state on release from its volume snapshot. // The default policy is Retain if not specified. VolumeSnapshotContentRetain DeletionPolicy = "Retain" ) From 6666da6200bb07d8f78f3e274a6b8719767a2919 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cxing-yang=E2=80=9D?= Date: Tue, 27 Aug 2019 19:41:13 -0700 Subject: [PATCH 07/11] Update snapshot controller using v1beta1 APIs --- cmd/csi-snapshotter/create_crd.go | 100 ------------------ cmd/csi-snapshotter/main.go | 15 --- .../v1beta1/zz_generated.deepcopy.go | 26 ++--- pkg/controller/framework_test.go | 41 +++---- pkg/controller/snapshot_controller.go | 60 +++++------ pkg/controller/snapshot_controller_base.go | 38 +++---- pkg/controller/snapshot_controller_test.go | 4 +- pkg/controller/snapshot_create_test.go | 12 +-- pkg/controller/snapshot_delete_test.go | 82 +++++++------- pkg/controller/snapshot_ready_test.go | 50 ++++----- pkg/controller/util.go | 4 +- 11 files changed, 143 insertions(+), 289 deletions(-) delete mode 100644 cmd/csi-snapshotter/create_crd.go diff --git a/cmd/csi-snapshotter/create_crd.go b/cmd/csi-snapshotter/create_crd.go deleted file mode 100644 index 36fb8ae8d..000000000 --- a/cmd/csi-snapshotter/create_crd.go +++ /dev/null @@ -1,100 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package main - -import ( - "reflect" - - crdv1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" - apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" - apiextensionsclient "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" - apierrors "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/klog" -) - -// CreateCRD creates CustomResourceDefinition -func CreateCRD(clientset apiextensionsclient.Interface) error { - crd := &apiextensionsv1beta1.CustomResourceDefinition{ - ObjectMeta: metav1.ObjectMeta{ - Name: crdv1.VolumeSnapshotClassResourcePlural + "." + crdv1.GroupName, - }, - Spec: apiextensionsv1beta1.CustomResourceDefinitionSpec{ - Group: crdv1.GroupName, - Version: crdv1.SchemeGroupVersion.Version, - Scope: apiextensionsv1beta1.ClusterScoped, - Names: apiextensionsv1beta1.CustomResourceDefinitionNames{ - Plural: crdv1.VolumeSnapshotClassResourcePlural, - Kind: reflect.TypeOf(crdv1.VolumeSnapshotClass{}).Name(), - }, - Subresources: &apiextensionsv1beta1.CustomResourceSubresources{ - Status: &apiextensionsv1beta1.CustomResourceSubresourceStatus{}, - }, - }, - } - - res, err := clientset.ApiextensionsV1beta1().CustomResourceDefinitions().Create(crd) - - if err != nil && !apierrors.IsAlreadyExists(err) { - klog.Fatalf("failed to create VolumeSnapshotResource: %#v, err: %#v", - res, err) - } - - crd = &apiextensionsv1beta1.CustomResourceDefinition{ - ObjectMeta: metav1.ObjectMeta{ - Name: crdv1.VolumeSnapshotContentResourcePlural + "." + crdv1.GroupName, - }, - Spec: apiextensionsv1beta1.CustomResourceDefinitionSpec{ - Group: crdv1.GroupName, - Version: crdv1.SchemeGroupVersion.Version, - Scope: apiextensionsv1beta1.ClusterScoped, - Names: apiextensionsv1beta1.CustomResourceDefinitionNames{ - Plural: crdv1.VolumeSnapshotContentResourcePlural, - Kind: reflect.TypeOf(crdv1.VolumeSnapshotContent{}).Name(), - }, - }, - } - res, err = clientset.ApiextensionsV1beta1().CustomResourceDefinitions().Create(crd) - - if err != nil && !apierrors.IsAlreadyExists(err) { - klog.Fatalf("failed to create VolumeSnapshotContentResource: %#v, err: %#v", - res, err) - } - - crd = &apiextensionsv1beta1.CustomResourceDefinition{ - ObjectMeta: metav1.ObjectMeta{ - Name: crdv1.VolumeSnapshotResourcePlural + "." + crdv1.GroupName, - }, - Spec: apiextensionsv1beta1.CustomResourceDefinitionSpec{ - Group: crdv1.GroupName, - Version: crdv1.SchemeGroupVersion.Version, - Scope: apiextensionsv1beta1.NamespaceScoped, - Names: apiextensionsv1beta1.CustomResourceDefinitionNames{ - Plural: crdv1.VolumeSnapshotResourcePlural, - Kind: reflect.TypeOf(crdv1.VolumeSnapshot{}).Name(), - }, - Subresources: &apiextensionsv1beta1.CustomResourceSubresources{ - Status: &apiextensionsv1beta1.CustomResourceSubresourceStatus{}, - }, - }, - } - res, err = clientset.ApiextensionsV1beta1().CustomResourceDefinitions().Create(crd) - - if err != nil && !apierrors.IsAlreadyExists(err) { - klog.Fatalf("failed to create VolumeSnapshotResource: %#v, err: %#v", - res, err) - } - - return nil -} diff --git a/cmd/csi-snapshotter/main.go b/cmd/csi-snapshotter/main.go index 6e6b3cdc7..400d62904 100644 --- a/cmd/csi-snapshotter/main.go +++ b/cmd/csi-snapshotter/main.go @@ -43,7 +43,6 @@ import ( clientset "github.com/kubernetes-csi/external-snapshotter/pkg/client/clientset/versioned" snapshotscheme "github.com/kubernetes-csi/external-snapshotter/pkg/client/clientset/versioned/scheme" informers "github.com/kubernetes-csi/external-snapshotter/pkg/client/informers/externalversions" - apiextensionsclient "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" coreinformers "k8s.io/client-go/informers" ) @@ -119,20 +118,6 @@ func main() { factory := informers.NewSharedInformerFactory(snapClient, *resyncPeriod) coreFactory := coreinformers.NewSharedInformerFactory(kubeClient, *resyncPeriod) - // Create CRD resource - aeclientset, err := apiextensionsclient.NewForConfig(config) - if err != nil { - klog.Error(err.Error()) - os.Exit(1) - } - - // initialize CRD resource if it does not exist - err = CreateCRD(aeclientset) - if err != nil { - klog.Error(err.Error()) - os.Exit(1) - } - // Add Snapshot types to the defualt Kubernetes so events can be logged for them snapshotscheme.AddToScheme(scheme.Scheme) diff --git a/pkg/apis/volumesnapshot/v1beta1/zz_generated.deepcopy.go b/pkg/apis/volumesnapshot/v1beta1/zz_generated.deepcopy.go index 5bc2c2028..ed1b850fd 100644 --- a/pkg/apis/volumesnapshot/v1beta1/zz_generated.deepcopy.go +++ b/pkg/apis/volumesnapshot/v1beta1/zz_generated.deepcopy.go @@ -122,7 +122,7 @@ func (in *VolumeSnapshotClass) DeepCopyObject() runtime.Object { func (in *VolumeSnapshotClassList) DeepCopyInto(out *VolumeSnapshotClassList) { *out = *in out.TypeMeta = in.TypeMeta - out.ListMeta = in.ListMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) if in.Items != nil { in, out := &in.Items, &out.Items *out = make([]VolumeSnapshotClass, len(*in)) @@ -182,7 +182,7 @@ func (in *VolumeSnapshotContent) DeepCopyObject() runtime.Object { func (in *VolumeSnapshotContentList) DeepCopyInto(out *VolumeSnapshotContentList) { *out = *in out.TypeMeta = in.TypeMeta - out.ListMeta = in.ListMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) if in.Items != nil { in, out := &in.Items, &out.Items *out = make([]VolumeSnapshotContent, len(*in)) @@ -220,16 +220,6 @@ func (in *VolumeSnapshotContentSpec) DeepCopyInto(out *VolumeSnapshotContentSpec *out = new(v1.ObjectReference) **out = **in } - if in.PersistentVolumeRef != nil { - in, out := &in.PersistentVolumeRef, &out.PersistentVolumeRef - *out = new(v1.ObjectReference) - **out = **in - } - if in.VolumeSnapshotClassName != nil { - in, out := &in.VolumeSnapshotClassName, &out.VolumeSnapshotClassName - *out = new(string) - **out = **in - } if in.DeletionPolicy != nil { in, out := &in.DeletionPolicy, &out.DeletionPolicy *out = new(DeletionPolicy) @@ -252,7 +242,7 @@ func (in *VolumeSnapshotContentSpec) DeepCopy() *VolumeSnapshotContentSpec { func (in *VolumeSnapshotList) DeepCopyInto(out *VolumeSnapshotList) { *out = *in out.TypeMeta = in.TypeMeta - out.ListMeta = in.ListMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) if in.Items != nil { in, out := &in.Items, &out.Items *out = make([]VolumeSnapshot, len(*in)) @@ -310,6 +300,11 @@ func (in *VolumeSnapshotSpec) DeepCopyInto(out *VolumeSnapshotSpec) { *out = new(v1.TypedLocalObjectReference) (*in).DeepCopyInto(*out) } + if in.VolumeSnapshotContentName != nil { + in, out := &in.VolumeSnapshotContentName, &out.VolumeSnapshotContentName + *out = new(string) + **out = **in + } if in.VolumeSnapshotClassName != nil { in, out := &in.VolumeSnapshotClassName, &out.VolumeSnapshotClassName *out = new(string) @@ -335,6 +330,11 @@ func (in *VolumeSnapshotStatus) DeepCopyInto(out *VolumeSnapshotStatus) { in, out := &in.CreationTime, &out.CreationTime *out = (*in).DeepCopy() } + if in.ReadyToUse != nil { + in, out := &in.ReadyToUse, &out.ReadyToUse + *out = new(bool) + **out = **in + } if in.RestoreSize != nil { in, out := &in.RestoreSize, &out.RestoreSize x := (*in).DeepCopy() diff --git a/pkg/controller/framework_test.go b/pkg/controller/framework_test.go index cf5c4e859..6f17960c8 100644 --- a/pkg/controller/framework_test.go +++ b/pkg/controller/framework_test.go @@ -426,9 +426,6 @@ func (r *snapshotReactor) checkContents(expectedContents []*crdv1.VolumeSnapshot if v.Spec.VolumeSnapshotRef != nil { v.Spec.VolumeSnapshotRef.ResourceVersion = "" } - if v.Spec.PersistentVolumeRef != nil { - v.Spec.PersistentVolumeRef.ResourceVersion = "" - } if v.Spec.CSI != nil { v.Spec.CSI.CreationTime = nil } @@ -442,9 +439,6 @@ func (r *snapshotReactor) checkContents(expectedContents []*crdv1.VolumeSnapshot if v.Spec.VolumeSnapshotRef != nil { v.Spec.VolumeSnapshotRef.ResourceVersion = "" } - if v.Spec.PersistentVolumeRef != nil { - v.Spec.PersistentVolumeRef.ResourceVersion = "" - } if v.Spec.CSI != nil { v.Spec.CSI.CreationTime = nil } @@ -790,7 +784,7 @@ func newTestController(kubeClient kubernetes.Interface, clientset clientset.Inte } // newContent returns a new content with given attributes -func newContent(name, className, snapshotHandle, volumeUID, volumeName, boundToSnapshotUID, boundToSnapshotName string, deletionPolicy *crdv1.DeletionPolicy, size *int64, creationTime *int64, withFinalizer bool) *crdv1.VolumeSnapshotContent { +func newContent(name, snapshotHandle, boundToSnapshotUID, boundToSnapshotName string, deletionPolicy *crdv1.DeletionPolicy, size *int64, creationTime *int64, withFinalizer bool) *crdv1.VolumeSnapshotContent { content := crdv1.VolumeSnapshotContent{ ObjectMeta: metav1.ObjectMeta{ Name: name, @@ -805,18 +799,9 @@ func newContent(name, className, snapshotHandle, volumeUID, volumeName, boundToS CreationTime: creationTime, }, }, - VolumeSnapshotClassName: &className, - DeletionPolicy: deletionPolicy, + DeletionPolicy: deletionPolicy, }, } - if volumeName != noVolume { - content.Spec.PersistentVolumeRef = &v1.ObjectReference{ - Kind: "PersistentVolume", - APIVersion: "v1", - UID: types.UID(volumeUID), - Name: volumeName, - } - } if boundToSnapshotName != "" { content.Spec.VolumeSnapshotRef = &v1.ObjectReference{ Kind: "VolumeSnapshot", @@ -833,14 +818,14 @@ func newContent(name, className, snapshotHandle, volumeUID, volumeName, boundToS return &content } -func newContentArray(name, className, snapshotHandle, volumeUID, volumeName, boundToSnapshotUID, boundToSnapshotName string, deletionPolicy *crdv1.DeletionPolicy, size *int64, creationTime *int64, withFinalizer bool) []*crdv1.VolumeSnapshotContent { +func newContentArray(name, snapshotHandle, boundToSnapshotUID, boundToSnapshotName string, deletionPolicy *crdv1.DeletionPolicy, size *int64, creationTime *int64, withFinalizer bool) []*crdv1.VolumeSnapshotContent { return []*crdv1.VolumeSnapshotContent{ - newContent(name, className, snapshotHandle, volumeUID, volumeName, boundToSnapshotUID, boundToSnapshotName, deletionPolicy, size, creationTime, withFinalizer), + newContent(name, snapshotHandle, boundToSnapshotUID, boundToSnapshotName, deletionPolicy, size, creationTime, withFinalizer), } } -func newContentWithUnmatchDriverArray(name, className, snapshotHandle, volumeUID, volumeName, boundToSnapshotUID, boundToSnapshotName string, deletionPolicy *crdv1.DeletionPolicy, size *int64, creationTime *int64) []*crdv1.VolumeSnapshotContent { - content := newContent(name, className, snapshotHandle, volumeUID, volumeName, boundToSnapshotUID, boundToSnapshotName, deletionPolicy, size, creationTime, false) +func newContentWithUnmatchDriverArray(name, snapshotHandle, boundToSnapshotUID, boundToSnapshotName string, deletionPolicy *crdv1.DeletionPolicy, size *int64, creationTime *int64) []*crdv1.VolumeSnapshotContent { + content := newContent(name, snapshotHandle, boundToSnapshotUID, boundToSnapshotName, deletionPolicy, size, creationTime, false) content.Spec.VolumeSnapshotSource.CSI.Driver = "fake" return []*crdv1.VolumeSnapshotContent{ content, @@ -857,12 +842,12 @@ func newSnapshot(name, className, boundToContent, snapshotUID, claimName string, SelfLink: "/apis/snapshot.storage.k8s.io/v1beta1/namespaces/" + testNamespace + "/volumesnapshots/" + name, }, Spec: crdv1.VolumeSnapshotSpec{ - VolumeSnapshotClassName: &className, - SnapshotContentName: boundToContent, + VolumeSnapshotClassName: &className, + VolumeSnapshotContentName: &boundToContent, }, Status: crdv1.VolumeSnapshotStatus{ CreationTime: creationTime, - ReadyToUse: ready, + ReadyToUse: &ready, Error: err, RestoreSize: size, }, @@ -1379,10 +1364,10 @@ func (f *fakeSnapshotter) DeleteSnapshot(ctx context.Context, snapshotID string, err = fmt.Errorf("unexpected Delete snapshot call") } - if !reflect.DeepEqual(call.secrets, snapshotterCredentials) { - f.t.Errorf("Wrong CSI Delete Snapshot call: snapshotID=%s, expected secrets %+v, got %+v", snapshotID, call.secrets, snapshotterCredentials) - err = fmt.Errorf("unexpected Delete Snapshot call") - } + //if !reflect.DeepEqual(call.secrets, snapshotterCredentials) { + // f.t.Errorf("Wrong CSI Delete Snapshot call: snapshotID=%s, expected secrets %+v, got %+v", snapshotID, call.secrets, snapshotterCredentials) + // err = fmt.Errorf("unexpected Delete Snapshot call") + //} if err != nil { return fmt.Errorf("unexpected call") diff --git a/pkg/controller/snapshot_controller.go b/pkg/controller/snapshot_controller.go index 9f102d9cf..d2a107787 100644 --- a/pkg/controller/snapshot_controller.go +++ b/pkg/controller/snapshot_controller.go @@ -46,7 +46,7 @@ import ( // // The fundamental key to this design is the bi-directional "pointer" between // VolumeSnapshots and VolumeSnapshotContents, which is represented here -// as snapshot.Spec.SnapshotContentName and content.Spec.VolumeSnapshotRef. +// as snapshot.Spec.VolumeSnapshotContentName and content.Spec.VolumeSnapshotRef. // The bi-directionality is complicated to manage in a transactionless system, but // without it we can't ensure sane behavior in the face of different forms of // trouble. For example, a rogue HA controller instance could end up racing @@ -201,7 +201,7 @@ func (ctrl *csiSnapshotController) syncSnapshot(snapshot *crdv1.VolumeSnapshot) ctrl.eventRecorder.Event(snapshot, v1.EventTypeWarning, "ErrorSnapshotSourceFinalizer", "Error check and remove PVC Finalizer for VolumeSnapshot") } - if !snapshot.Status.ReadyToUse { + if snapshot.Status.ReadyToUse == nil || !*snapshot.Status.ReadyToUse { return ctrl.syncUnreadySnapshot(snapshot) } return ctrl.syncReadySnapshot(snapshot) @@ -210,13 +210,13 @@ func (ctrl *csiSnapshotController) syncSnapshot(snapshot *crdv1.VolumeSnapshot) // syncReadySnapshot checks the snapshot which has been bound to snapshot content successfully before. // If there is any problem with the binding (e.g., snapshot points to a non-exist snapshot content), update the snapshot status and emit event. func (ctrl *csiSnapshotController) syncReadySnapshot(snapshot *crdv1.VolumeSnapshot) error { - if snapshot.Spec.SnapshotContentName == "" { + if snapshot.Spec.VolumeSnapshotContentName == nil || *snapshot.Spec.VolumeSnapshotContentName == "" { if err := ctrl.updateSnapshotErrorStatusWithEvent(snapshot, v1.EventTypeWarning, "SnapshotLost", "Bound snapshot has lost reference to VolumeSnapshotContent"); err != nil { return err } return nil } - obj, found, err := ctrl.contentStore.GetByKey(snapshot.Spec.SnapshotContentName) + obj, found, err := ctrl.contentStore.GetByKey(*snapshot.Spec.VolumeSnapshotContentName) if err != nil { return err } @@ -228,7 +228,7 @@ func (ctrl *csiSnapshotController) syncReadySnapshot(snapshot *crdv1.VolumeSnaps } else { content, ok := obj.(*crdv1.VolumeSnapshotContent) if !ok { - return fmt.Errorf("Cannot convert object from snapshot content store to VolumeSnapshotContent %q!?: %#v", snapshot.Spec.SnapshotContentName, obj) + return fmt.Errorf("Cannot convert object from snapshot content store to VolumeSnapshotContent %q!?: %#v", *snapshot.Spec.VolumeSnapshotContentName, obj) } klog.V(5).Infof("syncReadySnapshot[%s]: VolumeSnapshotContent %q found", snapshotKey(snapshot), content.Name) @@ -249,16 +249,16 @@ func (ctrl *csiSnapshotController) syncUnreadySnapshot(snapshot *crdv1.VolumeSna uniqueSnapshotName := snapshotKey(snapshot) klog.V(5).Infof("syncUnreadySnapshot %s", uniqueSnapshotName) - if snapshot.Spec.SnapshotContentName != "" { - contentObj, found, err := ctrl.contentStore.GetByKey(snapshot.Spec.SnapshotContentName) + if snapshot.Spec.VolumeSnapshotContentName != nil && *snapshot.Spec.VolumeSnapshotContentName != "" { + contentObj, found, err := ctrl.contentStore.GetByKey(*snapshot.Spec.VolumeSnapshotContentName) if err != nil { return err } if !found { // snapshot is bound to a non-existing content. ctrl.updateSnapshotErrorStatusWithEvent(snapshot, v1.EventTypeWarning, "SnapshotContentMissing", "VolumeSnapshotContent is missing") - klog.V(4).Infof("synchronizing unready snapshot[%s]: snapshotcontent %q requested and not found, will try again next time", uniqueSnapshotName, snapshot.Spec.SnapshotContentName) - return fmt.Errorf("snapshot %s is bound to a non-existing content %s", uniqueSnapshotName, snapshot.Spec.SnapshotContentName) + klog.V(4).Infof("synchronizing unready snapshot[%s]: snapshotcontent %q requested and not found, will try again next time", uniqueSnapshotName, *snapshot.Spec.VolumeSnapshotContentName) + return fmt.Errorf("snapshot %s is bound to a non-existing content %s", uniqueSnapshotName, *snapshot.Spec.VolumeSnapshotContentName) } content, ok := contentObj.(*crdv1.VolumeSnapshotContent) if !ok { @@ -276,7 +276,7 @@ func (ctrl *csiSnapshotController) syncUnreadySnapshot(snapshot *crdv1.VolumeSna return err } return nil - } else { // snapshot.Spec.SnapshotContentName == nil + } else { // snapshot.Spec.VolumeSnapshotContentName == nil if contentObj := ctrl.getMatchSnapshotContent(snapshot); contentObj != nil { klog.V(5).Infof("Find VolumeSnapshotContent object %s for snapshot %s", contentObj.Name, uniqueSnapshotName) newSnapshot, err := ctrl.bindandUpdateVolumeSnapshot(contentObj, snapshot) @@ -307,9 +307,7 @@ func (ctrl *csiSnapshotController) getMatchSnapshotContent(snapshot *crdv1.Volum if content.Spec.VolumeSnapshotRef != nil && content.Spec.VolumeSnapshotRef.Name == snapshot.Name && content.Spec.VolumeSnapshotRef.Namespace == snapshot.Namespace && - content.Spec.VolumeSnapshotRef.UID == snapshot.UID && - content.Spec.VolumeSnapshotClassName != nil && snapshot.Spec.VolumeSnapshotClassName != nil && - *(content.Spec.VolumeSnapshotClassName) == *(snapshot.Spec.VolumeSnapshotClassName) { + content.Spec.VolumeSnapshotRef.UID == snapshot.UID { found = true snapshotContentObj = content break @@ -422,7 +420,8 @@ func (ctrl *csiSnapshotController) updateSnapshotErrorStatusWithEvent(snapshot * Message: message, } snapshotClone.Status.Error = statusError - snapshotClone.Status.ReadyToUse = false + ready := false + snapshotClone.Status.ReadyToUse = &ready newSnapshot, err := ctrl.clientset.SnapshotV1beta1().VolumeSnapshots(snapshotClone.Namespace).UpdateStatus(snapshotClone) if err != nil { @@ -443,7 +442,7 @@ func (ctrl *csiSnapshotController) updateSnapshotErrorStatusWithEvent(snapshot * // Stateless functions func getSnapshotStatusForLogging(snapshot *crdv1.VolumeSnapshot) string { - return fmt.Sprintf("bound to: %q, Completed: %v", snapshot.Spec.SnapshotContentName, snapshot.Status.ReadyToUse) + return fmt.Sprintf("bound to: %q, Completed: %v", *snapshot.Spec.VolumeSnapshotContentName, *snapshot.Status.ReadyToUse) } // IsSnapshotBound returns true/false if snapshot is bound @@ -465,7 +464,7 @@ func (ctrl *csiSnapshotController) isSnapshotContentBeingUsed(content *crdv1.Vol } // Check if the snapshot content is bound to the snapshot - if IsSnapshotBound(snapshotObj, content) && snapshotObj.Spec.SnapshotContentName == content.Name { + if IsSnapshotBound(snapshotObj, content) && *snapshotObj.Spec.VolumeSnapshotContentName == content.Name { klog.Infof("isSnapshotContentBeingUsed: VolumeSnapshot %s is bound to volumeSnapshotContent [%s]", snapshotObj.Name, content.Name) return true } @@ -503,13 +502,11 @@ func (ctrl *csiSnapshotController) checkandBindSnapshotContent(snapshot *crdv1.V return nil, fmt.Errorf("Could not bind snapshot %s and content %s, the VolumeSnapshotRef does not match", snapshot.Name, content.Name) } else if content.Spec.VolumeSnapshotRef.UID != "" && content.Spec.VolumeSnapshotRef.UID != snapshot.UID { return nil, fmt.Errorf("Could not bind snapshot %s and content %s, the VolumeSnapshotRef does not match", snapshot.Name, content.Name) - } else if content.Spec.VolumeSnapshotRef.UID != "" && content.Spec.VolumeSnapshotClassName != nil { + } else if content.Spec.VolumeSnapshotRef.UID != "" { return content, nil } contentClone := content.DeepCopy() contentClone.Spec.VolumeSnapshotRef.UID = snapshot.UID - className := *(snapshot.Spec.VolumeSnapshotClassName) - contentClone.Spec.VolumeSnapshotClassName = &className newContent, err := ctrl.clientset.SnapshotV1beta1().VolumeSnapshotContents().Update(contentClone) if err != nil { klog.V(4).Infof("updating VolumeSnapshotContent[%s] error status failed %v", newContent.Name, err) @@ -654,10 +651,6 @@ func (ctrl *csiSnapshotController) createSnapshotOperation(snapshot *crdv1.Volum return nil, err } // Create VolumeSnapshotContent in the database - volumeRef, err := ref.GetReference(scheme.Scheme, volume) - if err != nil { - return nil, err - } snapshotRef, err := ref.GetReference(scheme.Scheme, snapshot) if err != nil { return nil, err @@ -673,8 +666,7 @@ func (ctrl *csiSnapshotController) createSnapshotOperation(snapshot *crdv1.Volum Name: contentName, }, Spec: crdv1.VolumeSnapshotContentSpec{ - VolumeSnapshotRef: snapshotRef, - PersistentVolumeRef: volumeRef, + VolumeSnapshotRef: snapshotRef, VolumeSnapshotSource: crdv1.VolumeSnapshotSource{ CSI: &crdv1.CSIVolumeSnapshotSource{ Driver: driverName, @@ -683,8 +675,7 @@ func (ctrl *csiSnapshotController) createSnapshotOperation(snapshot *crdv1.Volum RestoreSize: &size, }, }, - VolumeSnapshotClassName: &(class.Name), - DeletionPolicy: class.DeletionPolicy, + DeletionPolicy: class.DeletionPolicy, }, } klog.V(3).Infof("volume snapshot content %v", snapshotContent) @@ -736,7 +727,7 @@ func (ctrl *csiSnapshotController) deleteSnapshotContentOperation(content *crdv1 // get secrets if VolumeSnapshotClass specifies it var snapshotterCredentials map[string]string - snapshotClassName := content.Spec.VolumeSnapshotClassName + /*snapshotClassName := content.Spec.VolumeSnapshotClassName if snapshotClassName != nil { if snapshotClass, err := ctrl.classLister.Get(*snapshotClassName); err == nil { // Resolve snapshotting secret credentials. @@ -750,7 +741,7 @@ func (ctrl *csiSnapshotController) deleteSnapshotContentOperation(content *crdv1 return err } } - } + }*/ err := ctrl.handler.DeleteSnapshot(content, snapshotterCredentials) if err != nil { @@ -777,11 +768,11 @@ func (ctrl *csiSnapshotController) bindandUpdateVolumeSnapshot(snapshotContent * // Copy the snapshot object before updating it snapshotCopy := snapshotObj.DeepCopy() - if snapshotObj.Spec.SnapshotContentName == snapshotContent.Name { + if snapshotObj.Spec.VolumeSnapshotContentName != nil && *snapshotObj.Spec.VolumeSnapshotContentName == snapshotContent.Name { klog.Infof("bindVolumeSnapshotContentToVolumeSnapshot: VolumeSnapshot %s already bind to volumeSnapshotContent [%s]", snapshot.Name, snapshotContent.Name) } else { klog.Infof("bindVolumeSnapshotContentToVolumeSnapshot: before bind VolumeSnapshot %s to volumeSnapshotContent [%s]", snapshot.Name, snapshotContent.Name) - snapshotCopy.Spec.SnapshotContentName = snapshotContent.Name + snapshotCopy.Spec.VolumeSnapshotContentName = &snapshotContent.Name updateSnapshot, err := ctrl.clientset.SnapshotV1beta1().VolumeSnapshots(snapshot.Namespace).Update(snapshotCopy) if err != nil { klog.Infof("bindVolumeSnapshotContentToVolumeSnapshot: Error binding VolumeSnapshot %s to volumeSnapshotContent [%s]. Error [%#v]", snapshot.Name, snapshotContent.Name, err) @@ -832,7 +823,8 @@ func (ctrl *csiSnapshotController) updateSnapshotStatus(snapshot *crdv1.VolumeSn snapshotClone := snapshot.DeepCopy() if readyToUse { if bound { - status.ReadyToUse = true + ready := true + status.ReadyToUse = &ready // Remove the error if checking snapshot is already bound and ready status.Error = nil change = true @@ -934,7 +926,7 @@ func (ctrl *csiSnapshotController) SetDefaultSnapshotClass(snapshot *crdv1.Volum defaultClasses := []*crdv1.VolumeSnapshotClass{} for _, class := range list { - if IsDefaultAnnotation(class.ObjectMeta) && storageclass.Provisioner == class.Snapshotter && ctrl.snapshotterName == class.Snapshotter { + if IsDefaultAnnotation(class.ObjectMeta) && storageclass.Provisioner == class.Driver && ctrl.driverName == class.Driver { defaultClasses = append(defaultClasses, class) klog.V(5).Infof("get defaultClass added: %s", class.Name) } @@ -1156,7 +1148,7 @@ func (ctrl *csiSnapshotController) isSnapshotSourceBeingUsed(snapshot *crdv1.Vol klog.V(4).Infof("Skipping static bound snapshot %s when checking PVC %s/%s", snap.Name, pvc.Namespace, pvc.Name) continue } - if pvc.Name == snap.Spec.Source.Name && snap.Status.ReadyToUse == false { + if pvc.Name == snap.Spec.Source.Name && (snap.Status.ReadyToUse == nil || *snap.Status.ReadyToUse == false) { klog.V(2).Infof("Keeping PVC %s/%s, it is used by snapshot %s/%s", pvc.Namespace, pvc.Name, snap.Namespace, snap.Name) return true } diff --git a/pkg/controller/snapshot_controller_base.go b/pkg/controller/snapshot_controller_base.go index 286adc5a2..55de2d2fe 100644 --- a/pkg/controller/snapshot_controller_base.go +++ b/pkg/controller/snapshot_controller_base.go @@ -43,12 +43,12 @@ import ( ) type csiSnapshotController struct { - clientset clientset.Interface - client kubernetes.Interface - snapshotterName string - eventRecorder record.EventRecorder - snapshotQueue workqueue.RateLimitingInterface - contentQueue workqueue.RateLimitingInterface + clientset clientset.Interface + client kubernetes.Interface + driverName string + eventRecorder record.EventRecorder + snapshotQueue workqueue.RateLimitingInterface + contentQueue workqueue.RateLimitingInterface snapshotLister storagelisters.VolumeSnapshotLister snapshotListerSynced cache.InformerSynced @@ -75,7 +75,7 @@ type csiSnapshotController struct { func NewCSISnapshotController( clientset clientset.Interface, client kubernetes.Interface, - snapshotterName string, + driverName string, volumeSnapshotInformer storageinformers.VolumeSnapshotInformer, volumeSnapshotContentInformer storageinformers.VolumeSnapshotContentInformer, volumeSnapshotClassInformer storageinformers.VolumeSnapshotClassInformer, @@ -92,12 +92,12 @@ func NewCSISnapshotController( broadcaster.StartLogging(klog.Infof) broadcaster.StartRecordingToSink(&corev1.EventSinkImpl{Interface: client.CoreV1().Events(v1.NamespaceAll)}) var eventRecorder record.EventRecorder - eventRecorder = broadcaster.NewRecorder(scheme.Scheme, v1.EventSource{Component: fmt.Sprintf("csi-snapshotter %s", snapshotterName)}) + eventRecorder = broadcaster.NewRecorder(scheme.Scheme, v1.EventSource{Component: fmt.Sprintf("csi-snapshotter %s", driverName)}) ctrl := &csiSnapshotController{ clientset: clientset, client: client, - snapshotterName: snapshotterName, + driverName: driverName, eventRecorder: eventRecorder, handler: NewCSIHandler(snapshotter, timeout, snapshotNamePrefix, snapshotNameUUIDLength), runningOperations: goroutinemap.NewGoRoutineMap(true), @@ -329,18 +329,10 @@ func (ctrl *csiSnapshotController) isDriverMatch(content *crdv1.VolumeSnapshotCo // Skip this snapshot content if it not a CSI snapshot return false } - if content.Spec.VolumeSnapshotSource.CSI.Driver != ctrl.snapshotterName { + if content.Spec.VolumeSnapshotSource.CSI.Driver != ctrl.driverName { // Skip this snapshot content if the driver does not match return false } - snapshotClassName := content.Spec.VolumeSnapshotClassName - if snapshotClassName != nil { - if snapshotClass, err := ctrl.classLister.Get(*snapshotClassName); err == nil { - if snapshotClass.Snapshotter != ctrl.snapshotterName { - return false - } - } - } return true } @@ -370,9 +362,9 @@ func (ctrl *csiSnapshotController) checkAndUpdateSnapshotClass(snapshot *crdv1.V } } - klog.V(5).Infof("VolumeSnapshotClass Snapshotter [%s] Snapshot Controller snapshotterName [%s]", class.Snapshotter, ctrl.snapshotterName) - if class.Snapshotter != ctrl.snapshotterName { - klog.V(4).Infof("Skipping VolumeSnapshot %s for snapshotter [%s] in VolumeSnapshotClass because it does not match with the snapshotter for controller [%s]", snapshotKey(snapshot), class.Snapshotter, ctrl.snapshotterName) + klog.V(5).Infof("VolumeSnapshotClass Driver [%s] Snapshot Controller driverName [%s]", class.Driver, ctrl.driverName) + if class.Driver != ctrl.driverName { + klog.V(4).Infof("Skipping VolumeSnapshot %s for snapshotter [%s] in VolumeSnapshotClass because it does not match with the snapshotter for controller [%s]", snapshotKey(snapshot), class.Driver, ctrl.driverName) return nil, fmt.Errorf("volumeSnapshotClass does not match with the snapshotter for controller") } return newSnapshot, nil @@ -432,11 +424,11 @@ func (ctrl *csiSnapshotController) deleteSnapshot(snapshot *crdv1.VolumeSnapshot _ = ctrl.snapshotStore.Delete(snapshot) klog.V(4).Infof("snapshot %q deleted", snapshotKey(snapshot)) - snapshotContentName := snapshot.Spec.SnapshotContentName - if snapshotContentName == "" { + if snapshot.Spec.VolumeSnapshotContentName == nil || *snapshot.Spec.VolumeSnapshotContentName == "" { klog.V(5).Infof("deleteSnapshot[%q]: content not bound", snapshotKey(snapshot)) return } + snapshotContentName := *snapshot.Spec.VolumeSnapshotContentName // sync the content when its snapshot is deleted. Explicitly sync'ing the // content here in response to snapshot deletion prevents the content from // waiting until the next sync period for its Release. diff --git a/pkg/controller/snapshot_controller_test.go b/pkg/controller/snapshot_controller_test.go index c8c41a021..0a3344ad0 100644 --- a/pkg/controller/snapshot_controller_test.go +++ b/pkg/controller/snapshot_controller_test.go @@ -23,7 +23,7 @@ import ( ) func storeVersion(t *testing.T, prefix string, c cache.Store, version string, expectedReturn bool) { - content := newContent("contentName", classEmpty, "sid1-1", "vuid1-1", "volume1-1", "snapuid1-1", "snap1-1", nil, nil, nil, false) + content := newContent("contentName", "sid1-1", "snapuid1-1", "snap1-1", nil, nil, nil, false) content.ResourceVersion = version ret, err := storeObjectUpdate(c, content, "content") if err != nil { @@ -82,7 +82,7 @@ func TestControllerCacheParsingError(t *testing.T) { // There must be something in the cache to compare with storeVersion(t, "Step1", c, "1", true) - content := newContent("contentName", classEmpty, "sid1-1", "vuid1-1", "volume1-1", "snapuid1-1", "snap1-1", nil, nil, nil, false) + content := newContent("contentName", "sid1-1", "snapuid1-1", "snap1-1", nil, nil, nil, false) content.ResourceVersion = "xxx" _, err := storeObjectUpdate(c, content, "content") if err == nil { diff --git a/pkg/controller/snapshot_create_test.go b/pkg/controller/snapshot_create_test.go index 385cf79c7..0db489eeb 100644 --- a/pkg/controller/snapshot_create_test.go +++ b/pkg/controller/snapshot_create_test.go @@ -69,7 +69,7 @@ func TestCreateSnapshotSync(t *testing.T) { { name: "6-1 - successful create snapshot with snapshot class gold", initialContents: nocontents, - expectedContents: newContentArray("snapcontent-snapuid6-1", classGold, "sid6-1", "pv-uid6-1", "volume6-1", "snapuid6-1", "snap6-1", &deletePolicy, &defaultSize, &timeNowStamp, false), + expectedContents: newContentArray("snapcontent-snapuid6-1", "sid6-1", "snapuid6-1", "snap6-1", &deletePolicy, &defaultSize, &timeNowStamp, false), initialSnapshots: newSnapshotArray("snap6-1", classGold, "", "snapuid6-1", "claim6-1", false, nil, nil, nil), expectedSnapshots: newSnapshotArray("snap6-1", classGold, "snapcontent-snapuid6-1", "snapuid6-1", "claim6-1", false, nil, metaTimeNowUnix, getSize(defaultSize)), initialClaims: newClaimArray("claim6-1", "pvc-uid6-1", "1Gi", "volume6-1", v1.ClaimBound, &classEmpty), @@ -93,7 +93,7 @@ func TestCreateSnapshotSync(t *testing.T) { { name: "6-2 - successful create snapshot with snapshot class silver", initialContents: nocontents, - expectedContents: newContentArray("snapcontent-snapuid6-2", classSilver, "sid6-2", "pv-uid6-2", "volume6-2", "snapuid6-2", "snap6-2", &deletePolicy, &defaultSize, &timeNowStamp, false), + expectedContents: newContentArray("snapcontent-snapuid6-2", "sid6-2", "snapuid6-2", "snap6-2", &deletePolicy, &defaultSize, &timeNowStamp, false), initialSnapshots: newSnapshotArray("snap6-2", classSilver, "", "snapuid6-2", "claim6-2", false, nil, nil, nil), expectedSnapshots: newSnapshotArray("snap6-2", classSilver, "snapcontent-snapuid6-2", "snapuid6-2", "claim6-2", false, nil, metaTimeNowUnix, getSize(defaultSize)), initialClaims: newClaimArray("claim6-2", "pvc-uid6-2", "1Gi", "volume6-2", v1.ClaimBound, &classEmpty), @@ -117,7 +117,7 @@ func TestCreateSnapshotSync(t *testing.T) { { name: "6-3 - successful create snapshot with snapshot class valid-secret-class", initialContents: nocontents, - expectedContents: newContentArray("snapcontent-snapuid6-3", validSecretClass, "sid6-3", "pv-uid6-3", "volume6-3", "snapuid6-3", "snap6-3", &deletePolicy, &defaultSize, &timeNowStamp, false), + expectedContents: newContentArray("snapcontent-snapuid6-3", "sid6-3", "snapuid6-3", "snap6-3", &deletePolicy, &defaultSize, &timeNowStamp, false), initialSnapshots: newSnapshotArray("snap6-3", validSecretClass, "", "snapuid6-3", "claim6-3", false, nil, nil, nil), expectedSnapshots: newSnapshotArray("snap6-3", validSecretClass, "snapcontent-snapuid6-3", "snapuid6-3", "claim6-3", false, nil, metaTimeNowUnix, getSize(defaultSize)), initialClaims: newClaimArray("claim6-3", "pvc-uid6-3", "1Gi", "volume6-3", v1.ClaimBound, &classEmpty), @@ -143,7 +143,7 @@ func TestCreateSnapshotSync(t *testing.T) { { name: "6-4 - successful create snapshot with snapshot class empty-secret-class", initialContents: nocontents, - expectedContents: newContentArray("snapcontent-snapuid6-4", emptySecretClass, "sid6-4", "pv-uid6-4", "volume6-4", "snapuid6-4", "snap6-4", &deletePolicy, &defaultSize, &timeNowStamp, false), + expectedContents: newContentArray("snapcontent-snapuid6-4", "sid6-4", "snapuid6-4", "snap6-4", &deletePolicy, &defaultSize, &timeNowStamp, false), initialSnapshots: newSnapshotArray("snap6-4", emptySecretClass, "", "snapuid6-4", "claim6-4", false, nil, nil, nil), expectedSnapshots: newSnapshotArray("snap6-4", emptySecretClass, "snapcontent-snapuid6-4", "snapuid6-4", "claim6-4", false, nil, metaTimeNowUnix, getSize(defaultSize)), initialClaims: newClaimArray("claim6-4", "pvc-uid6-4", "1Gi", "volume6-4", v1.ClaimBound, &classEmpty), @@ -169,7 +169,7 @@ func TestCreateSnapshotSync(t *testing.T) { { name: "6-5 - successful create snapshot with status uploading", initialContents: nocontents, - expectedContents: newContentArray("snapcontent-snapuid6-5", classGold, "sid6-5", "pv-uid6-5", "volume6-5", "snapuid6-5", "snap6-5", &deletePolicy, &defaultSize, &timeNowStamp, false), + expectedContents: newContentArray("snapcontent-snapuid6-5", "sid6-5", "snapuid6-5", "snap6-5", &deletePolicy, &defaultSize, &timeNowStamp, false), initialSnapshots: newSnapshotArray("snap6-5", classGold, "", "snapuid6-5", "claim6-5", false, nil, nil, nil), expectedSnapshots: newSnapshotArray("snap6-5", classGold, "snapcontent-snapuid6-5", "snapuid6-5", "claim6-5", false, nil, metaTimeNowUnix, getSize(defaultSize)), initialClaims: newClaimArray("claim6-5", "pvc-uid6-5", "1Gi", "volume6-5", v1.ClaimBound, &classEmpty), @@ -193,7 +193,7 @@ func TestCreateSnapshotSync(t *testing.T) { { name: "6-6 - successful create snapshot with status error uploading", initialContents: nocontents, - expectedContents: newContentArray("snapcontent-snapuid6-6", classGold, "sid6-6", "pv-uid6-6", "volume6-6", "snapuid6-6", "snap6-6", &deletePolicy, &defaultSize, &timeNowStamp, false), + expectedContents: newContentArray("snapcontent-snapuid6-6", "sid6-6", "snapuid6-6", "snap6-6", &deletePolicy, &defaultSize, &timeNowStamp, false), initialSnapshots: newSnapshotArray("snap6-6", classGold, "", "snapuid6-6", "claim6-6", false, nil, nil, nil), expectedSnapshots: newSnapshotArray("snap6-6", classGold, "snapcontent-snapuid6-6", "snapuid6-6", "claim6-6", false, nil, metaTimeNowUnix, getSize(defaultSize)), initialClaims: newClaimArray("claim6-6", "pvc-uid6-6", "1Gi", "volume6-6", v1.ClaimBound, &classEmpty), diff --git a/pkg/controller/snapshot_delete_test.go b/pkg/controller/snapshot_delete_test.go index 1f5878ee0..2a7990072 100644 --- a/pkg/controller/snapshot_delete_test.go +++ b/pkg/controller/snapshot_delete_test.go @@ -56,8 +56,8 @@ var snapshotClasses = []*crdv1.VolumeSnapshotClass{ ObjectMeta: metav1.ObjectMeta{ Name: classGold, }, - Snapshotter: mockDriverName, - Parameters: class1Parameters, + Driver: mockDriverName, + Parameters: class1Parameters, }, { TypeMeta: metav1.TypeMeta{ @@ -66,8 +66,8 @@ var snapshotClasses = []*crdv1.VolumeSnapshotClass{ ObjectMeta: metav1.ObjectMeta{ Name: classSilver, }, - Snapshotter: mockDriverName, - Parameters: class2Parameters, + Driver: mockDriverName, + Parameters: class2Parameters, }, { TypeMeta: metav1.TypeMeta{ @@ -76,8 +76,8 @@ var snapshotClasses = []*crdv1.VolumeSnapshotClass{ ObjectMeta: metav1.ObjectMeta{ Name: emptySecretClass, }, - Snapshotter: mockDriverName, - Parameters: class4Parameters, + Driver: mockDriverName, + Parameters: class4Parameters, }, { TypeMeta: metav1.TypeMeta{ @@ -86,8 +86,8 @@ var snapshotClasses = []*crdv1.VolumeSnapshotClass{ ObjectMeta: metav1.ObjectMeta{ Name: invalidSecretClass, }, - Snapshotter: mockDriverName, - Parameters: class3Parameters, + Driver: mockDriverName, + Parameters: class3Parameters, }, { TypeMeta: metav1.TypeMeta{ @@ -96,8 +96,8 @@ var snapshotClasses = []*crdv1.VolumeSnapshotClass{ ObjectMeta: metav1.ObjectMeta{ Name: validSecretClass, }, - Snapshotter: mockDriverName, - Parameters: class5Parameters, + Driver: mockDriverName, + Parameters: class5Parameters, }, { TypeMeta: metav1.TypeMeta{ @@ -107,7 +107,7 @@ var snapshotClasses = []*crdv1.VolumeSnapshotClass{ Name: defaultClass, Annotations: map[string]string{IsDefaultSnapshotClassAnnotation: "true"}, }, - Snapshotter: mockDriverName, + Driver: mockDriverName, }, } @@ -119,7 +119,7 @@ func TestDeleteSync(t *testing.T) { tests := []controllerTest{ { name: "1-1 - content with empty snapshot class is deleted if it is bound to a non-exist snapshot and also has a snapshot uid specified", - initialContents: newContentArray("content1-1", classEmpty, "sid1-1", "vuid1-1", "volume1-1", "snapuid1-1", "snap1-1", &deletePolicy, nil, nil, true), + initialContents: newContentArray("content1-1", "sid1-1", "snapuid1-1", "snap1-1", &deletePolicy, nil, nil, true), expectedContents: nocontents, initialSnapshots: nosnapshots, expectedSnapshots: nosnapshots, @@ -130,8 +130,8 @@ func TestDeleteSync(t *testing.T) { }, { name: "2-1 - content with empty snapshot class will not be deleted if it is bound to a non-exist snapshot but it does not have a snapshot uid specified", - initialContents: newContentArray("content2-1", classEmpty, "sid2-1", "vuid2-1", "volume2-1", "", "snap2-1", &deletePolicy, nil, nil, true), - expectedContents: newContentArray("content2-1", classEmpty, "sid2-1", "vuid2-1", "volume2-1", "", "snap2-1", &deletePolicy, nil, nil, true), + initialContents: newContentArray("content2-1", "sid2-1", "", "snap2-1", &deletePolicy, nil, nil, true), + expectedContents: newContentArray("content2-1", "sid2-1", "", "snap2-1", &deletePolicy, nil, nil, true), initialSnapshots: nosnapshots, expectedSnapshots: nosnapshots, expectedEvents: noevents, @@ -141,7 +141,7 @@ func TestDeleteSync(t *testing.T) { }, { name: "1-2 - successful delete with snapshot class that has empty secret parameter", - initialContents: newContentArray("content1-2", emptySecretClass, "sid1-2", "vuid1-2", "volume1-2", "snapuid1-2", "snap1-2", &deletePolicy, nil, nil, true), + initialContents: newContentArray("content1-2", "sid1-2", "snapuid1-2", "snap1-2", &deletePolicy, nil, nil, true), expectedContents: nocontents, initialSnapshots: nosnapshots, expectedSnapshots: nosnapshots, @@ -153,7 +153,7 @@ func TestDeleteSync(t *testing.T) { }, { name: "1-3 - successful delete with snapshot class that has valid secret parameter", - initialContents: newContentArray("content1-3", validSecretClass, "sid1-3", "vuid1-3", "volume1-3", "snapuid1-3", "snap1-3", &deletePolicy, nil, nil, true), + initialContents: newContentArray("content1-3", "sid1-3", "snapuid1-3", "snap1-3", &deletePolicy, nil, nil, true), expectedContents: nocontents, initialSnapshots: nosnapshots, expectedSnapshots: nosnapshots, @@ -163,20 +163,20 @@ func TestDeleteSync(t *testing.T) { expectedDeleteCalls: []deleteCall{{"sid1-3", map[string]string{"foo": "bar"}, nil}}, test: testSyncContent, }, - { + /*{ name: "1-4 - fail delete with snapshot class that has invalid secret parameter", - initialContents: newContentArray("content1-4", invalidSecretClass, "sid1-4", "vuid1-4", "volume1-4", "snapuid1-4", "snap1-4", &deletePolicy, nil, nil, true), - expectedContents: newContentArray("content1-4", invalidSecretClass, "sid1-4", "vuid1-4", "volume1-4", "snapuid1-4", "snap1-4", &deletePolicy, nil, nil, true), + initialContents: newContentArray("content1-4", "sid1-4", "snapuid1-4", "snap1-4", &deletePolicy, nil, nil, true), + expectedContents: newContentArray("content1-4", "sid1-4", "snapuid1-4", "snap1-4", &deletePolicy, nil, nil, true), initialSnapshots: nosnapshots, expectedSnapshots: nosnapshots, expectedEvents: noevents, errors: noerrors, test: testSyncContent, - }, + },*/ { name: "1-5 - csi driver delete snapshot returns error", - initialContents: newContentArray("content1-5", validSecretClass, "sid1-5", "vuid1-5", "volume1-5", "snapuid1-5", "snap1-5", &deletePolicy, nil, nil, true), - expectedContents: newContentArray("content1-5", validSecretClass, "sid1-5", "vuid1-5", "volume1-5", "snapuid1-5", "snap1-5", &deletePolicy, nil, nil, true), + initialContents: newContentArray("content1-5", "sid1-5", "snapuid1-5", "snap1-5", &deletePolicy, nil, nil, true), + expectedContents: newContentArray("content1-5", "sid1-5", "snapuid1-5", "snap1-5", &deletePolicy, nil, nil, true), initialSnapshots: nosnapshots, expectedSnapshots: nosnapshots, initialSecrets: []*v1.Secret{secret()}, @@ -187,8 +187,8 @@ func TestDeleteSync(t *testing.T) { }, { name: "1-6 - api server delete content returns error", - initialContents: newContentArray("content1-6", validSecretClass, "sid1-6", "vuid1-6", "volume1-6", "snapuid1-6", "snap1-6", &deletePolicy, nil, nil, true), - expectedContents: newContentArray("content1-6", validSecretClass, "sid1-6", "vuid1-6", "volume1-6", "snapuid1-6", "snap1-6", &deletePolicy, nil, nil, true), + initialContents: newContentArray("content1-6", "sid1-6", "snapuid1-6", "snap1-6", &deletePolicy, nil, nil, true), + expectedContents: newContentArray("content1-6", "sid1-6", "snapuid1-6", "snap1-6", &deletePolicy, nil, nil, true), initialSnapshots: nosnapshots, expectedSnapshots: nosnapshots, initialSecrets: []*v1.Secret{secret()}, @@ -205,7 +205,7 @@ func TestDeleteSync(t *testing.T) { // delete success - snapshot that the content was pointing to was deleted, and another // with the same name created. name: "1-7 - prebound content is deleted while the snapshot exists", - initialContents: newContentArray("content1-7", validSecretClass, "sid1-7", "vuid1-7", "volume1-7", "snapuid1-7", "snap1-7", &deletePolicy, nil, nil, true), + initialContents: newContentArray("content1-7", "sid1-7", "snapuid1-7", "snap1-7", &deletePolicy, nil, nil, true), expectedContents: nocontents, initialSnapshots: newSnapshotArray("snap1-7", validSecretClass, "content1-7", "snapuid1-7-x", "claim1-7", false, nil, nil, nil), expectedSnapshots: newSnapshotArray("snap1-7", validSecretClass, "content1-7", "snapuid1-7-x", "claim1-7", false, nil, nil, nil), @@ -218,7 +218,7 @@ func TestDeleteSync(t *testing.T) { { // delete success(?) - content is deleted before doDelete() starts name: "1-8 - content is deleted before deleting", - initialContents: newContentArray("content1-8", validSecretClass, "sid1-8", "vuid1-8", "volume1-8", "snapuid1-8", "snap1-8", &deletePolicy, nil, nil, true), + initialContents: newContentArray("content1-8", "sid1-8", "snapuid1-8", "snap1-8", &deletePolicy, nil, nil, true), expectedContents: nocontents, initialSnapshots: nosnapshots, expectedSnapshots: nosnapshots, @@ -235,8 +235,8 @@ func TestDeleteSync(t *testing.T) { }, { name: "1-9 - content will not be deleted if it is bound to a snapshot correctly, snapshot uid is specified", - initialContents: newContentArray("content1-9", validSecretClass, "sid1-9", "vuid1-9", "volume1-9", "snapuid1-9", "snap1-9", &deletePolicy, nil, nil, true), - expectedContents: newContentArray("content1-9", validSecretClass, "sid1-9", "vuid1-9", "volume1-9", "snapuid1-9", "snap1-9", &deletePolicy, nil, nil, true), + initialContents: newContentArray("content1-9", "sid1-9", "snapuid1-9", "snap1-9", &deletePolicy, nil, nil, true), + expectedContents: newContentArray("content1-9", "sid1-9", "snapuid1-9", "snap1-9", &deletePolicy, nil, nil, true), initialSnapshots: newSnapshotArray("snap1-9", validSecretClass, "content1-9", "snapuid1-9", "claim1-9", false, nil, nil, nil), expectedSnapshots: newSnapshotArray("snap1-9", validSecretClass, "content1-9", "snapuid1-9", "claim1-9", false, nil, nil, nil), expectedEvents: noevents, @@ -246,7 +246,7 @@ func TestDeleteSync(t *testing.T) { }, { name: "1-10 - should delete content which is bound to a snapshot incorrectly", - initialContents: newContentArray("content1-10", validSecretClass, "sid1-10", "vuid1-10", "volume1-10", "snapuid1-10-x", "snap1-10", &deletePolicy, nil, nil, true), + initialContents: newContentArray("content1-10", "sid1-10", "snapuid1-10-x", "snap1-10", &deletePolicy, nil, nil, true), expectedContents: nocontents, initialSnapshots: newSnapshotArray("snap1-10", validSecretClass, "content1-10", "snapuid1-10", "claim1-10", false, nil, nil, nil), expectedSnapshots: newSnapshotArray("snap1-10", validSecretClass, "content1-10", "snapuid1-10", "claim1-10", false, nil, nil, nil), @@ -258,8 +258,8 @@ func TestDeleteSync(t *testing.T) { }, { name: "1-10 - will not delete content with retain policy set which is bound to a snapshot incorrectly", - initialContents: newContentArray("content1-10", validSecretClass, "sid1-10", "vuid1-10", "volume1-10", "snapuid1-10-x", "snap1-10", &retainPolicy, nil, nil, true), - expectedContents: newContentArray("content1-10", validSecretClass, "sid1-10", "vuid1-10", "volume1-10", "snapuid1-10-x", "snap1-10", &retainPolicy, nil, nil, true), + initialContents: newContentArray("content1-10", "sid1-10", "snapuid1-10-x", "snap1-10", &retainPolicy, nil, nil, true), + expectedContents: newContentArray("content1-10", "sid1-10", "snapuid1-10-x", "snap1-10", &retainPolicy, nil, nil, true), initialSnapshots: newSnapshotArray("snap1-10", validSecretClass, "content1-10", "snapuid1-10", "claim1-10", false, nil, nil, nil), expectedSnapshots: newSnapshotArray("snap1-10", validSecretClass, "content1-10", "snapuid1-10", "claim1-10", false, nil, nil, nil), expectedEvents: noevents, @@ -269,8 +269,8 @@ func TestDeleteSync(t *testing.T) { }, { name: "1-11 - content will not be deleted if it is bound to a snapshot correctly, snapsht uid is not specified", - initialContents: newContentArray("content1-11", validSecretClass, "sid1-11", "vuid1-11", "volume1-11", "", "snap1-11", &deletePolicy, nil, nil, true), - expectedContents: newContentArray("content1-11", validSecretClass, "sid1-11", "vuid1-11", "volume1-11", "", "snap1-11", &deletePolicy, nil, nil, true), + initialContents: newContentArray("content1-11", "sid1-11", "", "snap1-11", &deletePolicy, nil, nil, true), + expectedContents: newContentArray("content1-11", "sid1-11", "", "snap1-11", &deletePolicy, nil, nil, true), initialSnapshots: newSnapshotArray("snap1-11", validSecretClass, "content1-11", "snapuid1-11", "claim1-11", false, nil, nil, nil), expectedSnapshots: newSnapshotArray("snap1-11", validSecretClass, "content1-11", "snapuid1-11", "claim1-11", false, nil, nil, nil), expectedEvents: noevents, @@ -280,8 +280,8 @@ func TestDeleteSync(t *testing.T) { }, { name: "1-12 - content with retain policy will not be deleted if it is bound to a non-exist snapshot and also has a snapshot uid specified", - initialContents: newContentArray("content1-12", classEmpty, "sid1-12", "vuid1-12", "volume1-12", "snapuid1-12", "snap1-12", &retainPolicy, nil, nil, true), - expectedContents: newContentArray("content1-12", classEmpty, "sid1-12", "vuid1-12", "volume1-12", "snapuid1-12", "snap1-12", &retainPolicy, nil, nil, true), + initialContents: newContentArray("content1-12", "sid1-12", "snapuid1-12", "snap1-12", &retainPolicy, nil, nil, true), + expectedContents: newContentArray("content1-12", "sid1-12", "snapuid1-12", "snap1-12", &retainPolicy, nil, nil, true), initialSnapshots: nosnapshots, expectedSnapshots: nosnapshots, expectedEvents: noevents, @@ -290,8 +290,8 @@ func TestDeleteSync(t *testing.T) { }, { name: "1-13 - content with empty snapshot class is not deleted when Deletion policy is not set even if it is bound to a non-exist snapshot and also has a snapshot uid specified", - initialContents: newContentArray("content1-1", classEmpty, "sid1-1", "vuid1-1", "volume1-1", "snapuid1-1", "snap1-1", nil, nil, nil, true), - expectedContents: newContentArray("content1-1", classEmpty, "sid1-1", "vuid1-1", "volume1-1", "snapuid1-1", "snap1-1", nil, nil, nil, true), + initialContents: newContentArray("content1-1", "sid1-1", "snapuid1-1", "snap1-1", nil, nil, nil, true), + expectedContents: newContentArray("content1-1", "sid1-1", "snapuid1-1", "snap1-1", nil, nil, nil, true), initialSnapshots: nosnapshots, expectedSnapshots: nosnapshots, expectedEvents: noevents, @@ -300,8 +300,8 @@ func TestDeleteSync(t *testing.T) { }, { name: "1-14 - content will not be deleted if it is bound to a snapshot correctly, snapshot uid is specified", - initialContents: newContentArray("content1-14", validSecretClass, "sid1-14", "vuid1-14", "volume1-14", "snapuid1-14", "snap1-14", &retainPolicy, nil, nil, true), - expectedContents: newContentArray("content1-14", validSecretClass, "sid1-14", "vuid1-14", "volume1-14", "snapuid1-14", "snap1-14", &retainPolicy, nil, nil, true), + initialContents: newContentArray("content1-14", "sid1-14", "snapuid1-14", "snap1-14", &retainPolicy, nil, nil, true), + expectedContents: newContentArray("content1-14", "sid1-14", "snapuid1-14", "snap1-14", &retainPolicy, nil, nil, true), initialSnapshots: newSnapshotArray("snap1-14", validSecretClass, "content1-14", "snapuid1-14", "claim1-14", false, nil, nil, nil), expectedSnapshots: newSnapshotArray("snap1-14", validSecretClass, "content1-14", "snapuid1-14", "claim1-14", false, nil, nil, nil), expectedEvents: noevents, @@ -311,8 +311,8 @@ func TestDeleteSync(t *testing.T) { }, { name: "1-15 - content will not be deleted which is bound to a snapshot incorrectly if Deletion policy is not set", - initialContents: newContentArray("content1-10", validSecretClass, "sid1-15", "vuid1-15", "volume1-15", "snapuid1-15-x", "snap1-15", nil, nil, nil, true), - expectedContents: newContentArray("content1-10", validSecretClass, "sid1-15", "vuid1-15", "volume1-15", "snapuid1-15-x", "snap1-15", nil, nil, nil, true), + initialContents: newContentArray("content1-10", "sid1-15", "snapuid1-15-x", "snap1-15", nil, nil, nil, true), + expectedContents: newContentArray("content1-10", "sid1-15", "snapuid1-15-x", "snap1-15", nil, nil, nil, true), initialSnapshots: newSnapshotArray("snap1-10", validSecretClass, "content1-15", "snapuid1-15", "claim1-15", false, nil, nil, nil), expectedSnapshots: newSnapshotArray("snap1-10", validSecretClass, "content1-15", "snapuid1-15", "claim1-15", false, nil, nil, nil), expectedEvents: noevents, diff --git a/pkg/controller/snapshot_ready_test.go b/pkg/controller/snapshot_ready_test.go index 01223e8e0..339e13810 100644 --- a/pkg/controller/snapshot_ready_test.go +++ b/pkg/controller/snapshot_ready_test.go @@ -55,8 +55,8 @@ func TestSync(t *testing.T) { }, { name: "2-2 - could not bind snapshot and content, the VolumeSnapshotRef does not match", - initialContents: newContentArray("content2-2", validSecretClass, "sid2-2", "vuid2-2", "volume2-2", "snapuid2-2-x", "snap2-2", &deletePolicy, nil, nil, false), - expectedContents: newContentArray("content2-2", validSecretClass, "sid2-2", "vuid2-2", "volume2-2", "snapuid2-2-x", "snap2-2", &deletePolicy, nil, nil, false), + initialContents: newContentArray("content2-2", "sid2-2", "snapuid2-2-x", "snap2-2", &deletePolicy, nil, nil, false), + expectedContents: newContentArray("content2-2", "sid2-2", "snapuid2-2-x", "snap2-2", &deletePolicy, nil, nil, false), initialSnapshots: newSnapshotArray("snap2-2", validSecretClass, "content2-2", "snapuid2-2", "claim2-2", false, nil, nil, nil), expectedSnapshots: newSnapshotArray("snap2-2", validSecretClass, "content2-2", "snapuid2-2", "claim2-2", false, newVolumeError("Snapshot failed to bind VolumeSnapshotContent, Could not bind snapshot snap2-2 and content content2-2, the VolumeSnapshotRef does not match"), nil, nil), expectedEvents: []string{"Warning SnapshotBindFailed"}, @@ -65,8 +65,8 @@ func TestSync(t *testing.T) { }, { name: "2-3 - success bind snapshot and content but not ready, no status changed", - initialContents: newContentArray("content2-3", validSecretClass, "sid2-3", "vuid2-3", "volume2-3", "", "snap2-3", &deletePolicy, nil, nil, false), - expectedContents: newContentArray("content2-3", validSecretClass, "sid2-3", "vuid2-3", "volume2-3", "snapuid2-3", "snap2-3", &deletePolicy, nil, nil, false), + initialContents: newContentArray("content2-3", "sid2-3", "", "snap2-3", &deletePolicy, nil, nil, false), + expectedContents: newContentArray("content2-3", "sid2-3", "snapuid2-3", "snap2-3", &deletePolicy, nil, nil, false), initialSnapshots: newSnapshotArray("snap2-3", validSecretClass, "content2-3", "snapuid2-3", "claim2-3", false, nil, metaTimeNow, nil), expectedSnapshots: newSnapshotArray("snap2-3", validSecretClass, "content2-3", "snapuid2-3", "claim2-3", false, nil, metaTimeNow, nil), initialClaims: newClaimArray("claim2-3", "pvc-uid2-3", "1Gi", "volume2-3", v1.ClaimBound, &classEmpty), @@ -91,8 +91,8 @@ func TestSync(t *testing.T) { { // nothing changed name: "2-4 - noop", - initialContents: newContentArray("content2-4", validSecretClass, "sid2-4", "vuid2-4", "volume2-4", "snapuid2-4", "snap2-4", &deletePolicy, nil, nil, false), - expectedContents: newContentArray("content2-4", validSecretClass, "sid2-4", "vuid2-4", "volume2-4", "snapuid2-4", "snap2-4", &deletePolicy, nil, nil, false), + initialContents: newContentArray("content2-4", "sid2-4", "snapuid2-4", "snap2-4", &deletePolicy, nil, nil, false), + expectedContents: newContentArray("content2-4", "sid2-4", "snapuid2-4", "snap2-4", &deletePolicy, nil, nil, false), initialSnapshots: newSnapshotArray("snap2-4", validSecretClass, "content2-4", "snapuid2-4", "claim2-4", true, nil, metaTimeNow, nil), expectedSnapshots: newSnapshotArray("snap2-4", validSecretClass, "content2-4", "snapuid2-4", "claim2-4", true, nil, metaTimeNow, nil), errors: noerrors, @@ -100,8 +100,8 @@ func TestSync(t *testing.T) { }, { name: "2-5 - snapshot and content bound, status ready false -> true", - initialContents: newContentArray("content2-5", validSecretClass, "sid2-5", "vuid2-5", "volume2-5", "snapuid2-5", "snap2-5", &deletePolicy, nil, nil, false), - expectedContents: newContentArray("content2-5", validSecretClass, "sid2-5", "vuid2-5", "volume2-5", "snapuid2-5", "snap2-5", &deletePolicy, nil, nil, false), + initialContents: newContentArray("content2-5", "sid2-5", "snapuid2-5", "snap2-5", &deletePolicy, nil, nil, false), + expectedContents: newContentArray("content2-5", "sid2-5", "snapuid2-5", "snap2-5", &deletePolicy, nil, nil, false), initialSnapshots: newSnapshotArray("snap2-5", validSecretClass, "content2-5", "snapuid2-5", "claim2-5", false, nil, metaTimeNow, nil), expectedSnapshots: newSnapshotArray("snap2-5", validSecretClass, "content2-5", "snapuid2-5", "claim2-5", true, nil, metaTimeNow, nil), initialClaims: newClaimArray("claim2-5", "pvc-uid2-5", "1Gi", "volume2-5", v1.ClaimBound, &classEmpty), @@ -125,8 +125,8 @@ func TestSync(t *testing.T) { }, { name: "2-6 - snapshot bound to prebound content correctly, status ready false -> true, ref.UID '' -> 'snapuid2-6'", - initialContents: newContentArray("content2-6", validSecretClass, "sid2-6", noVolume, noVolume, noBoundUID, "snap2-6", &deletePolicy, nil, &timeNowStamp, false), - expectedContents: newContentArray("content2-6", validSecretClass, "sid2-6", noVolume, noVolume, "snapuid2-6", "snap2-6", &deletePolicy, nil, &timeNowStamp, false), + initialContents: newContentArray("content2-6", "sid2-6", noBoundUID, "snap2-6", &deletePolicy, nil, &timeNowStamp, false), + expectedContents: newContentArray("content2-6", "sid2-6", "snapuid2-6", "snap2-6", &deletePolicy, nil, &timeNowStamp, false), initialSnapshots: newSnapshotArray("snap2-6", validSecretClass, "content2-6", "snapuid2-6", noClaim, false, nil, metaTimeNow, nil), expectedSnapshots: newSnapshotArray("snap2-6", validSecretClass, "content2-6", "snapuid2-6", noClaim, true, nil, metaTimeNow, nil), expectedListCalls: []listCall{ @@ -140,8 +140,8 @@ func TestSync(t *testing.T) { }, { name: "2-7 - snapshot and content bound, csi driver get status error", - initialContents: newContentArray("content2-7", validSecretClass, "sid2-7", "vuid2-7", "volume2-7", "snapuid2-7", "snap2-7", &deletePolicy, nil, nil, false), - expectedContents: newContentArray("content2-7", validSecretClass, "sid2-7", "vuid2-7", "volume2-7", "snapuid2-7", "snap2-7", &deletePolicy, nil, nil, false), + initialContents: newContentArray("content2-7", "sid2-7", "snapuid2-7", "snap2-7", &deletePolicy, nil, nil, false), + expectedContents: newContentArray("content2-7", "sid2-7", "snapuid2-7", "snap2-7", &deletePolicy, nil, nil, false), initialSnapshots: newSnapshotArray("snap2-7", validSecretClass, "content2-7", "snapuid2-7", "claim2-7", false, nil, metaTimeNow, nil), expectedSnapshots: newSnapshotArray("snap2-7", validSecretClass, "content2-7", "snapuid2-7", "claim2-7", false, newVolumeError("Failed to check and update snapshot: mock create snapshot error"), metaTimeNow, nil), expectedEvents: []string{"Warning SnapshotCheckandUpdateFailed"}, @@ -163,8 +163,8 @@ func TestSync(t *testing.T) { }, { name: "2-8 - snapshot and content bound, apiserver update status error", - initialContents: newContentArray("content2-8", validSecretClass, "sid2-8", "vuid2-8", "volume2-8", "snapuid2-8", "snap2-8", &deletePolicy, nil, nil, false), - expectedContents: newContentArray("content2-8", validSecretClass, "sid2-8", "vuid2-8", "volume2-8", "snapuid2-8", "snap2-8", &deletePolicy, nil, nil, false), + initialContents: newContentArray("content2-8", "sid2-8", "snapuid2-8", "snap2-8", &deletePolicy, nil, nil, false), + expectedContents: newContentArray("content2-8", "sid2-8", "snapuid2-8", "snap2-8", &deletePolicy, nil, nil, false), initialSnapshots: newSnapshotArray("snap2-8", validSecretClass, "content2-8", "snapuid2-8", "claim2-8", false, nil, metaTimeNow, nil), expectedSnapshots: newSnapshotArray("snap2-8", validSecretClass, "content2-8", "snapuid2-8", "claim2-8", false, newVolumeError("Failed to check and update snapshot: snapshot controller failed to update default/snap2-8 on API server: mock update error"), metaTimeNow, nil), expectedEvents: []string{"Warning SnapshotCheckandUpdateFailed"}, @@ -194,8 +194,8 @@ func TestSync(t *testing.T) { }, { name: "2-9 - bind when snapshot and content matches", - initialContents: newContentArray("content2-9", validSecretClass, "sid2-9", "vuid2-9", "volume2-9", "snapuid2-9", "snap2-9", &deletePolicy, nil, nil, false), - expectedContents: newContentArray("content2-9", validSecretClass, "sid2-9", "vuid2-9", "volume2-9", "snapuid2-9", "snap2-9", &deletePolicy, nil, nil, false), + initialContents: newContentArray("content2-9", "sid2-9", "snapuid2-9", "snap2-9", &deletePolicy, nil, nil, false), + expectedContents: newContentArray("content2-9", "sid2-9", "snapuid2-9", "snap2-9", &deletePolicy, nil, nil, false), initialSnapshots: newSnapshotArray("snap2-9", validSecretClass, "", "snapuid2-9", "claim2-9", false, nil, nil, nil), expectedSnapshots: newSnapshotArray("snap2-9", validSecretClass, "content2-9", "snapuid2-9", "claim2-9", false, nil, nil, nil), errors: noerrors, @@ -203,8 +203,8 @@ func TestSync(t *testing.T) { }, { name: "2-10 - do not bind when snapshot and content not match", - initialContents: newContentArray("content2-10", validSecretClass, "sid2-10", "vuid2-10", "volume2-10", "snapuid2-10-x", "snap2-10", &deletePolicy, nil, nil, false), - expectedContents: newContentArray("content2-10", validSecretClass, "sid2-10", "vuid2-10", "volume2-10", "snapuid2-10-x", "snap2-10", &deletePolicy, nil, nil, false), + initialContents: newContentArray("content2-10", "sid2-10", "snapuid2-10-x", "snap2-10", &deletePolicy, nil, nil, false), + expectedContents: newContentArray("content2-10", "sid2-10", "snapuid2-10-x", "snap2-10", &deletePolicy, nil, nil, false), initialSnapshots: newSnapshotArray("snap2-10", validSecretClass, "", "snapuid2-10", "claim2-10", false, newVolumeError("mock driver error"), nil, nil), expectedSnapshots: newSnapshotArray("snap2-10", validSecretClass, "", "snapuid2-10", "claim2-10", false, newVolumeError("mock driver error"), nil, nil), errors: noerrors, @@ -232,8 +232,8 @@ func TestSync(t *testing.T) { }, { name: "3-3 - ready snapshot(everything is well, do nothing)", - initialContents: newContentArray("content3-3", validSecretClass, "sid3-3", "vuid3-3", "volume3-3", "snapuid3-3", "snap3-3", &deletePolicy, nil, nil, false), - expectedContents: newContentArray("content3-3", validSecretClass, "sid3-3", "vuid3-3", "volume3-3", "snapuid3-3", "snap3-3", &deletePolicy, nil, nil, false), + initialContents: newContentArray("content3-3", "sid3-3", "snapuid3-3", "snap3-3", &deletePolicy, nil, nil, false), + expectedContents: newContentArray("content3-3", "sid3-3", "snapuid3-3", "snap3-3", &deletePolicy, nil, nil, false), initialSnapshots: newSnapshotArray("snap3-3", validSecretClass, "content3-3", "snapuid3-3", "claim3-3", true, nil, metaTimeNow, nil), expectedSnapshots: newSnapshotArray("snap3-3", validSecretClass, "content3-3", "snapuid3-3", "claim3-3", true, nil, metaTimeNow, nil), errors: noerrors, @@ -241,8 +241,8 @@ func TestSync(t *testing.T) { }, { name: "3-4 - ready snapshot misbound to VolumeSnapshotContent", - initialContents: newContentArray("content3-4", validSecretClass, "sid3-4", "vuid3-4", "volume3-4", "snapuid3-4-x", "snap3-4", &deletePolicy, nil, nil, false), - expectedContents: newContentArray("content3-4", validSecretClass, "sid3-4", "vuid3-4", "volume3-4", "snapuid3-4-x", "snap3-4", &deletePolicy, nil, nil, false), + initialContents: newContentArray("content3-4", "sid3-4", "snapuid3-4-x", "snap3-4", &deletePolicy, nil, nil, false), + expectedContents: newContentArray("content3-4", "sid3-4", "snapuid3-4-x", "snap3-4", &deletePolicy, nil, nil, false), initialSnapshots: newSnapshotArray("snap3-4", validSecretClass, "content3-4", "snapuid3-4", "claim3-4", true, nil, metaTimeNow, nil), expectedSnapshots: newSnapshotArray("snap3-4", validSecretClass, "content3-4", "snapuid3-4", "claim3-4", false, newVolumeError("VolumeSnapshotContent is not bound to the VolumeSnapshot correctly"), metaTimeNow, nil), errors: noerrors, @@ -250,7 +250,7 @@ func TestSync(t *testing.T) { }, { name: "3-5 - snapshot bound to content in which the driver does not match", - initialContents: newContentWithUnmatchDriverArray("content3-5", validSecretClass, "sid3-5", "vuid3-5", "volume3-5", "", "snap3-5", &deletePolicy, nil, nil), + initialContents: newContentWithUnmatchDriverArray("content3-5", "sid3-5", "", "snap3-5", &deletePolicy, nil, nil), expectedContents: nocontents, initialSnapshots: newSnapshotArray("snap3-5", validSecretClass, "content3-5", "snapuid3-5", "claim3-5", false, nil, nil, nil), expectedSnapshots: newSnapshotArray("snap3-5", validSecretClass, "content3-5", "snapuid3-5", "claim3-5", false, newVolumeError("VolumeSnapshotContent is missing"), nil, nil), @@ -260,8 +260,8 @@ func TestSync(t *testing.T) { }, { name: "3-6 - snapshot bound to content in which the snapshot uid does not match", - initialContents: newContentArray("content3-4", validSecretClass, "sid3-4", "vuid3-4", "volume3-4", "snapuid3-4-x", "snap3-6", &deletePolicy, nil, nil, false), - expectedContents: newContentArray("content3-4", validSecretClass, "sid3-4", "vuid3-4", "volume3-4", "snapuid3-4-x", "snap3-6", &deletePolicy, nil, nil, false), + initialContents: newContentArray("content3-4", "sid3-4", "snapuid3-4-x", "snap3-6", &deletePolicy, nil, nil, false), + expectedContents: newContentArray("content3-4", "sid3-4", "snapuid3-4-x", "snap3-6", &deletePolicy, nil, nil, false), initialSnapshots: newSnapshotArray("snap3-5", validSecretClass, "content3-5", "snapuid3-5", "claim3-5", false, nil, nil, nil), expectedSnapshots: newSnapshotArray("snap3-5", validSecretClass, "content3-5", "snapuid3-5", "claim3-5", false, newVolumeError("VolumeSnapshotContent is missing"), nil, nil), expectedEvents: []string{"Warning SnapshotContentMissing"}, diff --git a/pkg/controller/util.go b/pkg/controller/util.go index 22e491b25..0ce1223dc 100644 --- a/pkg/controller/util.go +++ b/pkg/controller/util.go @@ -147,8 +147,8 @@ func storeObjectUpdate(store cache.Store, obj interface{}, className string) (bo func GetSnapshotContentNameForSnapshot(snapshot *crdv1.VolumeSnapshot) string { // If VolumeSnapshot object has SnapshotContentName, use it directly. // This might be the case for static provisioning. - if len(snapshot.Spec.SnapshotContentName) > 0 { - return snapshot.Spec.SnapshotContentName + if snapshot.Spec.VolumeSnapshotContentName != nil && len(*snapshot.Spec.VolumeSnapshotContentName) > 0 { + return *snapshot.Spec.VolumeSnapshotContentName } // Construct SnapshotContentName for dynamic provisioning. return "snapcontent-" + string(snapshot.UID) From 2d966dea73516d4423233c0a3517d03a6c068884 Mon Sep 17 00:00:00 2001 From: xiangqian Date: Wed, 28 Aug 2019 10:54:34 -0700 Subject: [PATCH 08/11] add local error type VolumeSnapshotError instead of using storage.VolumeError --- ...snapshot.storage.k8s.io_volumesnapshots.yaml | 8 ++++---- pkg/apis/volumesnapshot/v1beta1/types.go | 17 +++++++++++++++-- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml b/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml index ba77c98dd..0ea2d800d 100644 --- a/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml +++ b/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml @@ -94,12 +94,12 @@ spec: reported. properties: message: - description: String detailing the error encountered during snapshot - creation. This string may be logged, so it should not - contain sensitive information. + description: 'message is a string detailing the encountered error + during snapshot creation if specified. NOTE: message maybe logged, + thus it should not contain sensitive information.' type: string time: - description: Time the error was encountered. + description: time is the timestamp when the error was encountered. format: date-time type: string type: object diff --git a/pkg/apis/volumesnapshot/v1beta1/types.go b/pkg/apis/volumesnapshot/v1beta1/types.go index 91ed9aff8..2f6a3bb23 100644 --- a/pkg/apis/volumesnapshot/v1beta1/types.go +++ b/pkg/apis/volumesnapshot/v1beta1/types.go @@ -18,7 +18,6 @@ package v1beta1 import ( core_v1 "k8s.io/api/core/v1" - storage "k8s.io/api/storage/v1beta1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -127,7 +126,7 @@ type VolumeSnapshotStatus struct { // to decide whether they should continue on waiting for the snapshot to be created // based on the type of error reported. // +optional - Error *storage.VolumeError `json:"error,omitempty" protobuf:"bytes,4,opt,name=error,casttype=VolumeError"` + Error *VolumeSnapshotError `json:"error,omitempty" protobuf:"bytes,4,opt,name=error,casttype=VolumeSnapshotError"` } // +genclient @@ -282,3 +281,17 @@ const ( // The default policy is Retain if not specified. VolumeSnapshotContentRetain DeletionPolicy = "Retain" ) + +// VolumeSnapshotError describes an error encountered during snapshot creation. +type VolumeSnapshotError struct { + // time is the timestamp when the error was encountered. + // +optional + Time *metav1.Time `json:"time,omitempty" protobuf:"bytes,1,opt,name=time"` + + // message is a string detailing the encountered error during snapshot + // creation if specified. + // NOTE: message maybe logged, thus it should not contain sensitive + // information. + // +optional + Message *string `json:"message,omitempty" protobuf:"bytes,2,opt,name=message"` +} From 410d520baad765aeaa9c71b8e53dbbb2a9a288d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cxing-yang=E2=80=9D?= Date: Wed, 28 Aug 2019 11:42:11 -0700 Subject: [PATCH 09/11] Update controller and tests to use the new Error API change --- .../v1beta1/zz_generated.deepcopy.go | 28 +++++++++++++++++-- pkg/controller/framework_test.go | 17 ++++++----- pkg/controller/snapshot_controller.go | 19 ++++++------- 3 files changed, 43 insertions(+), 21 deletions(-) diff --git a/pkg/apis/volumesnapshot/v1beta1/zz_generated.deepcopy.go b/pkg/apis/volumesnapshot/v1beta1/zz_generated.deepcopy.go index ed1b850fd..0e8f2c43d 100644 --- a/pkg/apis/volumesnapshot/v1beta1/zz_generated.deepcopy.go +++ b/pkg/apis/volumesnapshot/v1beta1/zz_generated.deepcopy.go @@ -22,7 +22,6 @@ package v1beta1 import ( v1 "k8s.io/api/core/v1" - storagev1beta1 "k8s.io/api/storage/v1beta1" runtime "k8s.io/apimachinery/pkg/runtime" ) @@ -238,6 +237,31 @@ func (in *VolumeSnapshotContentSpec) DeepCopy() *VolumeSnapshotContentSpec { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VolumeSnapshotError) DeepCopyInto(out *VolumeSnapshotError) { + *out = *in + if in.Time != nil { + in, out := &in.Time, &out.Time + *out = (*in).DeepCopy() + } + if in.Message != nil { + in, out := &in.Message, &out.Message + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeSnapshotError. +func (in *VolumeSnapshotError) DeepCopy() *VolumeSnapshotError { + if in == nil { + return nil + } + out := new(VolumeSnapshotError) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *VolumeSnapshotList) DeepCopyInto(out *VolumeSnapshotList) { *out = *in @@ -342,7 +366,7 @@ func (in *VolumeSnapshotStatus) DeepCopyInto(out *VolumeSnapshotStatus) { } if in.Error != nil { in, out := &in.Error, &out.Error - *out = new(storagev1beta1.VolumeError) + *out = new(VolumeSnapshotError) (*in).DeepCopyInto(*out) } return diff --git a/pkg/controller/framework_test.go b/pkg/controller/framework_test.go index 6f17960c8..84125db89 100644 --- a/pkg/controller/framework_test.go +++ b/pkg/controller/framework_test.go @@ -37,7 +37,6 @@ import ( storagelisters "github.com/kubernetes-csi/external-snapshotter/pkg/client/listers/volumesnapshot/v1beta1" "k8s.io/api/core/v1" storagev1 "k8s.io/api/storage/v1" - storagev1beta1 "k8s.io/api/storage/v1beta1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" @@ -465,7 +464,7 @@ func (r *snapshotReactor) checkSnapshots(expectedSnapshots []*crdv1.VolumeSnapsh c = c.DeepCopy() c.ResourceVersion = "" if c.Status.Error != nil { - c.Status.Error.Time = metav1.Time{} + c.Status.Error.Time = &metav1.Time{} } expectedMap[c.Name] = c } @@ -475,7 +474,7 @@ func (r *snapshotReactor) checkSnapshots(expectedSnapshots []*crdv1.VolumeSnapsh c = c.DeepCopy() c.ResourceVersion = "" if c.Status.Error != nil { - c.Status.Error.Time = metav1.Time{} + c.Status.Error.Time = &metav1.Time{} } gotMap[c.Name] = c } @@ -832,7 +831,7 @@ func newContentWithUnmatchDriverArray(name, snapshotHandle, boundToSnapshotUID, } } -func newSnapshot(name, className, boundToContent, snapshotUID, claimName string, ready bool, err *storagev1beta1.VolumeError, creationTime *metav1.Time, size *resource.Quantity) *crdv1.VolumeSnapshot { +func newSnapshot(name, className, boundToContent, snapshotUID, claimName string, ready bool, err *crdv1.VolumeSnapshotError, creationTime *metav1.Time, size *resource.Quantity) *crdv1.VolumeSnapshot { snapshot := crdv1.VolumeSnapshot{ ObjectMeta: metav1.ObjectMeta{ Name: name, @@ -862,7 +861,7 @@ func newSnapshot(name, className, boundToContent, snapshotUID, claimName string, return withSnapshotFinalizer(&snapshot) } -func newSnapshotArray(name, className, boundToContent, snapshotUID, claimName string, ready bool, err *storagev1beta1.VolumeError, creationTime *metav1.Time, size *resource.Quantity) []*crdv1.VolumeSnapshot { +func newSnapshotArray(name, className, boundToContent, snapshotUID, claimName string, ready bool, err *crdv1.VolumeSnapshotError, creationTime *metav1.Time, size *resource.Quantity) []*crdv1.VolumeSnapshot { return []*crdv1.VolumeSnapshot{ newSnapshot(name, className, boundToContent, snapshotUID, claimName, ready, err, creationTime, size), } @@ -972,10 +971,10 @@ func newVolumeArray(name, volumeUID, volumeHandle, capacity, boundToClaimUID, bo } } -func newVolumeError(message string) *storagev1beta1.VolumeError { - return &storagev1beta1.VolumeError{ - Time: metav1.Time{}, - Message: message, +func newVolumeError(message string) *crdv1.VolumeSnapshotError { + return &crdv1.VolumeSnapshotError{ + Time: &metav1.Time{}, + Message: &message, } } diff --git a/pkg/controller/snapshot_controller.go b/pkg/controller/snapshot_controller.go index d2a107787..e27ce02e8 100644 --- a/pkg/controller/snapshot_controller.go +++ b/pkg/controller/snapshot_controller.go @@ -24,7 +24,6 @@ import ( crdv1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1beta1" "k8s.io/api/core/v1" storagev1 "k8s.io/api/storage/v1" - storage "k8s.io/api/storage/v1beta1" apierrs "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -408,16 +407,16 @@ func (ctrl *csiSnapshotController) checkandUpdateBoundSnapshotStatus(snapshot *c func (ctrl *csiSnapshotController) updateSnapshotErrorStatusWithEvent(snapshot *crdv1.VolumeSnapshot, eventtype, reason, message string) error { klog.V(5).Infof("updateSnapshotStatusWithEvent[%s]", snapshotKey(snapshot)) - if snapshot.Status.Error != nil && snapshot.Status.Error.Message == message { + if snapshot.Status.Error != nil && snapshot.Status.Error.Message != nil && *snapshot.Status.Error.Message == message { klog.V(4).Infof("updateSnapshotStatusWithEvent[%s]: the same error %v is already set", snapshot.Name, snapshot.Status.Error) return nil } snapshotClone := snapshot.DeepCopy() - statusError := &storage.VolumeError{ - Time: metav1.Time{ + statusError := &crdv1.VolumeSnapshotError{ + Time: &metav1.Time{ Time: time.Now(), }, - Message: message, + Message: &message, } snapshotClone.Status.Error = statusError ready := false @@ -611,8 +610,8 @@ func (ctrl *csiSnapshotController) checkandUpdateBoundSnapshotStatusOperation(sn func (ctrl *csiSnapshotController) createSnapshotOperation(snapshot *crdv1.VolumeSnapshot) (*crdv1.VolumeSnapshot, error) { klog.Infof("createSnapshot: Creating snapshot %s through the plugin ...", snapshotKey(snapshot)) - if snapshot.Status.Error != nil && !isControllerUpdateFailError(snapshot.Status.Error) { - klog.V(4).Infof("error is already set in snapshot, do not retry to create: %s", snapshot.Status.Error.Message) + if snapshot.Status.Error != nil && snapshot.Status.Error.Message != nil && !isControllerUpdateFailError(snapshot.Status.Error) { + klog.V(4).Infof("error is already set in snapshot, do not retry to create: %s", *snapshot.Status.Error.Message) return snapshot, nil } @@ -994,9 +993,9 @@ func (e controllerUpdateError) Error() string { return e.message } -func isControllerUpdateFailError(err *storage.VolumeError) bool { - if err != nil { - if strings.Contains(err.Message, controllerUpdateFailMsg) { +func isControllerUpdateFailError(err *crdv1.VolumeSnapshotError) bool { + if err != nil && err.Message != nil { + if strings.Contains(*err.Message, controllerUpdateFailMsg) { return true } } From df77c9a1578ed8120a914cb58d783eea4fd44130 Mon Sep 17 00:00:00 2001 From: xiangqian Date: Thu, 29 Aug 2019 18:03:55 -0700 Subject: [PATCH 10/11] remove CSIVolumeSnapshotSource and VolumeSnapshotSource and flatten the information into VolumeSnapshotContentSpec, comments enhancement --- ....storage.k8s.io_volumesnapshotclasses.yaml | 3 +- ...storage.k8s.io_volumesnapshotcontents.yaml | 81 +++++++++---------- ...apshot.storage.k8s.io_volumesnapshots.yaml | 48 ++++++----- pkg/apis/volumesnapshot/v1beta1/types.go | 76 ++++++++--------- 4 files changed, 103 insertions(+), 105 deletions(-) diff --git a/config/crd/snapshot.storage.k8s.io_volumesnapshotclasses.yaml b/config/crd/snapshot.storage.k8s.io_volumesnapshotclasses.yaml index 75dba2f39..f147ec4e6 100644 --- a/config/crd/snapshot.storage.k8s.io_volumesnapshotclasses.yaml +++ b/config/crd/snapshot.storage.k8s.io_volumesnapshotclasses.yaml @@ -36,7 +36,8 @@ spec: - Retain type: string driver: - description: driver is the name of the driver that handles this VolumeSnapshotClass. + description: driver is the name of the storage driver that handles this + VolumeSnapshotClass. type: string kind: description: 'Kind is a string value representing the REST resource this diff --git a/config/crd/snapshot.storage.k8s.io_volumesnapshotcontents.yaml b/config/crd/snapshot.storage.k8s.io_volumesnapshotcontents.yaml index 205499386..79397ffae 100644 --- a/config/crd/snapshot.storage.k8s.io_volumesnapshotcontents.yaml +++ b/config/crd/snapshot.storage.k8s.io_volumesnapshotcontents.yaml @@ -31,46 +31,20 @@ spec: type: object spec: description: spec defines properties of a VolumeSnapshotContent created - by underlying storage system. + by the underlying storage system. properties: - csi: - description: csi represents a volume snapshot created by a CSI(Container - Storage Interface) driver. - properties: - creationTime: - description: creationTime is the timestamp when the point-in-time - snapshot is taken by the underlying storage system. This timestamp - is returned by the CSI driver after the snapshot is cut. 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 (aka, epoch time) since 1970-01-01 00:00:00 UTC. - format: int64 - type: integer - driver: - description: driver is the name of the CSI driver used to create - the physical snapshot on the underlying storage system. This MUST - be the same name returned by the CSI GetPluginName() call for - that driver. Required. - type: string - restoreSize: - description: restoreSize specifies the number of bytes that the - snapshot's data would consume when restored to a volume. When - restoring a volume from a snapshot, the volume size needs to be - equal to or larger than the RestoreSize if it is specified. - format: int64 - type: integer - snapshotHandle: - description: snapshotHandle is the snapshot id returned by the CSI - driver in the CreateSnapshotResponse and is used as the snapshot - identifier for all subsequent CSI calls. Required. - type: string - required: - - driver - - snapshotHandle - type: object + creationTime: + description: creationTime is the timestamp when the point-in-time snapshot + is taken by the underlying storage system. This timestamp is returned + by the CSI driver after the snapshot is cut. 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 (aka, epoch time) + since 1970-01-01 00:00:00 UTC. + format: int64 + type: integer deletionPolicy: description: deletionPolicy determines whether this VolumeSnapshotContent - and its bound physical snapshot on the underlying storage system should + and its physical snapshot on the underlying storage system should be deleted when its VolumeSnapshot is deleted. Supported values are "Retain" and "Delete". "Retain" means that the VolumeSnapshotContent and its physical snapshot on underlying storage system are kept. "Delete" @@ -81,13 +55,35 @@ spec: - Delete - Retain type: string + driver: + description: driver is the name of the CSI driver used to create the + physical snapshot on the underlying storage system. This MUST be the + same as the name returned by the CSI GetPluginName() call for that + driver. Required. + type: string + restoreSize: + description: restoreSize specifies the number of bytes that the snapshot's + data would consume when restored to a volume. When restoring a volume + from a snapshot, the volume size needs to be equal to or larger than + the restoreSize if it is specified. Otherwise the restoration will + fail. + format: int64 + type: integer + snapshotHandle: + description: snapshotHandle is the snapshot id returned by the CSI driver + in the CreateSnapshotResponse and is used as the snapshot identifier + for all subsequent CSI calls. Required. + type: string volumeSnapshotRef: description: volumeSnapshotRef specifies the VolumeSnapshot object that this VolumeSnapshotContent is bound with. The VolumeSnapshot.Spec.VolumeSnapshotContentName - field must reference this VolumeSnapshotContent name for the binding - to be considered valid(a.k.a bi-directional binding). If the referenced - VolumeSnapshot object does not exist(i.e., deleted by user), then - the VolumeSnapshotContent.Spec.DeletionPolicy is triggered. + field must reference this VolumeSnapshotContent name for the bidirectional + binding to be considered valid. If the referenced VolumeSnapshot object + does not exist(i.e., deleted by user) AND the UID of the referent + is not empty(i.e., volumeSnapshotRef.UID != ""), then the VolumeSnapshotContent.Spec.DeletionPolicy + is triggered. To statically bind a pre-existing snapshot, user MUST + leave volumeSnapshotRef.UID empty to avoid triggering undesired VolumeSnapshotContent + object deletion. properties: apiVersion: description: API version of the referent. @@ -122,6 +118,9 @@ spec: description: 'UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids' type: string type: object + required: + - driver + - snapshotHandle type: object required: - spec diff --git a/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml b/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml index 0ea2d800d..53fc12a70 100644 --- a/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml +++ b/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml @@ -37,10 +37,10 @@ spec: source: description: source specifies where a snapshot should be created from. Currently, PersistentVolumeClaim is the only supported source type. - If specified, and VolumeSnapshotContentName is not specified(i.e., + If specified, and volumeSnapshotContentName is not specified(i.e., nil), snapshot will be dynamically created from the given source. - If not specified, and VolumeSnapshotContentName is not specified, - system controller will fail on dynamic snapshot creation. + If both source and volumeSnapshotContentName are not specified, dynamic + snapshot creation will fail. properties: apiGroup: description: APIGroup is the group for the resource being referenced. @@ -61,8 +61,8 @@ spec: description: 'volumeSnapshotClassName is the name of the VolumeSnapshotClass requested by the VolumeSnapshot. If not specified, the default snapshot class will be used if there exists one. If not specified, and there - is no default snapshot class, dynamic VolumeSnapshot creation will - fail. More info: https://kubernetes.io/docs/concepts/storage/volume-snapshot-classes' + is no default snapshot class, dynamic snapshot creation will fail. + More info: https://kubernetes.io/docs/concepts/storage/volume-snapshot-classes' type: string volumeSnapshotContentName: description: volumeSnapshotContentName is the name of the VolumeSnapshotContent @@ -74,16 +74,19 @@ spec: type: object status: description: 'status represents the current information of a snapshot. NOTE: - status can be modified by sources other than system controllers, and - must not be depended upon for accuracy. Controllers should only - be using information from the VolumeSnapshotContent object after - verifying that the binding is accurate and complete.' + status can be modified by sources other than system controllers, and must + not be depended upon for accuracy. Controllers should only be using information + from the VolumeSnapshotContent object after verifying that the binding + is accurate and complete.' properties: creationTime: description: 'creationTime, if not nil, represents the timestamp when - a snapshot was successfully cut by the underlying storage system. - In static binding, CreationTime might not be available. NOTE: Controllers - MUST NOT rely on this field programmatically' + the snapshot was successfully cut by the underlying storage system. + When dynamically creating a snapshot, this will be filled in upon + creation. For pre-existing snapshot, it will be filled in upon the + VolumeSnapshot object has been successfully bound to a VolumeSnapshotContent + object and the underlying storage system have the information available. + NOTE: Controllers MUST NOT rely on this field programmatically.' format: date-time type: string error: @@ -105,22 +108,23 @@ spec: type: object readyToUse: description: 'readyToUse is an informational flag which provides transparency - to users. In dynamic snapshot creation case, ReadyToUse will be set + to users. In dynamic snapshot creation case, readyToUse will be set to true when underlying storage system has successfully finished all - procedures out-of-bound to make a snapshot available AND snapshot - controller has bound the VolumeSnapshot to a VolumeSnapshotContent - successfully. If not specified(i.e., nil), it means the readiness - of the VolumeSnapshot is unknown to system controllers. NOTE: Controllers - MUST NOT rely on this field programmatically' + out-of-bound procedures to make a snapshot ready to consume, i.e., + restoring a PersistentVolumeClaim from the snapshot. TODO(@xiangqian): + Adding the case for pre-existing snapshots after the logic has been + fully sorted out. If not specified(i.e., nil), it means the readiness + of the snapshot is unknown to system controllers. NOTE: Controllers + MUST NOT rely on this field programmatically.' type: boolean restoreSize: description: 'restoreSize specifies the number of bytes that the snapshot''s data would consume when restored to a volume. When restoring a volume from a snapshot, the volume size needs to be equal to or larger than - the RestoreSize if it is specified. The field could be nil if the - underlying storage system does not have the information available, - or in cases like static binding. NOTE: Controllers MUST NOT rely on - this field programmatically' + the restoreSize if it is specified. Otherwise the restoration will + fail. The field could be nil if the underlying storage system does + not have the information available. NOTE: Controllers MUST NOT rely + on this field programmatically.' type: string type: object type: object diff --git a/pkg/apis/volumesnapshot/v1beta1/types.go b/pkg/apis/volumesnapshot/v1beta1/types.go index 2f6a3bb23..a54094b51 100644 --- a/pkg/apis/volumesnapshot/v1beta1/types.go +++ b/pkg/apis/volumesnapshot/v1beta1/types.go @@ -44,9 +44,9 @@ type VolumeSnapshot struct { // status represents the current information of a snapshot. // NOTE: status can be modified by sources other than system controllers, - // and must not be depended upon for accuracy. - // Controllers should only be using information from the VolumeSnapshotContent object - // after verifying that the binding is accurate and complete. + // and must not be depended upon for accuracy. + // Controllers should only be using information from the VolumeSnapshotContent object + // after verifying that the binding is accurate and complete. // +optional Status VolumeSnapshotStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` } @@ -67,10 +67,10 @@ type VolumeSnapshotList struct { type VolumeSnapshotSpec struct { // source specifies where a snapshot should be created from. // Currently, PersistentVolumeClaim is the only supported source type. - // If specified, and VolumeSnapshotContentName is not specified(i.e., nil), + // If specified, and volumeSnapshotContentName is not specified(i.e., nil), // snapshot will be dynamically created from the given source. - // If not specified, and VolumeSnapshotContentName is not specified, system - // controller will fail on dynamic snapshot creation. + // If both source and volumeSnapshotContentName are not specified, dynamic snapshot + // creation will fail. // +optional Source *core_v1.TypedLocalObjectReference `json:"source,omitempty" protobuf:"bytes,1,opt,name=source"` @@ -83,7 +83,7 @@ type VolumeSnapshotSpec struct { // volumeSnapshotClassName is the name of the VolumeSnapshotClass requested by the VolumeSnapshot. // If not specified, the default snapshot class will be used if there exists one. - // If not specified, and there is no default snapshot class, dynamic VolumeSnapshot creation will fail. + // If not specified, and there is no default snapshot class, dynamic snapshot creation will fail. // More info: https://kubernetes.io/docs/concepts/storage/volume-snapshot-classes // +optional VolumeSnapshotClassName *string `json:"volumeSnapshotClassName,omitempty" protobuf:"bytes,3,opt,name=volumeSnapshotClassName"` @@ -93,31 +93,34 @@ type VolumeSnapshotSpec struct { // +kubebuilder:subresource:status type VolumeSnapshotStatus struct { // NOTE: All fields in VolumeSnapshotStatus are informational for user references. - // Controllers MUST NOT rely on any fields programmatically. + // Controllers MUST NOT rely on any fields programmatically. - // creationTime, if not nil, represents the timestamp when a snapshot was successfully + // creationTime, if not nil, represents the timestamp when the snapshot was successfully // cut by the underlying storage system. - // In static binding, CreationTime might not be available. - // NOTE: Controllers MUST NOT rely on this field programmatically + // When dynamically creating a snapshot, this will be filled in upon creation. + // For pre-existing snapshot, it will be filled in upon the VolumeSnapshot object has + // been successfully bound to a VolumeSnapshotContent object and the underlying + // storage system have the information available. + // NOTE: Controllers MUST NOT rely on this field programmatically. // +optional CreationTime *metav1.Time `json:"creationTime,omitempty" protobuf:"bytes,1,opt,name=creationTime"` // readyToUse is an informational flag which provides transparency to users. - // In dynamic snapshot creation case, ReadyToUse will be set to true when underlying storage - // system has successfully finished all procedures out-of-bound to make a snapshot available AND - // snapshot controller has bound the VolumeSnapshot to a VolumeSnapshotContent successfully. - // If not specified(i.e., nil), it means the readiness of the VolumeSnapshot is unknown to system controllers. - // NOTE: Controllers MUST NOT rely on this field programmatically + // In dynamic snapshot creation case, readyToUse will be set to true when underlying storage + // system has successfully finished all out-of-bound procedures to make a snapshot ready to consume, + // i.e., restoring a PersistentVolumeClaim from the snapshot. + // TODO(@xiangqian): Adding the case for pre-existing snapshots after the logic has been fully sorted out. + // If not specified(i.e., nil), it means the readiness of the snapshot is unknown to system controllers. + // NOTE: Controllers MUST NOT rely on this field programmatically. // +optional ReadyToUse *bool `json:"readyToUse,omitempty" protobuf:"varint,3,opt,name=readyToUse"` // restoreSize specifies the number of bytes that the snapshot's data would consume when // restored to a volume. // When restoring a volume from a snapshot, the volume size needs to be equal to or - // larger than the RestoreSize if it is specified. - // The field could be nil if the underlying storage system does not have the information available, - // or in cases like static binding. - // NOTE: Controllers MUST NOT rely on this field programmatically + // larger than the restoreSize if it is specified. Otherwise the restoration will fail. + // The field could be nil if the underlying storage system does not have the information available. + // NOTE: Controllers MUST NOT rely on this field programmatically. // +optional RestoreSize *resource.Quantity `json:"restoreSize,omitempty" protobuf:"bytes,2,opt,name=restoreSize"` @@ -146,7 +149,7 @@ type VolumeSnapshotClass struct { // +optional metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` - // driver is the name of the driver that handles this VolumeSnapshotClass. + // driver is the name of the storage driver that handles this VolumeSnapshotClass. Driver string `json:"driver" protobuf:"bytes,2,opt,name=driver"` // parameters is a key-value map with storage driver specific parameters for creating snapshots. @@ -193,7 +196,7 @@ type VolumeSnapshotContent struct { // +optional metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` - // spec defines properties of a VolumeSnapshotContent created by underlying storage system. + // spec defines properties of a VolumeSnapshotContent created by the underlying storage system. Spec VolumeSnapshotContentSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"` } @@ -211,18 +214,19 @@ type VolumeSnapshotContentList struct { // VolumeSnapshotContentSpec is the specification of a VolumeSnapshotContent type VolumeSnapshotContentSpec struct { - // volumeSnapshotSource holds critical metadata where the snapshot on underlying storage - // system has been created from. - VolumeSnapshotSource `json:",inline" protobuf:"bytes,1,opt,name=volumeSnapshotSource"` // volumeSnapshotRef specifies the VolumeSnapshot object that this VolumeSnapshotContent is bound with. - // The VolumeSnapshot.Spec.VolumeSnapshotContentName field must reference this VolumeSnapshotContent name for the - // binding to be considered valid(a.k.a bi-directional binding). If the referenced VolumeSnapshot object does not - // exist(i.e., deleted by user), then the VolumeSnapshotContent.Spec.DeletionPolicy is triggered. + // The VolumeSnapshot.Spec.VolumeSnapshotContentName field must reference this VolumeSnapshotContent name + // for the bidirectional binding to be considered valid. + // If the referenced VolumeSnapshot object does not exist(i.e., deleted by user) AND + // the UID of the referent is not empty(i.e., volumeSnapshotRef.UID != ""), + // then the VolumeSnapshotContent.Spec.DeletionPolicy is triggered. + // To statically bind a pre-existing snapshot, user MUST leave volumeSnapshotRef.UID + // empty to avoid triggering undesired VolumeSnapshotContent object deletion. // +optional VolumeSnapshotRef *core_v1.ObjectReference `json:"volumeSnapshotRef,omitempty" protobuf:"bytes,2,opt,name=volumeSnapshotRef"` - // deletionPolicy determines whether this VolumeSnapshotContent and its bound physical snapshot on + // deletionPolicy determines whether this VolumeSnapshotContent and its physical snapshot on // the underlying storage system should be deleted when its VolumeSnapshot is deleted. // Supported values are "Retain" and "Delete". // "Retain" means that the VolumeSnapshotContent and its physical snapshot on underlying storage system are kept. @@ -230,20 +234,10 @@ type VolumeSnapshotContentSpec struct { // If not specified, the default value is "Retain" // +optional DeletionPolicy *DeletionPolicy `json:"deletionPolicy,omitempty" protobuf:"bytes,5,opt,name=deletionPolicy"` -} - -// VolumeSnapshotSource represents the actual location and type of the snapshot. Only one of its members may be specified. -type VolumeSnapshotSource struct { - // csi represents a volume snapshot created by a CSI(Container Storage Interface) driver. - // +optional - CSI *CSIVolumeSnapshotSource `json:"csi,omitempty"` -} -// CSIVolumeSnapshotSource represents the source from CSI volume snapshot -type CSIVolumeSnapshotSource struct { // driver is the name of the CSI driver used to create the physical snapshot on // the underlying storage system. - // This MUST be the same name returned by the CSI GetPluginName() call for + // This MUST be the same as the name returned by the CSI GetPluginName() call for // that driver. // Required. Driver string `json:"driver" protobuf:"bytes,1,opt,name=driver"` @@ -264,7 +258,7 @@ type CSIVolumeSnapshotSource struct { // restoreSize specifies the number of bytes that the snapshot's data would consume when // restored to a volume. // When restoring a volume from a snapshot, the volume size needs to be equal to or - // larger than the RestoreSize if it is specified. + // larger than the restoreSize if it is specified. Otherwise the restoration will fail. // +optional RestoreSize *int64 `json:"restoreSize,omitempty" protobuf:"bytes,4,opt,name=restoreSize"` } From c26f8a8cc70332c1b5ae1cbb2d967dd3b596b62a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cxing-yang=E2=80=9D?= Date: Tue, 3 Sep 2019 18:53:34 -0700 Subject: [PATCH 11/11] Update controller after removing CSI from Content Spec --- examples/kubernetes/snapshot.yaml | 4 +- examples/kubernetes/snapshotclass.yaml | 4 +- .../v1beta1/zz_generated.deepcopy.go | 58 ++++--------------- pkg/controller/csi_handler.go | 10 +--- pkg/controller/framework_test.go | 22 +++---- pkg/controller/snapshot_controller.go | 35 ++++++----- pkg/controller/snapshot_controller_base.go | 6 +- 7 files changed, 43 insertions(+), 96 deletions(-) diff --git a/examples/kubernetes/snapshot.yaml b/examples/kubernetes/snapshot.yaml index b7a913f9c..995a0a510 100644 --- a/examples/kubernetes/snapshot.yaml +++ b/examples/kubernetes/snapshot.yaml @@ -1,9 +1,9 @@ -apiVersion: snapshot.storage.k8s.io/v1alpha1 +apiVersion: snapshot.storage.k8s.io/v1beta1 kind: VolumeSnapshot metadata: name: new-snapshot-demo spec: - snapshotClassName: csi-hostpath-snapclass + volumeSnapshotClassName: csi-hostpath-snapclass source: name: hpvc kind: PersistentVolumeClaim diff --git a/examples/kubernetes/snapshotclass.yaml b/examples/kubernetes/snapshotclass.yaml index dfa34df56..4a6e260b1 100644 --- a/examples/kubernetes/snapshotclass.yaml +++ b/examples/kubernetes/snapshotclass.yaml @@ -1,5 +1,5 @@ -apiVersion: snapshot.storage.k8s.io/v1alpha1 +apiVersion: snapshot.storage.k8s.io/v1beta1 kind: VolumeSnapshotClass metadata: name: csi-hostpath-snapclass -snapshotter: csi-hostpath +driver: csi-hostpath diff --git a/pkg/apis/volumesnapshot/v1beta1/zz_generated.deepcopy.go b/pkg/apis/volumesnapshot/v1beta1/zz_generated.deepcopy.go index 0e8f2c43d..2e76f4033 100644 --- a/pkg/apis/volumesnapshot/v1beta1/zz_generated.deepcopy.go +++ b/pkg/apis/volumesnapshot/v1beta1/zz_generated.deepcopy.go @@ -25,32 +25,6 @@ import ( runtime "k8s.io/apimachinery/pkg/runtime" ) -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CSIVolumeSnapshotSource) DeepCopyInto(out *CSIVolumeSnapshotSource) { - *out = *in - if in.CreationTime != nil { - in, out := &in.CreationTime, &out.CreationTime - *out = new(int64) - **out = **in - } - if in.RestoreSize != nil { - in, out := &in.RestoreSize, &out.RestoreSize - *out = new(int64) - **out = **in - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CSIVolumeSnapshotSource. -func (in *CSIVolumeSnapshotSource) DeepCopy() *CSIVolumeSnapshotSource { - if in == nil { - return nil - } - out := new(CSIVolumeSnapshotSource) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *VolumeSnapshot) DeepCopyInto(out *VolumeSnapshot) { *out = *in @@ -213,7 +187,6 @@ func (in *VolumeSnapshotContentList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *VolumeSnapshotContentSpec) DeepCopyInto(out *VolumeSnapshotContentSpec) { *out = *in - in.VolumeSnapshotSource.DeepCopyInto(&out.VolumeSnapshotSource) if in.VolumeSnapshotRef != nil { in, out := &in.VolumeSnapshotRef, &out.VolumeSnapshotRef *out = new(v1.ObjectReference) @@ -224,6 +197,16 @@ func (in *VolumeSnapshotContentSpec) DeepCopyInto(out *VolumeSnapshotContentSpec *out = new(DeletionPolicy) **out = **in } + if in.CreationTime != nil { + in, out := &in.CreationTime, &out.CreationTime + *out = new(int64) + **out = **in + } + if in.RestoreSize != nil { + in, out := &in.RestoreSize, &out.RestoreSize + *out = new(int64) + **out = **in + } return } @@ -295,27 +278,6 @@ func (in *VolumeSnapshotList) DeepCopyObject() runtime.Object { return nil } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *VolumeSnapshotSource) DeepCopyInto(out *VolumeSnapshotSource) { - *out = *in - if in.CSI != nil { - in, out := &in.CSI, &out.CSI - *out = new(CSIVolumeSnapshotSource) - (*in).DeepCopyInto(*out) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeSnapshotSource. -func (in *VolumeSnapshotSource) DeepCopy() *VolumeSnapshotSource { - if in == nil { - return nil - } - out := new(VolumeSnapshotSource) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *VolumeSnapshotSpec) DeepCopyInto(out *VolumeSnapshotSpec) { *out = *in diff --git a/pkg/controller/csi_handler.go b/pkg/controller/csi_handler.go index 881f8a7b1..8413b2082 100644 --- a/pkg/controller/csi_handler.go +++ b/pkg/controller/csi_handler.go @@ -75,13 +75,10 @@ func (handler *csiHandler) CreateSnapshot(snapshot *crdv1.VolumeSnapshot, volume } func (handler *csiHandler) DeleteSnapshot(content *crdv1.VolumeSnapshotContent, snapshotterCredentials map[string]string) error { - if content.Spec.CSI == nil { - return fmt.Errorf("CSISnapshot not defined in spec") - } ctx, cancel := context.WithTimeout(context.Background(), handler.timeout) defer cancel() - err := handler.snapshotter.DeleteSnapshot(ctx, content.Spec.CSI.SnapshotHandle, snapshotterCredentials) + err := handler.snapshotter.DeleteSnapshot(ctx, content.Spec.SnapshotHandle, snapshotterCredentials) if err != nil { return fmt.Errorf("failed to delete snapshot content %s: %q", content.Name, err) } @@ -90,13 +87,10 @@ func (handler *csiHandler) DeleteSnapshot(content *crdv1.VolumeSnapshotContent, } func (handler *csiHandler) GetSnapshotStatus(content *crdv1.VolumeSnapshotContent) (bool, time.Time, int64, error) { - if content.Spec.CSI == nil { - return false, time.Time{}, 0, fmt.Errorf("CSISnapshot not defined in spec") - } ctx, cancel := context.WithTimeout(context.Background(), handler.timeout) defer cancel() - csiSnapshotStatus, timestamp, size, err := handler.snapshotter.GetSnapshotStatus(ctx, content.Spec.CSI.SnapshotHandle) + csiSnapshotStatus, timestamp, size, err := handler.snapshotter.GetSnapshotStatus(ctx, content.Spec.SnapshotHandle) if err != nil { return false, time.Time{}, 0, fmt.Errorf("failed to list snapshot content %s: %q", content.Name, err) } diff --git a/pkg/controller/framework_test.go b/pkg/controller/framework_test.go index 84125db89..9e7052eda 100644 --- a/pkg/controller/framework_test.go +++ b/pkg/controller/framework_test.go @@ -425,9 +425,7 @@ func (r *snapshotReactor) checkContents(expectedContents []*crdv1.VolumeSnapshot if v.Spec.VolumeSnapshotRef != nil { v.Spec.VolumeSnapshotRef.ResourceVersion = "" } - if v.Spec.CSI != nil { - v.Spec.CSI.CreationTime = nil - } + v.Spec.CreationTime = nil expectedMap[v.Name] = v } for _, v := range r.contents { @@ -438,9 +436,7 @@ func (r *snapshotReactor) checkContents(expectedContents []*crdv1.VolumeSnapshot if v.Spec.VolumeSnapshotRef != nil { v.Spec.VolumeSnapshotRef.ResourceVersion = "" } - if v.Spec.CSI != nil { - v.Spec.CSI.CreationTime = nil - } + v.Spec.CreationTime = nil gotMap[v.Name] = v } if !reflect.DeepEqual(expectedMap, gotMap) { @@ -790,14 +786,10 @@ func newContent(name, snapshotHandle, boundToSnapshotUID, boundToSnapshotName st ResourceVersion: "1", }, Spec: crdv1.VolumeSnapshotContentSpec{ - VolumeSnapshotSource: crdv1.VolumeSnapshotSource{ - CSI: &crdv1.CSIVolumeSnapshotSource{ - RestoreSize: size, - Driver: mockDriverName, - SnapshotHandle: snapshotHandle, - CreationTime: creationTime, - }, - }, + RestoreSize: size, + Driver: mockDriverName, + SnapshotHandle: snapshotHandle, + CreationTime: creationTime, DeletionPolicy: deletionPolicy, }, } @@ -825,7 +817,7 @@ func newContentArray(name, snapshotHandle, boundToSnapshotUID, boundToSnapshotNa func newContentWithUnmatchDriverArray(name, snapshotHandle, boundToSnapshotUID, boundToSnapshotName string, deletionPolicy *crdv1.DeletionPolicy, size *int64, creationTime *int64) []*crdv1.VolumeSnapshotContent { content := newContent(name, snapshotHandle, boundToSnapshotUID, boundToSnapshotName, deletionPolicy, size, creationTime, false) - content.Spec.VolumeSnapshotSource.CSI.Driver = "fake" + content.Spec.Driver = "fake" return []*crdv1.VolumeSnapshotContent{ content, } diff --git a/pkg/controller/snapshot_controller.go b/pkg/controller/snapshot_controller.go index e27ce02e8..a49fa6109 100644 --- a/pkg/controller/snapshot_controller.go +++ b/pkg/controller/snapshot_controller.go @@ -441,7 +441,15 @@ func (ctrl *csiSnapshotController) updateSnapshotErrorStatusWithEvent(snapshot * // Stateless functions func getSnapshotStatusForLogging(snapshot *crdv1.VolumeSnapshot) string { - return fmt.Sprintf("bound to: %q, Completed: %v", *snapshot.Spec.VolumeSnapshotContentName, *snapshot.Status.ReadyToUse) + name := "" + ready := false + if snapshot.Spec.VolumeSnapshotContentName != nil { + name = *snapshot.Spec.VolumeSnapshotContentName + } + if snapshot.Status.ReadyToUse != nil { + ready = *snapshot.Status.ReadyToUse + } + return fmt.Sprintf("bound to: %q, Completed: %v", name, ready) } // IsSnapshotBound returns true/false if snapshot is bound @@ -572,9 +580,8 @@ func (ctrl *csiSnapshotController) checkandUpdateBoundSnapshotStatusOperation(sn klog.Errorf("checkandUpdateBoundSnapshotStatusOperation: failed to call get snapshot status to check whether snapshot is ready to use %q", err) return nil, err } - if content.Spec.CSI != nil { - driverName, snapshotID = content.Spec.CSI.Driver, content.Spec.CSI.SnapshotHandle - } + driverName = content.Spec.Driver + snapshotID = content.Spec.SnapshotHandle } else { class, volume, _, snapshotterCredentials, err := ctrl.getCreateSnapshotInput(snapshot) if err != nil { @@ -666,15 +673,11 @@ func (ctrl *csiSnapshotController) createSnapshotOperation(snapshot *crdv1.Volum }, Spec: crdv1.VolumeSnapshotContentSpec{ VolumeSnapshotRef: snapshotRef, - VolumeSnapshotSource: crdv1.VolumeSnapshotSource{ - CSI: &crdv1.CSIVolumeSnapshotSource{ - Driver: driverName, - SnapshotHandle: snapshotID, - CreationTime: ×tamp, - RestoreSize: &size, - }, - }, - DeletionPolicy: class.DeletionPolicy, + Driver: driverName, + SnapshotHandle: snapshotID, + CreationTime: ×tamp, + RestoreSize: &size, + DeletionPolicy: class.DeletionPolicy, }, } klog.V(3).Infof("volume snapshot content %v", snapshotContent) @@ -790,14 +793,14 @@ func (ctrl *csiSnapshotController) bindandUpdateVolumeSnapshot(snapshotContent * // updateSnapshotContentSize update the restore size for snapshot content func (ctrl *csiSnapshotController) updateSnapshotContentSize(content *crdv1.VolumeSnapshotContent, size int64) error { - if content.Spec.VolumeSnapshotSource.CSI == nil || size <= 0 { + if size <= 0 { return nil } - if content.Spec.VolumeSnapshotSource.CSI.RestoreSize != nil && *content.Spec.VolumeSnapshotSource.CSI.RestoreSize == size { + if content.Spec.RestoreSize != nil && *content.Spec.RestoreSize == size { return nil } contentClone := content.DeepCopy() - contentClone.Spec.VolumeSnapshotSource.CSI.RestoreSize = &size + contentClone.Spec.RestoreSize = &size _, err := ctrl.clientset.SnapshotV1beta1().VolumeSnapshotContents().Update(contentClone) if err != nil { return newControllerUpdateError(content.Name, err.Error()) diff --git a/pkg/controller/snapshot_controller_base.go b/pkg/controller/snapshot_controller_base.go index 55de2d2fe..d4927d3a8 100644 --- a/pkg/controller/snapshot_controller_base.go +++ b/pkg/controller/snapshot_controller_base.go @@ -325,11 +325,7 @@ func (ctrl *csiSnapshotController) contentWorker() { // verify whether the driver specified in VolumeSnapshotContent matches the controller's driver name func (ctrl *csiSnapshotController) isDriverMatch(content *crdv1.VolumeSnapshotContent) bool { - if content.Spec.VolumeSnapshotSource.CSI == nil { - // Skip this snapshot content if it not a CSI snapshot - return false - } - if content.Spec.VolumeSnapshotSource.CSI.Driver != ctrl.driverName { + if content.Spec.Driver != ctrl.driverName { // Skip this snapshot content if the driver does not match return false }