diff --git a/api/api-rules/violation_exceptions.list b/api/api-rules/violation_exceptions.list index 599e55546cb..63f329b8fa7 100644 --- a/api/api-rules/violation_exceptions.list +++ b/api/api-rules/violation_exceptions.list @@ -265,6 +265,7 @@ API rule violation: list_type_missing,k8s.io/api/storage/v1,CSINodeDriver,Topolo API rule violation: list_type_missing,k8s.io/api/storage/v1,CSINodeSpec,Drivers API rule violation: list_type_missing,k8s.io/api/storage/v1,StorageClass,AllowedTopologies API rule violation: list_type_missing,k8s.io/api/storage/v1,StorageClass,MountOptions +API rule violation: list_type_missing,k8s.io/api/storage/v1alpha1,CSIStorageCapacityList,Items API rule violation: list_type_missing,k8s.io/api/storage/v1beta1,CSIDriverSpec,VolumeLifecycleModes API rule violation: list_type_missing,k8s.io/api/storage/v1beta1,CSINodeDriver,TopologyKeys API rule violation: list_type_missing,k8s.io/api/storage/v1beta1,CSINodeSpec,Drivers diff --git a/api/openapi-spec/swagger.json b/api/openapi-spec/swagger.json index 51f51c80b1c..2d72dd85681 100644 --- a/api/openapi-spec/swagger.json +++ b/api/openapi-spec/swagger.json @@ -14848,6 +14848,10 @@ "description": "If set to true, podInfoOnMount indicates this CSI volume driver requires additional pod information (like podName, podUID, etc.) during mount operations. If set to false, pod information will not be passed on mount. Default is false. The CSI driver specifies podInfoOnMount as part of driver deployment. If true, Kubelet will pass pod information as VolumeContext in the CSI NodePublishVolume() calls. The CSI driver is responsible for parsing and validating the information passed in as VolumeContext. The following VolumeConext will be passed if podInfoOnMount is set to true. This list might grow, but the prefix will be used. \"csi.storage.k8s.io/pod.name\": pod.Name \"csi.storage.k8s.io/pod.namespace\": pod.Namespace \"csi.storage.k8s.io/pod.uid\": string(pod.UID) \"csi.storage.k8s.io/ephemeral\": \"true\" iff the volume is an ephemeral inline volume\n defined by a CSIVolumeSource, otherwise \"false\"\n\n\"csi.storage.k8s.io/ephemeral\" is a new feature in Kubernetes 1.16. It is only required for drivers which support both the \"Persistent\" and \"Ephemeral\" VolumeLifecycleMode. Other drivers can leave pod info disabled and/or ignore this field. As Kubernetes 1.15 doesn't support this field, drivers can only support one mode when deployed on such a cluster and the deployment determines which mode that is, for example via a command line parameter of the driver.", "type": "boolean" }, + "storageCapacity": { + "description": "If set to true, storageCapacity indicates that the CSI volume driver wants pod scheduling to consider the storage capacity that the driver deployment will report by creating CSIStorageCapacity objects with capacity information.\n\nThe check can be enabled immediately when deploying a driver. In that case, provisioning new volumes with late binding will pause until the driver deployment has published some suitable CSIStorageCapacity object.\n\nAlternatively, the driver can be deployed with the field unset or false and it can be flipped later when storage capacity information has been published.\n\nThis is an alpha field and only available when the CSIStorageCapacity feature is enabled. The default is false.", + "type": "boolean" + }, "volumeLifecycleModes": { "description": "volumeLifecycleModes defines what kind of volumes this CSI volume driver supports. The default if the list is empty is \"Persistent\", which is the usage defined by the CSI specification and implemented in Kubernetes via the usual PV/PVC mechanism. The other mode is \"Ephemeral\". In this mode, volumes are defined inline inside the pod spec with CSIVolumeSource and their lifecycle is tied to the lifecycle of that pod. A driver has to be aware of this because it is only going to get a NodePublishVolume call for such a volume. For more information about implementing this mode, see https://kubernetes-csi.github.io/docs/ephemeral-local-volumes.html A driver can support one or more of these modes and more modes may be added in the future. This field is beta.", "items": { @@ -15462,6 +15466,10 @@ "description": "If set to true, podInfoOnMount indicates this CSI volume driver requires additional pod information (like podName, podUID, etc.) during mount operations. If set to false, pod information will not be passed on mount. Default is false. The CSI driver specifies podInfoOnMount as part of driver deployment. If true, Kubelet will pass pod information as VolumeContext in the CSI NodePublishVolume() calls. The CSI driver is responsible for parsing and validating the information passed in as VolumeContext. The following VolumeConext will be passed if podInfoOnMount is set to true. This list might grow, but the prefix will be used. \"csi.storage.k8s.io/pod.name\": pod.Name \"csi.storage.k8s.io/pod.namespace\": pod.Namespace \"csi.storage.k8s.io/pod.uid\": string(pod.UID) \"csi.storage.k8s.io/ephemeral\": \"true\" iff the volume is an ephemeral inline volume\n defined by a CSIVolumeSource, otherwise \"false\"\n\n\"csi.storage.k8s.io/ephemeral\" is a new feature in Kubernetes 1.16. It is only required for drivers which support both the \"Persistent\" and \"Ephemeral\" VolumeLifecycleMode. Other drivers can leave pod info disabled and/or ignore this field. As Kubernetes 1.15 doesn't support this field, drivers can only support one mode when deployed on such a cluster and the deployment determines which mode that is, for example via a command line parameter of the driver.", "type": "boolean" }, + "storageCapacity": { + "description": "If set to true, storageCapacity indicates that the CSI volume driver wants pod scheduling to consider the storage capacity that the driver deployment will report by creating CSIStorageCapacity objects with capacity information.\n\nThe check can be enabled immediately when deploying a driver. In that case, provisioning new volumes with late binding will pause until the driver deployment has published some suitable CSIStorageCapacity object.\n\nAlternatively, the driver can be deployed with the field unset or false and it can be flipped later when storage capacity information has been published.\n\nThis is an alpha field and only available when the CSIStorageCapacity feature is enabled. The default is false.", + "type": "boolean" + }, "volumeLifecycleModes": { "description": "VolumeLifecycleModes defines what kind of volumes this CSI volume driver supports. The default if the list is empty is \"Persistent\", which is the usage defined by the CSI specification and implemented in Kubernetes via the usual PV/PVC mechanism. The other mode is \"Ephemeral\". In this mode, volumes are defined inline inside the pod spec with CSIVolumeSource and their lifecycle is tied to the lifecycle of that pod. A driver has to be aware of this because it is only going to get a NodePublishVolume call for such a volume. For more information about implementing this mode, see https://kubernetes-csi.github.io/docs/ephemeral-local-volumes.html A driver can support one or more of these modes and more modes may be added in the future.", "items": { diff --git a/pkg/apis/storage/BUILD b/pkg/apis/storage/BUILD index 2e7f381c2e8..6224e0a493c 100644 --- a/pkg/apis/storage/BUILD +++ b/pkg/apis/storage/BUILD @@ -16,6 +16,7 @@ go_library( importpath = "k8s.io/kubernetes/pkg/apis/storage", deps = [ "//pkg/apis/core:go_default_library", + "//staging/src/k8s.io/apimachinery/pkg/api/resource:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library", diff --git a/pkg/apis/storage/fuzzer/fuzzer.go b/pkg/apis/storage/fuzzer/fuzzer.go index a059856cc7f..ed8621899ab 100644 --- a/pkg/apis/storage/fuzzer/fuzzer.go +++ b/pkg/apis/storage/fuzzer/fuzzer.go @@ -78,6 +78,10 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { obj.Spec.PodInfoOnMount = new(bool) *(obj.Spec.PodInfoOnMount) = false } + if obj.Spec.StorageCapacity == nil { + obj.Spec.StorageCapacity = new(bool) + *(obj.Spec.StorageCapacity) = false + } if len(obj.Spec.VolumeLifecycleModes) == 0 { obj.Spec.VolumeLifecycleModes = []storage.VolumeLifecycleMode{ storage.VolumeLifecyclePersistent, diff --git a/pkg/apis/storage/register.go b/pkg/apis/storage/register.go index fffba5fc5a2..bf59e88cd1e 100644 --- a/pkg/apis/storage/register.go +++ b/pkg/apis/storage/register.go @@ -52,6 +52,8 @@ func addKnownTypes(scheme *runtime.Scheme) error { &CSINodeList{}, &CSIDriver{}, &CSIDriverList{}, + &CSIStorageCapacity{}, + &CSIStorageCapacityList{}, ) return nil } diff --git a/pkg/apis/storage/types.go b/pkg/apis/storage/types.go index 78185dfdbdb..4cb484aabfe 100644 --- a/pkg/apis/storage/types.go +++ b/pkg/apis/storage/types.go @@ -17,6 +17,7 @@ limitations under the License. package storage import ( + "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" api "k8s.io/kubernetes/pkg/apis/core" ) @@ -308,6 +309,26 @@ type CSIDriverSpec struct { // more modes may be added in the future. // +optional VolumeLifecycleModes []VolumeLifecycleMode + + // If set to true, storageCapacity indicates that the CSI + // volume driver wants pod scheduling to consider the storage + // capacity that the driver deployment will report by creating + // CSIStorageCapacity objects with capacity information. + // + // The check can be enabled immediately when deploying a driver. + // In that case, provisioning new volumes with late binding + // will pause until the driver deployment has published + // some suitable CSIStorageCapacity object. + // + // Alternatively, the driver can be deployed with the field + // unset or false and it can be flipped later when storage + // capacity information has been published. + // + // This is an alpha field and only available when the CSIStorageCapacity + // feature is enabled. The default is false. + // + // +optional + StorageCapacity *bool } // VolumeLifecycleMode specifies how a CSI volume is used in Kubernetes. @@ -424,3 +445,81 @@ type CSINodeList struct { // items is the list of CSINode Items []CSINode } + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// CSIStorageCapacity stores the result of one CSI GetCapacity call. +// For a given StorageClass, this describes the available capacity in a +// particular topology segment. This can be used when considering where to +// instantiate new PersistentVolumes. +// +// For example this can express things like: +// - StorageClass "standard" has "1234 GiB" available in "topology.kubernetes.io/zone=us-east1" +// - StorageClass "localssd" has "10 GiB" available in "kubernetes.io/hostname=knode-abc123" +// +// The following three cases all imply that no capacity is available for +// a certain combination: +// - no object exists with suitable topology and storage class name +// - such an object exists, but the capacity is unset +// - such an object exists, but the capacity is zero +// +// The producer of these objects can decide which approach is more suitable. +// +// This is an alpha feature and only available when the CSIStorageCapacity feature is enabled. +type CSIStorageCapacity struct { + metav1.TypeMeta + // Standard object's metadata. The name has no particular meaning. It must be + // be a DNS subdomain (dots allowed, 253 characters). To ensure that + // there are no conflicts with other CSI drivers on the cluster, the recommendation + // is to use csisc-, a generated name, or a reverse-domain name which ends + // with the unique CSI driver name. + // + // Objects are namespaced. + // + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata + // +optional + metav1.ObjectMeta + + // NodeTopology defines which nodes have access to the storage + // for which capacity was reported. If not set, the storage is + // not accessible from any node in the cluster. If empty, the + // storage is accessible from all nodes. This field is + // immutable. + // + // +optional + NodeTopology *metav1.LabelSelector + + // The name of the StorageClass that the reported capacity applies to. + // It must meet the same requirements as the name of a StorageClass + // object (non-empty, DNS subdomain). If that object no longer exists, + // the CSIStorageCapacity object is obsolete and should be removed by its + // creator. + // This field is immutable. + StorageClassName string + + // Capacity is the value reported by the CSI driver in its GetCapacityResponse + // for a GetCapacityRequest with topology and parameters that match the + // previous fields. + // + // The semantic is currently (CSI spec 1.2) defined as: + // The available capacity, in bytes, of the storage that can be used + // to provision volumes. If not set, that information is currently + // unavailable and treated like zero capacity. + // + // +optional + Capacity *resource.Quantity +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// CSIStorageCapacityList is a collection of CSIStorageCapacity objects. +type CSIStorageCapacityList struct { + metav1.TypeMeta + // Standard list metadata + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata + // +optional + metav1.ListMeta + + // Items is the list of CSIStorageCapacity objects. + Items []CSIStorageCapacity +} diff --git a/pkg/apis/storage/v1/BUILD b/pkg/apis/storage/v1/BUILD index 2fc673d4e1a..e76d0c1bde7 100644 --- a/pkg/apis/storage/v1/BUILD +++ b/pkg/apis/storage/v1/BUILD @@ -53,7 +53,10 @@ go_test( deps = [ "//pkg/api/legacyscheme:go_default_library", "//pkg/apis/storage/install:go_default_library", + "//pkg/features:go_default_library", "//staging/src/k8s.io/api/storage/v1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library", + "//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library", + "//staging/src/k8s.io/component-base/featuregate/testing:go_default_library", ], ) diff --git a/pkg/apis/storage/v1/defaults.go b/pkg/apis/storage/v1/defaults.go index 856ed98e2d5..4d9145a8f49 100644 --- a/pkg/apis/storage/v1/defaults.go +++ b/pkg/apis/storage/v1/defaults.go @@ -49,6 +49,10 @@ func SetDefaults_CSIDriver(obj *storagev1.CSIDriver) { obj.Spec.PodInfoOnMount = new(bool) *(obj.Spec.PodInfoOnMount) = false } + if obj.Spec.StorageCapacity == nil && utilfeature.DefaultFeatureGate.Enabled(features.CSIStorageCapacity) { + obj.Spec.StorageCapacity = new(bool) + *(obj.Spec.StorageCapacity) = false + } if len(obj.Spec.VolumeLifecycleModes) == 0 && utilfeature.DefaultFeatureGate.Enabled(features.CSIInlineVolume) { obj.Spec.VolumeLifecycleModes = append(obj.Spec.VolumeLifecycleModes, storagev1.VolumeLifecyclePersistent) } diff --git a/pkg/apis/storage/v1/defaults_test.go b/pkg/apis/storage/v1/defaults_test.go index 48a45a27199..4b7fc118169 100644 --- a/pkg/apis/storage/v1/defaults_test.go +++ b/pkg/apis/storage/v1/defaults_test.go @@ -22,8 +22,11 @@ import ( storagev1 "k8s.io/api/storage/v1" "k8s.io/apimachinery/pkg/runtime" + utilfeature "k8s.io/apiserver/pkg/util/feature" + featuregatetesting "k8s.io/component-base/featuregate/testing" "k8s.io/kubernetes/pkg/api/legacyscheme" _ "k8s.io/kubernetes/pkg/apis/storage/install" + "k8s.io/kubernetes/pkg/features" ) func roundTrip(t *testing.T, obj runtime.Object) runtime.Object { @@ -47,6 +50,33 @@ func roundTrip(t *testing.T, obj runtime.Object) runtime.Object { return obj3 } +func TestSetDefaultStorageCapacityEnabled(t *testing.T) { + defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSIStorageCapacity, true)() + driver := &storagev1.CSIDriver{} + + // field should be defaulted + defaultStorageCapacity := false + output := roundTrip(t, runtime.Object(driver)).(*storagev1.CSIDriver) + outStorageCapacity := output.Spec.StorageCapacity + if outStorageCapacity == nil { + t.Errorf("Expected StorageCapacity to be defaulted to: %+v, got: nil", defaultStorageCapacity) + } else if *outStorageCapacity != defaultStorageCapacity { + t.Errorf("Expected StorageCapacity to be defaulted to: %+v, got: %+v", defaultStorageCapacity, outStorageCapacity) + } +} + +func TestSetDefaultStorageCapacityDisabled(t *testing.T) { + defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSIStorageCapacity, false)() + driver := &storagev1.CSIDriver{} + + // field should not be defaulted + output := roundTrip(t, runtime.Object(driver)).(*storagev1.CSIDriver) + outStorageCapacity := output.Spec.StorageCapacity + if outStorageCapacity != nil { + t.Errorf("Expected StorageCapacity to remain nil, got: %+v", outStorageCapacity) + } +} + func TestSetDefaultVolumeBindingMode(t *testing.T) { class := &storagev1.StorageClass{} diff --git a/pkg/apis/storage/v1/zz_generated.conversion.go b/pkg/apis/storage/v1/zz_generated.conversion.go index 07662262015..7ae58b2a6d9 100644 --- a/pkg/apis/storage/v1/zz_generated.conversion.go +++ b/pkg/apis/storage/v1/zz_generated.conversion.go @@ -254,6 +254,7 @@ func autoConvert_v1_CSIDriverSpec_To_storage_CSIDriverSpec(in *v1.CSIDriverSpec, out.AttachRequired = (*bool)(unsafe.Pointer(in.AttachRequired)) out.PodInfoOnMount = (*bool)(unsafe.Pointer(in.PodInfoOnMount)) out.VolumeLifecycleModes = *(*[]storage.VolumeLifecycleMode)(unsafe.Pointer(&in.VolumeLifecycleModes)) + out.StorageCapacity = (*bool)(unsafe.Pointer(in.StorageCapacity)) return nil } @@ -266,6 +267,7 @@ func autoConvert_storage_CSIDriverSpec_To_v1_CSIDriverSpec(in *storage.CSIDriver out.AttachRequired = (*bool)(unsafe.Pointer(in.AttachRequired)) out.PodInfoOnMount = (*bool)(unsafe.Pointer(in.PodInfoOnMount)) out.VolumeLifecycleModes = *(*[]v1.VolumeLifecycleMode)(unsafe.Pointer(&in.VolumeLifecycleModes)) + out.StorageCapacity = (*bool)(unsafe.Pointer(in.StorageCapacity)) return nil } diff --git a/pkg/apis/storage/v1alpha1/BUILD b/pkg/apis/storage/v1alpha1/BUILD index e5a86e68318..bd2653ce416 100644 --- a/pkg/apis/storage/v1alpha1/BUILD +++ b/pkg/apis/storage/v1alpha1/BUILD @@ -16,6 +16,8 @@ go_library( "//pkg/apis/storage:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library", "//staging/src/k8s.io/api/storage/v1alpha1:go_default_library", + "//staging/src/k8s.io/apimachinery/pkg/api/resource:go_default_library", + "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/conversion:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library", diff --git a/pkg/apis/storage/v1alpha1/zz_generated.conversion.go b/pkg/apis/storage/v1alpha1/zz_generated.conversion.go index b879670e76c..37a4dc8e916 100644 --- a/pkg/apis/storage/v1alpha1/zz_generated.conversion.go +++ b/pkg/apis/storage/v1alpha1/zz_generated.conversion.go @@ -23,12 +23,14 @@ package v1alpha1 import ( unsafe "unsafe" - corev1 "k8s.io/api/core/v1" + apicorev1 "k8s.io/api/core/v1" v1alpha1 "k8s.io/api/storage/v1alpha1" + resource "k8s.io/apimachinery/pkg/api/resource" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" conversion "k8s.io/apimachinery/pkg/conversion" runtime "k8s.io/apimachinery/pkg/runtime" core "k8s.io/kubernetes/pkg/apis/core" - v1 "k8s.io/kubernetes/pkg/apis/core/v1" + corev1 "k8s.io/kubernetes/pkg/apis/core/v1" storage "k8s.io/kubernetes/pkg/apis/storage" ) @@ -39,6 +41,26 @@ func init() { // RegisterConversions adds conversion functions to the given scheme. // Public to allow building arbitrary schemes. func RegisterConversions(s *runtime.Scheme) error { + if err := s.AddGeneratedConversionFunc((*v1alpha1.CSIStorageCapacity)(nil), (*storage.CSIStorageCapacity)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_CSIStorageCapacity_To_storage_CSIStorageCapacity(a.(*v1alpha1.CSIStorageCapacity), b.(*storage.CSIStorageCapacity), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*storage.CSIStorageCapacity)(nil), (*v1alpha1.CSIStorageCapacity)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_storage_CSIStorageCapacity_To_v1alpha1_CSIStorageCapacity(a.(*storage.CSIStorageCapacity), b.(*v1alpha1.CSIStorageCapacity), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.CSIStorageCapacityList)(nil), (*storage.CSIStorageCapacityList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_CSIStorageCapacityList_To_storage_CSIStorageCapacityList(a.(*v1alpha1.CSIStorageCapacityList), b.(*storage.CSIStorageCapacityList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*storage.CSIStorageCapacityList)(nil), (*v1alpha1.CSIStorageCapacityList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_storage_CSIStorageCapacityList_To_v1alpha1_CSIStorageCapacityList(a.(*storage.CSIStorageCapacityList), b.(*v1alpha1.CSIStorageCapacityList), scope) + }); err != nil { + return err + } if err := s.AddGeneratedConversionFunc((*v1alpha1.VolumeAttachment)(nil), (*storage.VolumeAttachment)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1alpha1_VolumeAttachment_To_storage_VolumeAttachment(a.(*v1alpha1.VolumeAttachment), b.(*storage.VolumeAttachment), scope) }); err != nil { @@ -102,6 +124,54 @@ func RegisterConversions(s *runtime.Scheme) error { return nil } +func autoConvert_v1alpha1_CSIStorageCapacity_To_storage_CSIStorageCapacity(in *v1alpha1.CSIStorageCapacity, out *storage.CSIStorageCapacity, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + out.NodeTopology = (*v1.LabelSelector)(unsafe.Pointer(in.NodeTopology)) + out.StorageClassName = in.StorageClassName + out.Capacity = (*resource.Quantity)(unsafe.Pointer(in.Capacity)) + return nil +} + +// Convert_v1alpha1_CSIStorageCapacity_To_storage_CSIStorageCapacity is an autogenerated conversion function. +func Convert_v1alpha1_CSIStorageCapacity_To_storage_CSIStorageCapacity(in *v1alpha1.CSIStorageCapacity, out *storage.CSIStorageCapacity, s conversion.Scope) error { + return autoConvert_v1alpha1_CSIStorageCapacity_To_storage_CSIStorageCapacity(in, out, s) +} + +func autoConvert_storage_CSIStorageCapacity_To_v1alpha1_CSIStorageCapacity(in *storage.CSIStorageCapacity, out *v1alpha1.CSIStorageCapacity, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + out.NodeTopology = (*v1.LabelSelector)(unsafe.Pointer(in.NodeTopology)) + out.StorageClassName = in.StorageClassName + out.Capacity = (*resource.Quantity)(unsafe.Pointer(in.Capacity)) + return nil +} + +// Convert_storage_CSIStorageCapacity_To_v1alpha1_CSIStorageCapacity is an autogenerated conversion function. +func Convert_storage_CSIStorageCapacity_To_v1alpha1_CSIStorageCapacity(in *storage.CSIStorageCapacity, out *v1alpha1.CSIStorageCapacity, s conversion.Scope) error { + return autoConvert_storage_CSIStorageCapacity_To_v1alpha1_CSIStorageCapacity(in, out, s) +} + +func autoConvert_v1alpha1_CSIStorageCapacityList_To_storage_CSIStorageCapacityList(in *v1alpha1.CSIStorageCapacityList, out *storage.CSIStorageCapacityList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]storage.CSIStorageCapacity)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_v1alpha1_CSIStorageCapacityList_To_storage_CSIStorageCapacityList is an autogenerated conversion function. +func Convert_v1alpha1_CSIStorageCapacityList_To_storage_CSIStorageCapacityList(in *v1alpha1.CSIStorageCapacityList, out *storage.CSIStorageCapacityList, s conversion.Scope) error { + return autoConvert_v1alpha1_CSIStorageCapacityList_To_storage_CSIStorageCapacityList(in, out, s) +} + +func autoConvert_storage_CSIStorageCapacityList_To_v1alpha1_CSIStorageCapacityList(in *storage.CSIStorageCapacityList, out *v1alpha1.CSIStorageCapacityList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]v1alpha1.CSIStorageCapacity)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_storage_CSIStorageCapacityList_To_v1alpha1_CSIStorageCapacityList is an autogenerated conversion function. +func Convert_storage_CSIStorageCapacityList_To_v1alpha1_CSIStorageCapacityList(in *storage.CSIStorageCapacityList, out *v1alpha1.CSIStorageCapacityList, s conversion.Scope) error { + return autoConvert_storage_CSIStorageCapacityList_To_v1alpha1_CSIStorageCapacityList(in, out, s) +} + func autoConvert_v1alpha1_VolumeAttachment_To_storage_VolumeAttachment(in *v1alpha1.VolumeAttachment, out *storage.VolumeAttachment, s conversion.Scope) error { out.ObjectMeta = in.ObjectMeta if err := Convert_v1alpha1_VolumeAttachmentSpec_To_storage_VolumeAttachmentSpec(&in.Spec, &out.Spec, s); err != nil { @@ -181,7 +251,7 @@ func autoConvert_v1alpha1_VolumeAttachmentSource_To_storage_VolumeAttachmentSour if in.InlineVolumeSpec != nil { in, out := &in.InlineVolumeSpec, &out.InlineVolumeSpec *out = new(core.PersistentVolumeSpec) - if err := v1.Convert_v1_PersistentVolumeSpec_To_core_PersistentVolumeSpec(*in, *out, s); err != nil { + if err := corev1.Convert_v1_PersistentVolumeSpec_To_core_PersistentVolumeSpec(*in, *out, s); err != nil { return err } } else { @@ -199,8 +269,8 @@ func autoConvert_storage_VolumeAttachmentSource_To_v1alpha1_VolumeAttachmentSour out.PersistentVolumeName = (*string)(unsafe.Pointer(in.PersistentVolumeName)) if in.InlineVolumeSpec != nil { in, out := &in.InlineVolumeSpec, &out.InlineVolumeSpec - *out = new(corev1.PersistentVolumeSpec) - if err := v1.Convert_core_PersistentVolumeSpec_To_v1_PersistentVolumeSpec(*in, *out, s); err != nil { + *out = new(apicorev1.PersistentVolumeSpec) + if err := corev1.Convert_core_PersistentVolumeSpec_To_v1_PersistentVolumeSpec(*in, *out, s); err != nil { return err } } else { diff --git a/pkg/apis/storage/v1beta1/defaults.go b/pkg/apis/storage/v1beta1/defaults.go index 50cc4fe15c0..fc6e346c2ec 100644 --- a/pkg/apis/storage/v1beta1/defaults.go +++ b/pkg/apis/storage/v1beta1/defaults.go @@ -49,6 +49,10 @@ func SetDefaults_CSIDriver(obj *storagev1beta1.CSIDriver) { obj.Spec.PodInfoOnMount = new(bool) *(obj.Spec.PodInfoOnMount) = false } + if obj.Spec.StorageCapacity == nil && utilfeature.DefaultFeatureGate.Enabled(features.CSIStorageCapacity) { + obj.Spec.StorageCapacity = new(bool) + *(obj.Spec.StorageCapacity) = false + } if len(obj.Spec.VolumeLifecycleModes) == 0 && utilfeature.DefaultFeatureGate.Enabled(features.CSIInlineVolume) { obj.Spec.VolumeLifecycleModes = append(obj.Spec.VolumeLifecycleModes, storagev1beta1.VolumeLifecyclePersistent) } diff --git a/pkg/apis/storage/v1beta1/defaults_test.go b/pkg/apis/storage/v1beta1/defaults_test.go index a76efa5de24..b60641b1d46 100644 --- a/pkg/apis/storage/v1beta1/defaults_test.go +++ b/pkg/apis/storage/v1beta1/defaults_test.go @@ -85,6 +85,33 @@ func TestSetDefaultAttachRequired(t *testing.T) { } } +func TestSetDefaultStorageCapacityEnabled(t *testing.T) { + defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSIStorageCapacity, true)() + driver := &storagev1beta1.CSIDriver{} + + // field should be defaulted + defaultStorageCapacity := false + output := roundTrip(t, runtime.Object(driver)).(*storagev1beta1.CSIDriver) + outStorageCapacity := output.Spec.StorageCapacity + if outStorageCapacity == nil { + t.Errorf("Expected StorageCapacity to be defaulted to: %+v, got: nil", defaultStorageCapacity) + } else if *outStorageCapacity != defaultStorageCapacity { + t.Errorf("Expected StorageCapacity to be defaulted to: %+v, got: %+v", defaultStorageCapacity, outStorageCapacity) + } +} + +func TestSetDefaultStorageCapacityDisabled(t *testing.T) { + defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSIStorageCapacity, false)() + driver := &storagev1beta1.CSIDriver{} + + // field should not be defaulted + output := roundTrip(t, runtime.Object(driver)).(*storagev1beta1.CSIDriver) + outStorageCapacity := output.Spec.StorageCapacity + if outStorageCapacity != nil { + t.Errorf("Expected StorageCapacity to remain nil, got: %+v", outStorageCapacity) + } +} + func TestSetDefaultVolumeLifecycleModesEnabled(t *testing.T) { defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSIInlineVolume, true)() driver := &storagev1beta1.CSIDriver{} diff --git a/pkg/apis/storage/v1beta1/zz_generated.conversion.go b/pkg/apis/storage/v1beta1/zz_generated.conversion.go index 7994f458a8f..a79b8df6700 100644 --- a/pkg/apis/storage/v1beta1/zz_generated.conversion.go +++ b/pkg/apis/storage/v1beta1/zz_generated.conversion.go @@ -254,6 +254,7 @@ func autoConvert_v1beta1_CSIDriverSpec_To_storage_CSIDriverSpec(in *v1beta1.CSID out.AttachRequired = (*bool)(unsafe.Pointer(in.AttachRequired)) out.PodInfoOnMount = (*bool)(unsafe.Pointer(in.PodInfoOnMount)) out.VolumeLifecycleModes = *(*[]storage.VolumeLifecycleMode)(unsafe.Pointer(&in.VolumeLifecycleModes)) + out.StorageCapacity = (*bool)(unsafe.Pointer(in.StorageCapacity)) return nil } @@ -266,6 +267,7 @@ func autoConvert_storage_CSIDriverSpec_To_v1beta1_CSIDriverSpec(in *storage.CSID out.AttachRequired = (*bool)(unsafe.Pointer(in.AttachRequired)) out.PodInfoOnMount = (*bool)(unsafe.Pointer(in.PodInfoOnMount)) out.VolumeLifecycleModes = *(*[]v1beta1.VolumeLifecycleMode)(unsafe.Pointer(&in.VolumeLifecycleModes)) + out.StorageCapacity = (*bool)(unsafe.Pointer(in.StorageCapacity)) return nil } diff --git a/pkg/apis/storage/validation/BUILD b/pkg/apis/storage/validation/BUILD index a3f234b1ffe..02351e23c6f 100644 --- a/pkg/apis/storage/validation/BUILD +++ b/pkg/apis/storage/validation/BUILD @@ -17,6 +17,8 @@ go_library( "//pkg/apis/storage:go_default_library", "//pkg/features:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/api/equality:go_default_library", + "//staging/src/k8s.io/apimachinery/pkg/api/validation:go_default_library", + "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/validation:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/util/validation:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/util/validation/field:go_default_library", diff --git a/pkg/apis/storage/validation/validation.go b/pkg/apis/storage/validation/validation.go index b45fdea6c35..290430f4e6f 100644 --- a/pkg/apis/storage/validation/validation.go +++ b/pkg/apis/storage/validation/validation.go @@ -22,6 +22,8 @@ import ( "strings" apiequality "k8s.io/apimachinery/pkg/api/equality" + apimachineryvalidation "k8s.io/apimachinery/pkg/api/validation" + metav1validation "k8s.io/apimachinery/pkg/apis/meta/v1/validation" "k8s.io/apimachinery/pkg/util/sets" "k8s.io/apimachinery/pkg/util/validation" "k8s.io/apimachinery/pkg/util/validation/field" @@ -418,6 +420,7 @@ func validateCSIDriverSpec( allErrs := field.ErrorList{} allErrs = append(allErrs, validateAttachRequired(spec.AttachRequired, fldPath.Child("attachedRequired"))...) allErrs = append(allErrs, validatePodInfoOnMount(spec.PodInfoOnMount, fldPath.Child("podInfoOnMount"))...) + allErrs = append(allErrs, validateStorageCapacity(spec.StorageCapacity, fldPath.Child("storageCapacity"))...) allErrs = append(allErrs, validateVolumeLifecycleModes(spec.VolumeLifecycleModes, fldPath.Child("volumeLifecycleModes"))...) return allErrs } @@ -442,6 +445,16 @@ func validatePodInfoOnMount(podInfoOnMount *bool, fldPath *field.Path) field.Err return allErrs } +// validateStorageCapacity tests if storageCapacity is set for CSIDriver. +func validateStorageCapacity(storageCapacity *bool, fldPath *field.Path) field.ErrorList { + allErrs := field.ErrorList{} + if storageCapacity == nil && utilfeature.DefaultFeatureGate.Enabled(features.CSIStorageCapacity) { + allErrs = append(allErrs, field.Required(fldPath, "")) + } + + return allErrs +} + // validateVolumeLifecycleModes tests if mode has one of the allowed values. func validateVolumeLifecycleModes(modes []storage.VolumeLifecycleMode, fldPath *field.Path) field.ErrorList { allErrs := field.ErrorList{} @@ -459,3 +472,36 @@ func validateVolumeLifecycleModes(modes []storage.VolumeLifecycleMode, fldPath * return allErrs } + +// ValidateStorageCapacityName checks that a name is appropriate for a +// CSIStorageCapacity object. +var ValidateStorageCapacityName = apimachineryvalidation.NameIsDNSSubdomain + +// ValidateCSIStorageCapacity validates a CSIStorageCapacity. +func ValidateCSIStorageCapacity(capacity *storage.CSIStorageCapacity) field.ErrorList { + allErrs := apivalidation.ValidateObjectMeta(&capacity.ObjectMeta, true, ValidateStorageCapacityName, field.NewPath("metadata")) + allErrs = append(allErrs, metav1validation.ValidateLabelSelector(capacity.NodeTopology, field.NewPath("nodeTopology"))...) + for _, msg := range apivalidation.ValidateClassName(capacity.StorageClassName, false) { + allErrs = append(allErrs, field.Invalid(field.NewPath("storageClassName"), capacity.StorageClassName, msg)) + } + if capacity.Capacity != nil { + allErrs = append(allErrs, apivalidation.ValidateNonnegativeQuantity(*capacity.Capacity, field.NewPath("capacity"))...) + } + return allErrs +} + +// ValidateCSIStorageCapacityUpdate tests if an update to CSIStorageCapacity is valid. +func ValidateCSIStorageCapacityUpdate(capacity, oldCapacity *storage.CSIStorageCapacity) field.ErrorList { + allErrs := apivalidation.ValidateObjectMetaUpdate(&capacity.ObjectMeta, &oldCapacity.ObjectMeta, field.NewPath("metadata")) + + // Input fields for CSI GetCapacity are immutable. + // If this ever relaxes in the future, make sure to increment the Generation number in PrepareForUpdate + if !apiequality.Semantic.DeepEqual(capacity.NodeTopology, oldCapacity.NodeTopology) { + allErrs = append(allErrs, field.Invalid(field.NewPath("nodeTopology"), capacity.NodeTopology, "field is immutable")) + } + if capacity.StorageClassName != oldCapacity.StorageClassName { + allErrs = append(allErrs, field.Invalid(field.NewPath("storageClassName"), capacity.StorageClassName, "field is immutable")) + } + + return allErrs +} diff --git a/pkg/apis/storage/validation/validation_test.go b/pkg/apis/storage/validation/validation_test.go index 375627f43cc..d335ce89a1a 100644 --- a/pkg/apis/storage/validation/validation_test.go +++ b/pkg/apis/storage/validation/validation_test.go @@ -1939,3 +1939,104 @@ func TestCSIDriverValidationUpdate(t *testing.T) { }) } } + +func TestValidateCSIStorageCapacity(t *testing.T) { + storageClassName := "test-sc" + invalidName := "-invalid-@#$%^&*()-" + + goodCapacity := storage.CSIStorageCapacity{ + ObjectMeta: metav1.ObjectMeta{ + Name: "csc-329803da-fdd2-42e4-af6f-7b07e7ccc305", + Namespace: metav1.NamespaceDefault, + }, + StorageClassName: storageClassName, + } + goodTopology := metav1.LabelSelector{ + MatchLabels: map[string]string{"foo": "bar"}, + } + + scenarios := map[string]struct { + isExpectedFailure bool + capacity *storage.CSIStorageCapacity + }{ + "good-capacity": { + capacity: &goodCapacity, + }, + "missing-storage-class-name": { + isExpectedFailure: true, + capacity: func() *storage.CSIStorageCapacity { + capacity := goodCapacity + capacity.StorageClassName = "" + return &capacity + }(), + }, + "bad-storage-class-name": { + isExpectedFailure: true, + capacity: func() *storage.CSIStorageCapacity { + capacity := goodCapacity + capacity.StorageClassName = invalidName + return &capacity + }(), + }, + "good-capacity-value": { + capacity: func() *storage.CSIStorageCapacity { + capacity := goodCapacity + capacity.Capacity = resource.NewQuantity(1, resource.BinarySI) + return &capacity + }(), + }, + "bad-capacity-value": { + isExpectedFailure: true, + capacity: func() *storage.CSIStorageCapacity { + capacity := goodCapacity + capacity.Capacity = resource.NewQuantity(-11, resource.BinarySI) + return &capacity + }(), + }, + "good-topology": { + capacity: func() *storage.CSIStorageCapacity { + capacity := goodCapacity + capacity.NodeTopology = &goodTopology + return &capacity + }(), + }, + "empty-topology": { + capacity: func() *storage.CSIStorageCapacity { + capacity := goodCapacity + capacity.NodeTopology = &metav1.LabelSelector{} + return &capacity + }(), + }, + "bad-topology-fields": { + isExpectedFailure: true, + capacity: func() *storage.CSIStorageCapacity { + capacity := goodCapacity + capacity.NodeTopology = &metav1.LabelSelector{ + MatchExpressions: []metav1.LabelSelectorRequirement{ + { + Key: "foo", + Operator: metav1.LabelSelectorOperator("no-such-operator"), + Values: []string{ + "bar", + }, + }, + }, + } + return &capacity + }(), + }, + } + + for name, scenario := range scenarios { + t.Run(name, func(t *testing.T) { + errs := ValidateCSIStorageCapacity(scenario.capacity) + if len(errs) == 0 && scenario.isExpectedFailure { + t.Errorf("Unexpected success") + } + if len(errs) > 0 && !scenario.isExpectedFailure { + t.Errorf("Unexpected failure: %+v", errs) + } + }) + } + +} diff --git a/pkg/apis/storage/zz_generated.deepcopy.go b/pkg/apis/storage/zz_generated.deepcopy.go index 5c9ee27e278..548a63152d8 100644 --- a/pkg/apis/storage/zz_generated.deepcopy.go +++ b/pkg/apis/storage/zz_generated.deepcopy.go @@ -21,6 +21,7 @@ limitations under the License. package storage import ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" core "k8s.io/kubernetes/pkg/apis/core" ) @@ -103,6 +104,11 @@ func (in *CSIDriverSpec) DeepCopyInto(out *CSIDriverSpec) { *out = make([]VolumeLifecycleMode, len(*in)) copy(*out, *in) } + if in.StorageCapacity != nil { + in, out := &in.StorageCapacity, &out.StorageCapacity + *out = new(bool) + **out = **in + } return } @@ -225,6 +231,75 @@ func (in *CSINodeSpec) DeepCopy() *CSINodeSpec { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CSIStorageCapacity) DeepCopyInto(out *CSIStorageCapacity) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + if in.NodeTopology != nil { + in, out := &in.NodeTopology, &out.NodeTopology + *out = new(v1.LabelSelector) + (*in).DeepCopyInto(*out) + } + if in.Capacity != nil { + in, out := &in.Capacity, &out.Capacity + x := (*in).DeepCopy() + *out = &x + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CSIStorageCapacity. +func (in *CSIStorageCapacity) DeepCopy() *CSIStorageCapacity { + if in == nil { + return nil + } + out := new(CSIStorageCapacity) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *CSIStorageCapacity) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CSIStorageCapacityList) DeepCopyInto(out *CSIStorageCapacityList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]CSIStorageCapacity, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CSIStorageCapacityList. +func (in *CSIStorageCapacityList) DeepCopy() *CSIStorageCapacityList { + if in == nil { + return nil + } + out := new(CSIStorageCapacityList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *CSIStorageCapacityList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *StorageClass) DeepCopyInto(out *StorageClass) { *out = *in diff --git a/pkg/controller/volume/scheduling/BUILD b/pkg/controller/volume/scheduling/BUILD index abb112b39a1..6525c355ecd 100644 --- a/pkg/controller/volume/scheduling/BUILD +++ b/pkg/controller/volume/scheduling/BUILD @@ -17,6 +17,7 @@ go_library( "//pkg/volume/util:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library", "//staging/src/k8s.io/api/storage/v1:go_default_library", + "//staging/src/k8s.io/api/storage/v1alpha1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/api/meta:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", @@ -27,9 +28,11 @@ go_library( "//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library", "//staging/src/k8s.io/client-go/informers/core/v1:go_default_library", "//staging/src/k8s.io/client-go/informers/storage/v1:go_default_library", + "//staging/src/k8s.io/client-go/informers/storage/v1alpha1:go_default_library", "//staging/src/k8s.io/client-go/kubernetes:go_default_library", "//staging/src/k8s.io/client-go/listers/core/v1:go_default_library", "//staging/src/k8s.io/client-go/listers/storage/v1:go_default_library", + "//staging/src/k8s.io/client-go/listers/storage/v1alpha1:go_default_library", "//staging/src/k8s.io/client-go/tools/cache:go_default_library", "//staging/src/k8s.io/csi-translation-lib:go_default_library", "//staging/src/k8s.io/csi-translation-lib/plugins:go_default_library", @@ -51,6 +54,7 @@ go_test( "//pkg/features:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library", "//staging/src/k8s.io/api/storage/v1:go_default_library", + "//staging/src/k8s.io/api/storage/v1alpha1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/api/resource:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/types:go_default_library", @@ -61,6 +65,7 @@ go_test( "//staging/src/k8s.io/client-go/informers:go_default_library", "//staging/src/k8s.io/client-go/informers/core/v1:go_default_library", "//staging/src/k8s.io/client-go/informers/storage/v1:go_default_library", + "//staging/src/k8s.io/client-go/informers/storage/v1alpha1:go_default_library", "//staging/src/k8s.io/client-go/kubernetes:go_default_library", "//staging/src/k8s.io/client-go/kubernetes/fake:go_default_library", "//staging/src/k8s.io/client-go/testing:go_default_library", diff --git a/pkg/controller/volume/scheduling/scheduler_binder.go b/pkg/controller/volume/scheduling/scheduler_binder.go index 949db90e48c..5c3930614fd 100644 --- a/pkg/controller/volume/scheduling/scheduler_binder.go +++ b/pkg/controller/volume/scheduling/scheduler_binder.go @@ -25,6 +25,7 @@ import ( v1 "k8s.io/api/core/v1" storagev1 "k8s.io/api/storage/v1" + storagev1alpha1 "k8s.io/api/storage/v1alpha1" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" @@ -34,9 +35,11 @@ import ( utilfeature "k8s.io/apiserver/pkg/util/feature" coreinformers "k8s.io/client-go/informers/core/v1" storageinformers "k8s.io/client-go/informers/storage/v1" + storageinformersv1alpha1 "k8s.io/client-go/informers/storage/v1alpha1" clientset "k8s.io/client-go/kubernetes" corelisters "k8s.io/client-go/listers/core/v1" storagelisters "k8s.io/client-go/listers/storage/v1" + storagelistersv1alpha1 "k8s.io/client-go/listers/storage/v1alpha1" csitrans "k8s.io/csi-translation-lib" csiplugins "k8s.io/csi-translation-lib/plugins" "k8s.io/klog/v2" @@ -63,6 +66,8 @@ const ( ErrReasonBindConflict ConflictReason = "node(s) didn't find available persistent volumes to bind" // ErrReasonNodeConflict is used for VolumeNodeAffinityConflict predicate error. ErrReasonNodeConflict ConflictReason = "node(s) had volume node affinity conflict" + // ErrReasonNotEnoughSpace is used when a pod cannot start on a node because not enough storage space is available. + ErrReasonNotEnoughSpace = "node(s) did not have enough free storage" ) // BindingInfo holds a binding between PV and PVC. @@ -131,6 +136,9 @@ type SchedulerVolumeBinder interface { // It returns an error when something went wrong or a list of reasons why the node is // (currently) not usable for the pod. // + // If the CSIStorageCapacity feature is enabled, then it also checks for sufficient storage + // for volumes that still need to be created. + // // This function is called by the scheduler VolumeBinding plugin and can be called in parallel FindPodVolumes(pod *v1.Pod, boundClaims, claimsToBind []*v1.PersistentVolumeClaim, node *v1.Node) (podVolumes *PodVolumes, reasons ConflictReasons, err error) @@ -174,9 +182,23 @@ type volumeBinder struct { bindTimeout time.Duration translator InTreeToCSITranslator + + capacityCheckEnabled bool + csiDriverLister storagelisters.CSIDriverLister + csiStorageCapacityLister storagelistersv1alpha1.CSIStorageCapacityLister +} + +// CapacityCheck contains additional parameters for NewVolumeBinder that +// are only needed when checking volume sizes against available storage +// capacity is desired. +type CapacityCheck struct { + CSIDriverInformer storageinformers.CSIDriverInformer + CSIStorageCapacityInformer storageinformersv1alpha1.CSIStorageCapacityInformer } // NewVolumeBinder sets up all the caches needed for the scheduler to make volume binding decisions. +// +// capacityCheck determines whether storage capacity is checked (CSIStorageCapacity feature). func NewVolumeBinder( kubeClient clientset.Interface, podInformer coreinformers.PodInformer, @@ -185,8 +207,9 @@ func NewVolumeBinder( pvcInformer coreinformers.PersistentVolumeClaimInformer, pvInformer coreinformers.PersistentVolumeInformer, storageClassInformer storageinformers.StorageClassInformer, + capacityCheck *CapacityCheck, bindTimeout time.Duration) SchedulerVolumeBinder { - return &volumeBinder{ + b := &volumeBinder{ kubeClient: kubeClient, podLister: podInformer.Lister(), classLister: storageClassInformer.Lister(), @@ -197,6 +220,14 @@ func NewVolumeBinder( bindTimeout: bindTimeout, translator: csitrans.New(), } + + if capacityCheck != nil { + b.capacityCheckEnabled = true + b.csiDriverLister = capacityCheck.CSIDriverInformer.Lister() + b.csiStorageCapacityLister = capacityCheck.CSIStorageCapacityInformer.Lister() + } + + return b } // FindPodVolumes finds the matching PVs for PVCs and nodes to provision PVs @@ -214,6 +245,7 @@ func (b *volumeBinder) FindPodVolumes(pod *v1.Pod, boundClaims, claimsToBind []* // returns without an error. unboundVolumesSatisfied := true boundVolumesSatisfied := true + sufficientStorage := true defer func() { if err != nil { return @@ -224,6 +256,9 @@ func (b *volumeBinder) FindPodVolumes(pod *v1.Pod, boundClaims, claimsToBind []* if !unboundVolumesSatisfied { reasons = append(reasons, ErrReasonBindConflict) } + if !sufficientStorage { + reasons = append(reasons, ErrReasonNotEnoughSpace) + } }() start := time.Now() @@ -290,9 +325,10 @@ func (b *volumeBinder) FindPodVolumes(pod *v1.Pod, boundClaims, claimsToBind []* claimsToProvision = append(claimsToProvision, unboundClaims...) } - // Check for claims to provision + // Check for claims to provision. This is the first time where we potentially + // find out that storage is not sufficient for the node. if len(claimsToProvision) > 0 { - unboundVolumesSatisfied, dynamicProvisions, err = b.checkVolumeProvisions(pod, claimsToProvision, node) + unboundVolumesSatisfied, sufficientStorage, dynamicProvisions, err = b.checkVolumeProvisions(pod, claimsToProvision, node) if err != nil { return } @@ -787,42 +823,51 @@ func (b *volumeBinder) findMatchingVolumes(pod *v1.Pod, claimsToBind []*v1.Persi // checkVolumeProvisions checks given unbound claims (the claims have gone through func // findMatchingVolumes, and do not have matching volumes for binding), and return true // if all of the claims are eligible for dynamic provision. -func (b *volumeBinder) checkVolumeProvisions(pod *v1.Pod, claimsToProvision []*v1.PersistentVolumeClaim, node *v1.Node) (provisionSatisfied bool, dynamicProvisions []*v1.PersistentVolumeClaim, err error) { +func (b *volumeBinder) checkVolumeProvisions(pod *v1.Pod, claimsToProvision []*v1.PersistentVolumeClaim, node *v1.Node) (provisionSatisfied, sufficientStorage bool, dynamicProvisions []*v1.PersistentVolumeClaim, err error) { podName := getPodName(pod) dynamicProvisions = []*v1.PersistentVolumeClaim{} + // We return early with provisionedClaims == nil if a check + // fails or we encounter an error. for _, claim := range claimsToProvision { pvcName := getPVCName(claim) className := v1helper.GetPersistentVolumeClaimClass(claim) if className == "" { - return false, nil, fmt.Errorf("no class for claim %q", pvcName) + return false, false, nil, fmt.Errorf("no class for claim %q", pvcName) } class, err := b.classLister.Get(className) if err != nil { - return false, nil, fmt.Errorf("failed to find storage class %q", className) + return false, false, nil, fmt.Errorf("failed to find storage class %q", className) } provisioner := class.Provisioner if provisioner == "" || provisioner == pvutil.NotSupportedProvisioner { klog.V(4).Infof("storage class %q of claim %q does not support dynamic provisioning", className, pvcName) - return false, nil, nil + return false, true, nil, nil } // Check if the node can satisfy the topology requirement in the class if !v1helper.MatchTopologySelectorTerms(class.AllowedTopologies, labels.Set(node.Labels)) { klog.V(4).Infof("Node %q cannot satisfy provisioning topology requirements of claim %q", node.Name, pvcName) - return false, nil, nil + return false, true, nil, nil } - // TODO: Check if capacity of the node domain in the storage class - // can satisfy resource requirement of given claim + // Check storage capacity. + sufficient, err := b.hasEnoughCapacity(provisioner, claim, class, node) + if err != nil { + return false, false, nil, err + } + if !sufficient { + // hasEnoughCapacity logs an explanation. + return true, false, nil, nil + } dynamicProvisions = append(dynamicProvisions, claim) } klog.V(4).Infof("Provisioning for %d claims of pod %q that has no matching volumes on node %q ...", len(claimsToProvision), podName, node.Name) - return true, dynamicProvisions, nil + return true, true, dynamicProvisions, nil } func (b *volumeBinder) revertAssumedPVs(bindings []*BindingInfo) { @@ -837,6 +882,76 @@ func (b *volumeBinder) revertAssumedPVCs(claims []*v1.PersistentVolumeClaim) { } } +// hasEnoughCapacity checks whether the provisioner has enough capacity left for a new volume of the given size +// that is available from the node. +func (b *volumeBinder) hasEnoughCapacity(provisioner string, claim *v1.PersistentVolumeClaim, storageClass *storagev1.StorageClass, node *v1.Node) (bool, error) { + // This is an optional feature. If disabled, we assume that + // there is enough storage. + if !b.capacityCheckEnabled { + return true, nil + } + + quantity, ok := claim.Spec.Resources.Requests[v1.ResourceStorage] + if !ok { + // No capacity to check for. + return true, nil + } + + // Only enabled for CSI drivers which opt into it. + driver, err := b.csiDriverLister.Get(provisioner) + if err != nil { + if apierrors.IsNotFound(err) { + // Either the provisioner is not a CSI driver or the driver does not + // opt into storage capacity scheduling. Either way, skip + // capacity checking. + return true, nil + } + return false, err + } + if driver.Spec.StorageCapacity == nil || !*driver.Spec.StorageCapacity { + return true, nil + } + + // Look for a matching CSIStorageCapacity object(s). + // TODO (for beta): benchmark this and potentially introduce some kind of lookup structure (https://github.com/kubernetes/enhancements/issues/1698#issuecomment-654356718). + capacities, err := b.csiStorageCapacityLister.List(labels.Everything()) + if err != nil { + return false, err + } + + sizeInBytes := quantity.Value() + for _, capacity := range capacities { + if capacity.StorageClassName == storageClass.Name && + capacity.Capacity != nil && + capacity.Capacity.Value() >= sizeInBytes && + b.nodeHasAccess(node, capacity) { + // Enough capacity found. + return true, nil + } + } + + // TODO (?): this doesn't give any information about which pools where considered and why + // they had to be rejected. Log that above? But that might be a lot of log output... + klog.V(4).Infof("Node %q has no accessible CSIStorageCapacity with enough capacity for PVC %s/%s of size %d and storage class %q", + node.Name, claim.Namespace, claim.Name, sizeInBytes, storageClass.Name) + return false, nil +} + +func (b *volumeBinder) nodeHasAccess(node *v1.Node, capacity *storagev1alpha1.CSIStorageCapacity) bool { + if capacity.NodeTopology == nil { + // Unavailable + return false + } + // Only matching by label is supported. + selector, err := metav1.LabelSelectorAsSelector(capacity.NodeTopology) + if err != nil { + // This should never happen because NodeTopology must be valid. + klog.Errorf("unexpected error converting %+v to a label selector: %v", capacity.NodeTopology, err) + return false + } + return selector.Matches(labels.Set(node.Labels)) +} + type byPVCSize []*v1.PersistentVolumeClaim func (a byPVCSize) Len() int { diff --git a/pkg/controller/volume/scheduling/scheduler_binder_test.go b/pkg/controller/volume/scheduling/scheduler_binder_test.go index 786bc0dbe4a..93815e8f498 100644 --- a/pkg/controller/volume/scheduling/scheduler_binder_test.go +++ b/pkg/controller/volume/scheduling/scheduler_binder_test.go @@ -26,6 +26,7 @@ import ( v1 "k8s.io/api/core/v1" storagev1 "k8s.io/api/storage/v1" + storagev1alpha1 "k8s.io/api/storage/v1alpha1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" @@ -36,6 +37,7 @@ import ( "k8s.io/client-go/informers" coreinformers "k8s.io/client-go/informers/core/v1" storageinformers "k8s.io/client-go/informers/storage/v1" + storageinformersv1alpha1 "k8s.io/client-go/informers/storage/v1alpha1" clientset "k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes/fake" k8stesting "k8s.io/client-go/testing" @@ -48,6 +50,8 @@ import ( ) var ( + provisioner = "test-provisioner" + // PVCs for manual binding // TODO: clean up all of these unboundPVC = makeTestPVC("unbound-pvc", "1G", "", pvcUnbound, "", "1", &waitClass) @@ -128,9 +132,13 @@ type testEnv struct { internalCSINodeInformer storageinformers.CSINodeInformer internalPVCache *assumeCache internalPVCCache *assumeCache + + // For CSIStorageCapacity feature testing: + internalCSIDriverInformer storageinformers.CSIDriverInformer + internalCSIStorageCapacityInformer storageinformersv1alpha1.CSIStorageCapacityInformer } -func newTestBinder(t *testing.T, stopCh <-chan struct{}) *testEnv { +func newTestBinder(t *testing.T, stopCh <-chan struct{}, csiStorageCapacity ...bool) *testEnv { client := &fake.Clientset{} reactor := pvtesting.NewVolumeReactor(client, nil, nil, nil) // TODO refactor all tests to use real watch mechanism, see #72327 @@ -150,6 +158,15 @@ func newTestBinder(t *testing.T, stopCh <-chan struct{}) *testEnv { csiNodeInformer := informerFactory.Storage().V1().CSINodes() pvcInformer := informerFactory.Core().V1().PersistentVolumeClaims() classInformer := informerFactory.Storage().V1().StorageClasses() + csiDriverInformer := informerFactory.Storage().V1().CSIDrivers() + csiStorageCapacityInformer := informerFactory.Storage().V1alpha1().CSIStorageCapacities() + var capacityCheck *CapacityCheck + if len(csiStorageCapacity) > 0 && csiStorageCapacity[0] { + capacityCheck = &CapacityCheck{ + CSIDriverInformer: csiDriverInformer, + CSIStorageCapacityInformer: csiStorageCapacityInformer, + } + } binder := NewVolumeBinder( client, podInformer, @@ -158,6 +175,7 @@ func newTestBinder(t *testing.T, stopCh <-chan struct{}) *testEnv { pvcInformer, informerFactory.Core().V1().PersistentVolumes(), classInformer, + capacityCheck, 10*time.Second) // Wait for informers cache sync @@ -177,7 +195,7 @@ func newTestBinder(t *testing.T, stopCh <-chan struct{}) *testEnv { Name: waitClassWithProvisioner, }, VolumeBindingMode: &waitMode, - Provisioner: "test-provisioner", + Provisioner: provisioner, AllowedTopologies: []v1.TopologySelectorTerm{ { MatchLabelExpressions: []v1.TopologySelectorLabelRequirement{ @@ -207,7 +225,7 @@ func newTestBinder(t *testing.T, stopCh <-chan struct{}) *testEnv { Name: topoMismatchClass, }, VolumeBindingMode: &waitMode, - Provisioner: "test-provisioner", + Provisioner: provisioner, AllowedTopologies: []v1.TopologySelectorTerm{ { MatchLabelExpressions: []v1.TopologySelectorLabelRequirement{ @@ -254,6 +272,9 @@ func newTestBinder(t *testing.T, stopCh <-chan struct{}) *testEnv { internalCSINodeInformer: csiNodeInformer, internalPVCache: internalPVCache, internalPVCCache: internalPVCCache, + + internalCSIDriverInformer: csiDriverInformer, + internalCSIStorageCapacityInformer: csiStorageCapacityInformer, } } @@ -271,6 +292,18 @@ func (env *testEnv) initCSINodes(cachedCSINodes []*storagev1.CSINode) { } } +func (env *testEnv) addCSIDriver(csiDriver *storagev1.CSIDriver) { + csiDriverInformer := env.internalCSIDriverInformer.Informer() + csiDriverInformer.GetIndexer().Add(csiDriver) +} + +func (env *testEnv) addCSIStorageCapacities(capacities []*storagev1alpha1.CSIStorageCapacity) { + csiStorageCapacityInformer := env.internalCSIStorageCapacityInformer.Informer() + for _, capacity := range capacities { + csiStorageCapacityInformer.GetIndexer().Add(capacity) + } +} + func (env *testEnv) initClaims(cachedPVCs []*v1.PersistentVolumeClaim, apiPVCs []*v1.PersistentVolumeClaim) { internalPVCCache := env.internalPVCCache for _, pvc := range cachedPVCs { @@ -678,6 +711,35 @@ func makeCSINode(name, migratedPlugin string) *storagev1.CSINode { } } +func makeCSIDriver(name string, storageCapacity bool) *storagev1.CSIDriver { + return &storagev1.CSIDriver{ + ObjectMeta: metav1.ObjectMeta{ + Name: name, + }, + Spec: storagev1.CSIDriverSpec{ + StorageCapacity: &storageCapacity, + }, + } +} + +func makeCapacity(name, storageClassName string, node *v1.Node, capacityStr string) *storagev1alpha1.CSIStorageCapacity { + c := &storagev1alpha1.CSIStorageCapacity{ + ObjectMeta: metav1.ObjectMeta{ + Name: name, + }, + StorageClassName: storageClassName, + NodeTopology: &metav1.LabelSelector{}, + } + if node != nil { + c.NodeTopology.MatchLabels = map[string]string{nodeLabelKey: node.Labels[nodeLabelKey]} + } + if capacityStr != "" { + capacityQuantity := resource.MustParse(capacityStr) + c.Capacity = &capacityQuantity + } + return c +} + func makePod(pvcs []*v1.PersistentVolumeClaim) *v1.Pod { pod := &v1.Pod{ ObjectMeta: metav1.ObjectMeta{ @@ -745,6 +807,8 @@ func reasonNames(reasons ConflictReasons) string { varNames = append(varNames, "ErrReasonBindConflict") case ErrReasonNodeConflict: varNames = append(varNames, "ErrReasonNodeConflict") + case ErrReasonNotEnoughSpace: + varNames = append(varNames, "ErrReasonNotEnoughSpace") default: varNames = append(varNames, string(reason)) } @@ -897,13 +961,16 @@ func TestFindPodVolumesWithoutProvisioning(t *testing.T) { }, } - run := func(t *testing.T, scenario scenarioType) { + run := func(t *testing.T, scenario scenarioType, csiStorageCapacity bool, csiDriver *storagev1.CSIDriver) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() // Setup - testEnv := newTestBinder(t, ctx.Done()) + testEnv := newTestBinder(t, ctx.Done(), csiStorageCapacity) testEnv.initVolumes(scenario.pvs, scenario.pvs) + if csiDriver != nil { + testEnv.addCSIDriver(csiDriver) + } // a. Init pvc cache if scenario.cachePVCs == nil { @@ -930,8 +997,20 @@ func TestFindPodVolumesWithoutProvisioning(t *testing.T) { testEnv.validatePodCache(t, testNode.Name, scenario.pod, podVolumes, scenario.expectedBindings, nil) } - for name, scenario := range scenarios { - t.Run(name, func(t *testing.T) { run(t, scenario) }) + for prefix, csiStorageCapacity := range map[string]bool{"with": true, "without": false} { + t.Run(fmt.Sprintf("%s CSIStorageCapacity", prefix), func(t *testing.T) { + for description, csiDriver := range map[string]*storagev1.CSIDriver{ + "no CSIDriver": nil, + "CSIDriver with capacity tracking": makeCSIDriver(provisioner, true), + "CSIDriver without capacity tracking": makeCSIDriver(provisioner, false), + } { + t.Run(description, func(t *testing.T) { + for name, scenario := range scenarios { + t.Run(name, func(t *testing.T) { run(t, scenario, csiStorageCapacity, csiDriver) }) + } + }) + } + }) } } @@ -950,29 +1029,34 @@ func TestFindPodVolumesWithProvisioning(t *testing.T) { expectedProvisions []*v1.PersistentVolumeClaim // Expected return values - reasons ConflictReasons - shouldFail bool + reasons ConflictReasons + shouldFail bool + needsCapacity bool } scenarios := map[string]scenarioType{ "one-provisioned": { podPVCs: []*v1.PersistentVolumeClaim{provisionedPVC}, expectedProvisions: []*v1.PersistentVolumeClaim{provisionedPVC}, + needsCapacity: true, }, "two-unbound-pvcs,one-matched,one-provisioned": { podPVCs: []*v1.PersistentVolumeClaim{unboundPVC, provisionedPVC}, pvs: []*v1.PersistentVolume{pvNode1a}, expectedBindings: []*BindingInfo{makeBinding(unboundPVC, pvNode1a)}, expectedProvisions: []*v1.PersistentVolumeClaim{provisionedPVC}, + needsCapacity: true, }, "one-bound,one-provisioned": { podPVCs: []*v1.PersistentVolumeClaim{boundPVC, provisionedPVC}, pvs: []*v1.PersistentVolume{pvBound}, expectedProvisions: []*v1.PersistentVolumeClaim{provisionedPVC}, + needsCapacity: true, }, "one-binding,one-selected-node": { podPVCs: []*v1.PersistentVolumeClaim{boundPVC, selectedNodePVC}, pvs: []*v1.PersistentVolume{pvBound}, expectedProvisions: []*v1.PersistentVolumeClaim{selectedNodePVC}, + needsCapacity: true, }, "immediate-unbound-pvc": { podPVCs: []*v1.PersistentVolumeClaim{immediateUnboundPVC}, @@ -982,6 +1066,7 @@ func TestFindPodVolumesWithProvisioning(t *testing.T) { podPVCs: []*v1.PersistentVolumeClaim{immediateBoundPVC, provisionedPVC}, pvs: []*v1.PersistentVolume{pvBoundImmediate}, expectedProvisions: []*v1.PersistentVolumeClaim{provisionedPVC}, + needsCapacity: true, }, "invalid-provisioner": { podPVCs: []*v1.PersistentVolumeClaim{noProvisionerPVC}, @@ -1002,13 +1087,16 @@ func TestFindPodVolumesWithProvisioning(t *testing.T) { }, } - run := func(t *testing.T, scenario scenarioType) { + run := func(t *testing.T, scenario scenarioType, csiStorageCapacity bool, csiDriver *storagev1.CSIDriver) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() // Setup - testEnv := newTestBinder(t, ctx.Done()) + testEnv := newTestBinder(t, ctx.Done(), csiStorageCapacity) testEnv.initVolumes(scenario.pvs, scenario.pvs) + if csiDriver != nil { + testEnv.addCSIDriver(csiDriver) + } // a. Init pvc cache if scenario.cachePVCs == nil { @@ -1031,12 +1119,32 @@ func TestFindPodVolumesWithProvisioning(t *testing.T) { if scenario.shouldFail && err == nil { t.Error("returned success but expected error") } - checkReasons(t, reasons, scenario.reasons) - testEnv.validatePodCache(t, testNode.Name, scenario.pod, podVolumes, scenario.expectedBindings, scenario.expectedProvisions) + expectedReasons := scenario.reasons + expectedProvisions := scenario.expectedProvisions + if scenario.needsCapacity && csiStorageCapacity && + csiDriver != nil && csiDriver.Spec.StorageCapacity != nil && *csiDriver.Spec.StorageCapacity { + // Without CSIStorageCapacity objects, provisioning is blocked. + expectedReasons = append(expectedReasons, ErrReasonNotEnoughSpace) + expectedProvisions = nil + } + checkReasons(t, reasons, expectedReasons) + testEnv.validatePodCache(t, testNode.Name, scenario.pod, podVolumes, scenario.expectedBindings, expectedProvisions) } - for name, scenario := range scenarios { - t.Run(name, func(t *testing.T) { run(t, scenario) }) + for prefix, csiStorageCapacity := range map[string]bool{"with": true, "without": false} { + t.Run(fmt.Sprintf("%s CSIStorageCapacity", prefix), func(t *testing.T) { + for description, csiDriver := range map[string]*storagev1.CSIDriver{ + "no CSIDriver": nil, + "CSIDriver with capacity tracking": makeCSIDriver(provisioner, true), + "CSIDriver without capacity tracking": makeCSIDriver(provisioner, false), + } { + t.Run(description, func(t *testing.T) { + for name, scenario := range scenarios { + t.Run(name, func(t *testing.T) { run(t, scenario, csiStorageCapacity, csiDriver) }) + } + }) + } + }) } } @@ -2008,3 +2116,125 @@ func TestFindAssumeVolumes(t *testing.T) { testEnv.validatePodCache(t, testNode.Name, pod, podVolumes, expectedBindings, nil) } } + +// TestCapacity covers different scenarios involving CSIStorageCapacity objects. +// Scenarios without those are covered by TestFindPodVolumesWithProvisioning. +func TestCapacity(t *testing.T) { + type scenarioType struct { + // Inputs + pvcs []*v1.PersistentVolumeClaim + capacities []*storagev1alpha1.CSIStorageCapacity + + // Expected return values + reasons ConflictReasons + shouldFail bool + } + scenarios := map[string]scenarioType{ + "network-attached": { + pvcs: []*v1.PersistentVolumeClaim{provisionedPVC}, + capacities: []*storagev1alpha1.CSIStorageCapacity{ + makeCapacity("net", waitClassWithProvisioner, nil, "1Gi"), + }, + }, + "local-storage": { + pvcs: []*v1.PersistentVolumeClaim{provisionedPVC}, + capacities: []*storagev1alpha1.CSIStorageCapacity{ + makeCapacity("net", waitClassWithProvisioner, node1, "1Gi"), + }, + }, + "multiple": { + pvcs: []*v1.PersistentVolumeClaim{provisionedPVC}, + capacities: []*storagev1alpha1.CSIStorageCapacity{ + makeCapacity("net", waitClassWithProvisioner, nil, "1Gi"), + makeCapacity("net", waitClassWithProvisioner, node2, "1Gi"), + makeCapacity("net", waitClassWithProvisioner, node1, "1Gi"), + }, + }, + "no-storage": { + pvcs: []*v1.PersistentVolumeClaim{provisionedPVC}, + reasons: ConflictReasons{ErrReasonNotEnoughSpace}, + }, + "wrong-node": { + pvcs: []*v1.PersistentVolumeClaim{provisionedPVC}, + capacities: []*storagev1alpha1.CSIStorageCapacity{ + makeCapacity("net", waitClassWithProvisioner, node2, "1Gi"), + }, + reasons: ConflictReasons{ErrReasonNotEnoughSpace}, + }, + "wrong-storage-class": { + pvcs: []*v1.PersistentVolumeClaim{provisionedPVC}, + capacities: []*storagev1alpha1.CSIStorageCapacity{ + makeCapacity("net", waitClass, node1, "1Gi"), + }, + reasons: ConflictReasons{ErrReasonNotEnoughSpace}, + }, + "insufficient-storage": { + pvcs: []*v1.PersistentVolumeClaim{provisionedPVC}, + capacities: []*storagev1alpha1.CSIStorageCapacity{ + makeCapacity("net", waitClassWithProvisioner, node1, "1Mi"), + }, + reasons: ConflictReasons{ErrReasonNotEnoughSpace}, + }, + "zero-storage": { + pvcs: []*v1.PersistentVolumeClaim{provisionedPVC}, + capacities: []*storagev1alpha1.CSIStorageCapacity{ + makeCapacity("net", waitClassWithProvisioner, node1, "0Mi"), + }, + reasons: ConflictReasons{ErrReasonNotEnoughSpace}, + }, + "nil-storage": { + pvcs: []*v1.PersistentVolumeClaim{provisionedPVC}, + capacities: []*storagev1alpha1.CSIStorageCapacity{ + makeCapacity("net", waitClassWithProvisioner, node1, ""), + }, + reasons: ConflictReasons{ErrReasonNotEnoughSpace}, + }, + } + + testNode := &v1.Node{ + ObjectMeta: metav1.ObjectMeta{ + Name: "node1", + Labels: map[string]string{ + nodeLabelKey: "node1", + }, + }, + } + + run := func(t *testing.T, scenario scenarioType) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + // Setup + withCSIStorageCapacity := true + testEnv := newTestBinder(t, ctx.Done(), withCSIStorageCapacity) + testEnv.addCSIDriver(makeCSIDriver(provisioner, withCSIStorageCapacity)) + testEnv.addCSIStorageCapacities(scenario.capacities) + + // a. Init pvc cache + testEnv.initClaims(scenario.pvcs, scenario.pvcs) + + // b. Generate pod with given claims + pod := makePod(scenario.pvcs) + + // Execute + podVolumes, reasons, err := findPodVolumes(testEnv.binder, pod, testNode) + + // Validate + if !scenario.shouldFail && err != nil { + t.Errorf("returned error: %v", err) + } + if scenario.shouldFail && err == nil { + t.Error("returned success but expected error") + } + checkReasons(t, reasons, scenario.reasons) + provisions := scenario.pvcs + if len(reasons) > 0 { + provisions = nil + } + testEnv.validatePodCache(t, pod.Spec.NodeName, pod, podVolumes, nil, provisions) + } + + for name, scenario := range scenarios { + t.Run(name, func(t *testing.T) { run(t, scenario) }) + } +} diff --git a/pkg/features/kube_features.go b/pkg/features/kube_features.go index a8482c78d4a..563789ece2e 100644 --- a/pkg/features/kube_features.go +++ b/pkg/features/kube_features.go @@ -293,6 +293,12 @@ const ( // Enables CSI Inline volumes support for pods CSIInlineVolume featuregate.Feature = "CSIInlineVolume" + // owner: @pohly + // alpha: v1.19 + // + // Enables tracking of available storage capacity that CSI drivers provide. + CSIStorageCapacity featuregate.Feature = "CSIStorageCapacity" + // owner: @alculquicondor // alpha: v1.19 // @@ -664,6 +670,7 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS BalanceAttachedNodeVolumes: {Default: false, PreRelease: featuregate.Alpha}, CSIBlockVolume: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.20 CSIInlineVolume: {Default: true, PreRelease: featuregate.Beta}, + CSIStorageCapacity: {Default: false, PreRelease: featuregate.Alpha}, RuntimeClass: {Default: true, PreRelease: featuregate.Beta}, NodeLease: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, SCTPSupport: {Default: true, PreRelease: featuregate.Beta}, diff --git a/pkg/kubeapiserver/default_storage_factory_builder.go b/pkg/kubeapiserver/default_storage_factory_builder.go index 35e8ef16207..eaf38a5fe38 100644 --- a/pkg/kubeapiserver/default_storage_factory_builder.go +++ b/pkg/kubeapiserver/default_storage_factory_builder.go @@ -57,6 +57,7 @@ func NewStorageFactoryConfig() *StorageFactoryConfig { networking.Resource("ingresses").WithVersion("v1beta1"), networking.Resource("ingressclasses").WithVersion("v1beta1"), apisstorage.Resource("csidrivers").WithVersion("v1beta1"), + apisstorage.Resource("csistoragecapacities").WithVersion("v1alpha1"), } return &StorageFactoryConfig{ diff --git a/pkg/printers/internalversion/BUILD b/pkg/printers/internalversion/BUILD index 729c906cf76..dae3120f513 100644 --- a/pkg/printers/internalversion/BUILD +++ b/pkg/printers/internalversion/BUILD @@ -80,6 +80,7 @@ go_library( "//pkg/apis/storage:go_default_library", "//pkg/apis/storage/install:go_default_library", "//pkg/apis/storage/util:go_default_library", + "//pkg/features:go_default_library", "//pkg/printers:go_default_library", "//pkg/util/node:go_default_library", "//staging/src/k8s.io/api/apps/v1beta1:go_default_library", @@ -96,12 +97,14 @@ go_library( "//staging/src/k8s.io/api/rbac/v1beta1:go_default_library", "//staging/src/k8s.io/api/scheduling/v1:go_default_library", "//staging/src/k8s.io/api/storage/v1:go_default_library", + "//staging/src/k8s.io/api/storage/v1alpha1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/labels:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/util/duration:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library", + "//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library", ], ) diff --git a/pkg/printers/internalversion/printers.go b/pkg/printers/internalversion/printers.go index ac58d853bbb..f31be801dae 100644 --- a/pkg/printers/internalversion/printers.go +++ b/pkg/printers/internalversion/printers.go @@ -39,12 +39,14 @@ import ( rbacv1beta1 "k8s.io/api/rbac/v1beta1" schedulingv1 "k8s.io/api/scheduling/v1" storagev1 "k8s.io/api/storage/v1" + storagev1alpha1 "k8s.io/api/storage/v1alpha1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/util/duration" "k8s.io/apimachinery/pkg/util/sets" + utilfeature "k8s.io/apiserver/pkg/util/feature" "k8s.io/kubernetes/pkg/apis/admissionregistration" "k8s.io/kubernetes/pkg/apis/apps" "k8s.io/kubernetes/pkg/apis/autoscaling" @@ -63,6 +65,7 @@ import ( "k8s.io/kubernetes/pkg/apis/scheduling" "k8s.io/kubernetes/pkg/apis/storage" storageutil "k8s.io/kubernetes/pkg/apis/storage/util" + "k8s.io/kubernetes/pkg/features" "k8s.io/kubernetes/pkg/printers" "k8s.io/kubernetes/pkg/util/node" ) @@ -509,12 +512,27 @@ func AddHandlers(h printers.PrintHandler) { {Name: "Name", Type: "string", Format: "name", Description: metav1.ObjectMeta{}.SwaggerDoc()["name"]}, {Name: "AttachRequired", Type: "boolean", Description: storagev1.CSIDriverSpec{}.SwaggerDoc()["attachRequired"]}, {Name: "PodInfoOnMount", Type: "boolean", Description: storagev1.CSIDriverSpec{}.SwaggerDoc()["podInfoOnMount"]}, + } + if utilfeature.DefaultFeatureGate.Enabled(features.CSIStorageCapacity) { + csiDriverColumnDefinitions = append(csiDriverColumnDefinitions, metav1.TableColumnDefinition{ + Name: "StorageCapacity", Type: "boolean", Description: storagev1.CSIDriverSpec{}.SwaggerDoc()["storageCapacity"], + }) + } + csiDriverColumnDefinitions = append(csiDriverColumnDefinitions, []metav1.TableColumnDefinition{ {Name: "Modes", Type: "string", Description: storagev1.CSIDriverSpec{}.SwaggerDoc()["volumeLifecycleModes"]}, {Name: "Age", Type: "string", Description: metav1.ObjectMeta{}.SwaggerDoc()["creationTimestamp"]}, - } + }...) h.TableHandler(csiDriverColumnDefinitions, printCSIDriver) h.TableHandler(csiDriverColumnDefinitions, printCSIDriverList) + csiStorageCapacityColumnDefinitions := []metav1.TableColumnDefinition{ + {Name: "Name", Type: "string", Format: "name", Description: metav1.ObjectMeta{}.SwaggerDoc()["name"]}, + {Name: "StorageClassName", Type: "string", Description: storagev1alpha1.CSIStorageCapacity{}.SwaggerDoc()["storageClassName"]}, + {Name: "Capacity", Type: "string", Description: storagev1alpha1.CSIStorageCapacity{}.SwaggerDoc()["capacity"]}, + } + h.TableHandler(csiStorageCapacityColumnDefinitions, printCSIStorageCapacity) + h.TableHandler(csiStorageCapacityColumnDefinitions, printCSIStorageCapacityList) + mutatingWebhookColumnDefinitions := []metav1.TableColumnDefinition{ {Name: "Name", Type: "string", Format: "name", Description: metav1.ObjectMeta{}.SwaggerDoc()["name"]}, {Name: "Webhooks", Type: "integer", Description: "Webhooks indicates the number of webhooks registered in this configuration"}, @@ -1357,7 +1375,15 @@ func printCSIDriver(obj *storage.CSIDriver, options printers.GenerateOptions) ([ modes = "" } - row.Cells = append(row.Cells, obj.Name, attachRequired, podInfoOnMount, modes, translateTimestampSince(obj.CreationTimestamp)) + row.Cells = append(row.Cells, obj.Name, attachRequired, podInfoOnMount) + if utilfeature.DefaultFeatureGate.Enabled(features.CSIStorageCapacity) { + storageCapacity := false + if obj.Spec.StorageCapacity != nil { + storageCapacity = *obj.Spec.StorageCapacity + } + row.Cells = append(row.Cells, storageCapacity) + } + row.Cells = append(row.Cells, modes, translateTimestampSince(obj.CreationTimestamp)) return []metav1.TableRow{row}, nil } @@ -1373,6 +1399,32 @@ func printCSIDriverList(list *storage.CSIDriverList, options printers.GenerateOp return rows, nil } +func printCSIStorageCapacity(obj *storage.CSIStorageCapacity, options printers.GenerateOptions) ([]metav1.TableRow, error) { + row := metav1.TableRow{ + Object: runtime.RawExtension{Object: obj}, + } + + capacity := "" + if obj.Capacity != nil { + capacity = obj.Capacity.String() + } + + row.Cells = append(row.Cells, obj.Name, obj.StorageClassName, capacity) + return []metav1.TableRow{row}, nil +} + +func printCSIStorageCapacityList(list *storage.CSIStorageCapacityList, options printers.GenerateOptions) ([]metav1.TableRow, error) { + rows := make([]metav1.TableRow, 0, len(list.Items)) + for i := range list.Items { + r, err := printCSIStorageCapacity(&list.Items[i], options) + if err != nil { + return nil, err + } + rows = append(rows, r...) + } + return rows, nil +} + func printMutatingWebhook(obj *admissionregistration.MutatingWebhookConfiguration, options printers.GenerateOptions) ([]metav1.TableRow, error) { row := metav1.TableRow{ Object: runtime.RawExtension{Object: obj}, diff --git a/pkg/registry/BUILD b/pkg/registry/BUILD index 8369d75ec5c..bced397da5b 100644 --- a/pkg/registry/BUILD +++ b/pkg/registry/BUILD @@ -91,6 +91,7 @@ filegroup( "//pkg/registry/settings/rest:all-srcs", "//pkg/registry/storage/csidriver:all-srcs", "//pkg/registry/storage/csinode:all-srcs", + "//pkg/registry/storage/csistoragecapacity:all-srcs", "//pkg/registry/storage/rest:all-srcs", "//pkg/registry/storage/storageclass:all-srcs", "//pkg/registry/storage/volumeattachment:all-srcs", diff --git a/pkg/registry/storage/csidriver/strategy.go b/pkg/registry/storage/csidriver/strategy.go index a968fcbaf17..f406ef55885 100644 --- a/pkg/registry/storage/csidriver/strategy.go +++ b/pkg/registry/storage/csidriver/strategy.go @@ -43,8 +43,12 @@ func (csiDriverStrategy) NamespaceScoped() bool { return false } -// PrepareForCreate clears the VolumeLifecycleModes field if the corresponding feature is disabled. +// PrepareForCreate clears the fields for which the corresponding feature is disabled. func (csiDriverStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) { + if !utilfeature.DefaultFeatureGate.Enabled(features.CSIStorageCapacity) { + csiDriver := obj.(*storage.CSIDriver) + csiDriver.Spec.StorageCapacity = nil + } if !utilfeature.DefaultFeatureGate.Enabled(features.CSIInlineVolume) { csiDriver := obj.(*storage.CSIDriver) csiDriver.Spec.VolumeLifecycleModes = nil @@ -68,10 +72,15 @@ func (csiDriverStrategy) AllowCreateOnUpdate() bool { return false } -// PrepareForUpdate clears the VolumeLifecycleModes field if the corresponding feature is disabled and +// PrepareForUpdate clears the fields for which the corresponding feature is disabled and // existing object does not already have that field set. This allows the field to remain when // downgrading to a version that has the feature disabled. func (csiDriverStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) { + if old.(*storage.CSIDriver).Spec.StorageCapacity == nil && + !utilfeature.DefaultFeatureGate.Enabled(features.CSIStorageCapacity) { + newCSIDriver := obj.(*storage.CSIDriver) + newCSIDriver.Spec.StorageCapacity = nil + } if old.(*storage.CSIDriver).Spec.VolumeLifecycleModes == nil && !utilfeature.DefaultFeatureGate.Enabled(features.CSIInlineVolume) { newCSIDriver := obj.(*storage.CSIDriver) diff --git a/pkg/registry/storage/csidriver/strategy_test.go b/pkg/registry/storage/csidriver/strategy_test.go index 7da19925dde..3088fb85694 100644 --- a/pkg/registry/storage/csidriver/strategy_test.go +++ b/pkg/registry/storage/csidriver/strategy_test.go @@ -30,15 +30,15 @@ import ( ) func getValidCSIDriver(name string) *storage.CSIDriver { - attachRequired := true - podInfoOnMount := true + enabled := true return &storage.CSIDriver{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, Spec: storage.CSIDriverSpec{ - AttachRequired: &attachRequired, - PodInfoOnMount: &podInfoOnMount, + AttachRequired: &enabled, + PodInfoOnMount: &enabled, + StorageCapacity: &enabled, }, } } @@ -87,22 +87,12 @@ func TestCSIDriverPrepareForCreate(t *testing.T) { attachRequired := true podInfoOnMount := true - csiDriver := &storage.CSIDriver{ - ObjectMeta: metav1.ObjectMeta{ - Name: "foo", - }, - Spec: storage.CSIDriverSpec{ - AttachRequired: &attachRequired, - PodInfoOnMount: &podInfoOnMount, - VolumeLifecycleModes: []storage.VolumeLifecycleMode{ - storage.VolumeLifecyclePersistent, - }, - }, - } + storageCapacity := true tests := []struct { - name string - withInline bool + name string + withCapacity bool + withInline bool }{ { name: "inline enabled", @@ -112,17 +102,48 @@ func TestCSIDriverPrepareForCreate(t *testing.T) { name: "inline disabled", withInline: false, }, + { + name: "capacity enabled", + withCapacity: true, + }, + { + name: "capacity disabled", + withCapacity: false, + }, } for _, test := range tests { t.Run(test.name, func(t *testing.T) { + defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSIStorageCapacity, test.withCapacity)() defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSIInlineVolume, test.withInline)() + csiDriver := &storage.CSIDriver{ + ObjectMeta: metav1.ObjectMeta{ + Name: "foo", + }, + Spec: storage.CSIDriverSpec{ + AttachRequired: &attachRequired, + PodInfoOnMount: &podInfoOnMount, + StorageCapacity: &storageCapacity, + VolumeLifecycleModes: []storage.VolumeLifecycleMode{ + storage.VolumeLifecyclePersistent, + }, + }, + } Strategy.PrepareForCreate(ctx, csiDriver) errs := Strategy.Validate(ctx, csiDriver) if len(errs) != 0 { t.Errorf("unexpected validating errors: %v", errs) } + if test.withCapacity { + if csiDriver.Spec.StorageCapacity == nil || *csiDriver.Spec.StorageCapacity != storageCapacity { + t.Errorf("StorageCapacity modified: %v", csiDriver.Spec.StorageCapacity) + } + } else { + if csiDriver.Spec.StorageCapacity != nil { + t.Errorf("StorageCapacity not stripped: %v", csiDriver.Spec.StorageCapacity) + } + } if test.withInline { if len(csiDriver.Spec.VolumeLifecycleModes) != 1 { t.Errorf("VolumeLifecycleModes modified: %v", csiDriver.Spec) @@ -178,15 +199,69 @@ func TestCSIDriverPrepareForUpdate(t *testing.T) { }, }, } + enabled := true + disabled := false + driverWithoutCapacity := &storage.CSIDriver{ + ObjectMeta: metav1.ObjectMeta{ + Name: "foo", + }, + } + driverWithCapacityEnabled := &storage.CSIDriver{ + ObjectMeta: metav1.ObjectMeta{ + Name: "foo", + }, + Spec: storage.CSIDriverSpec{ + StorageCapacity: &enabled, + }, + } + driverWithCapacityDisabled := &storage.CSIDriver{ + ObjectMeta: metav1.ObjectMeta{ + Name: "foo", + }, + Spec: storage.CSIDriverSpec{ + StorageCapacity: &disabled, + }, + } + var resultEmpty []storage.VolumeLifecycleMode resultPersistent := []storage.VolumeLifecycleMode{storage.VolumeLifecyclePersistent} resultEphemeral := []storage.VolumeLifecycleMode{storage.VolumeLifecycleEphemeral} tests := []struct { - name string - old, update *storage.CSIDriver - withInline, withoutInline []storage.VolumeLifecycleMode + name string + old, update *storage.CSIDriver + withCapacity, withoutCapacity *bool + withInline, withoutInline []storage.VolumeLifecycleMode }{ + { + name: "before: no capacity, update: no capacity", + old: driverWithoutCapacity, + update: driverWithoutCapacity, + withCapacity: nil, + withoutCapacity: nil, + }, + { + name: "before: no capacity, update: enabled", + old: driverWithoutCapacity, + update: driverWithCapacityEnabled, + withCapacity: &enabled, + withoutCapacity: nil, + }, + { + name: "before: capacity enabled, update: disabled", + old: driverWithCapacityEnabled, + update: driverWithCapacityDisabled, + withCapacity: &disabled, + withoutCapacity: &disabled, + }, + { + name: "before: capacity enabled, update: no capacity", + old: driverWithCapacityEnabled, + update: driverWithoutCapacity, + withCapacity: nil, + withoutCapacity: nil, + }, + { name: "before: no mode, update: no mode", old: driverWithoutModes, @@ -217,35 +292,46 @@ func TestCSIDriverPrepareForUpdate(t *testing.T) { }, } - runAll := func(t *testing.T, withInline bool) { + runAll := func(t *testing.T, withCapacity, withInline bool) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { + defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSIStorageCapacity, withCapacity)() defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSIInlineVolume, withInline)() csiDriver := test.update.DeepCopy() Strategy.PrepareForUpdate(ctx, csiDriver, test.old) - if withInline { - require.Equal(t, csiDriver.Spec.VolumeLifecycleModes, test.withInline) + if withCapacity { + require.Equal(t, test.withCapacity, csiDriver.Spec.StorageCapacity) } else { - require.Equal(t, csiDriver.Spec.VolumeLifecycleModes, test.withoutInline) + require.Equal(t, test.withoutCapacity, csiDriver.Spec.StorageCapacity) + } + if withInline { + require.Equal(t, test.withInline, csiDriver.Spec.VolumeLifecycleModes) + } else { + require.Equal(t, test.withoutInline, csiDriver.Spec.VolumeLifecycleModes) } }) } } + t.Run("with capacity", func(t *testing.T) { + runAll(t, true, false) + }) + t.Run("without capacity", func(t *testing.T) { + runAll(t, false, false) + }) + t.Run("with inline volumes", func(t *testing.T) { - runAll(t, true) + runAll(t, false, true) }) t.Run("without inline volumes", func(t *testing.T) { - runAll(t, false) + runAll(t, false, false) }) } func TestCSIDriverValidation(t *testing.T) { - attachRequired := true - notAttachRequired := false - podInfoOnMount := true - notPodInfoOnMount := false + enabled := true + disabled := true tests := []struct { name string @@ -258,27 +344,29 @@ func TestCSIDriverValidation(t *testing.T) { false, }, { - "true PodInfoOnMount and AttachRequired", + "true for all flags", &storage.CSIDriver{ ObjectMeta: metav1.ObjectMeta{ Name: "foo", }, Spec: storage.CSIDriverSpec{ - AttachRequired: &attachRequired, - PodInfoOnMount: &podInfoOnMount, + AttachRequired: &enabled, + PodInfoOnMount: &enabled, + StorageCapacity: &enabled, }, }, false, }, { - "false PodInfoOnMount and AttachRequired", + "false for all flags", &storage.CSIDriver{ ObjectMeta: metav1.ObjectMeta{ Name: "foo", }, Spec: storage.CSIDriverSpec{ - AttachRequired: ¬AttachRequired, - PodInfoOnMount: ¬PodInfoOnMount, + AttachRequired: &disabled, + PodInfoOnMount: &disabled, + StorageCapacity: &disabled, }, }, false, @@ -290,8 +378,9 @@ func TestCSIDriverValidation(t *testing.T) { Name: "*foo#", }, Spec: storage.CSIDriverSpec{ - AttachRequired: &attachRequired, - PodInfoOnMount: &podInfoOnMount, + AttachRequired: &enabled, + PodInfoOnMount: &enabled, + StorageCapacity: &enabled, }, }, true, @@ -303,8 +392,9 @@ func TestCSIDriverValidation(t *testing.T) { Name: "foo", }, Spec: storage.CSIDriverSpec{ - AttachRequired: &attachRequired, - PodInfoOnMount: &podInfoOnMount, + AttachRequired: &enabled, + PodInfoOnMount: &enabled, + StorageCapacity: &enabled, VolumeLifecycleModes: []storage.VolumeLifecycleMode{ storage.VolumeLifecycleMode("no-such-mode"), }, @@ -319,8 +409,9 @@ func TestCSIDriverValidation(t *testing.T) { Name: "foo", }, Spec: storage.CSIDriverSpec{ - AttachRequired: &attachRequired, - PodInfoOnMount: &podInfoOnMount, + AttachRequired: &enabled, + PodInfoOnMount: &enabled, + StorageCapacity: &enabled, VolumeLifecycleModes: []storage.VolumeLifecycleMode{ storage.VolumeLifecyclePersistent, }, @@ -335,8 +426,9 @@ func TestCSIDriverValidation(t *testing.T) { Name: "foo", }, Spec: storage.CSIDriverSpec{ - AttachRequired: &attachRequired, - PodInfoOnMount: &podInfoOnMount, + AttachRequired: &enabled, + PodInfoOnMount: &enabled, + StorageCapacity: &enabled, VolumeLifecycleModes: []storage.VolumeLifecycleMode{ storage.VolumeLifecycleEphemeral, }, @@ -351,8 +443,9 @@ func TestCSIDriverValidation(t *testing.T) { Name: "foo", }, Spec: storage.CSIDriverSpec{ - AttachRequired: &attachRequired, - PodInfoOnMount: &podInfoOnMount, + AttachRequired: &enabled, + PodInfoOnMount: &enabled, + StorageCapacity: &enabled, VolumeLifecycleModes: []storage.VolumeLifecycleMode{ storage.VolumeLifecyclePersistent, storage.VolumeLifecycleEphemeral, diff --git a/pkg/registry/storage/csistoragecapacity/BUILD b/pkg/registry/storage/csistoragecapacity/BUILD new file mode 100644 index 00000000000..fe95c84fca6 --- /dev/null +++ b/pkg/registry/storage/csistoragecapacity/BUILD @@ -0,0 +1,53 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "go_default_library", + srcs = [ + "doc.go", + "strategy.go", + ], + importpath = "k8s.io/kubernetes/pkg/registry/storage/csistoragecapacity", + visibility = ["//visibility:public"], + deps = [ + "//pkg/api/legacyscheme:go_default_library", + "//pkg/apis/storage:go_default_library", + "//pkg/apis/storage/validation:go_default_library", + "//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library", + "//staging/src/k8s.io/apimachinery/pkg/util/validation/field:go_default_library", + "//staging/src/k8s.io/apiserver/pkg/storage/names:go_default_library", + ], +) + +go_test( + name = "go_default_test", + srcs = ["strategy_test.go"], + embed = [":go_default_library"], + deps = [ + "//pkg/apis/storage:go_default_library", + "//pkg/features:go_default_library", + "//staging/src/k8s.io/apimachinery/pkg/api/equality:go_default_library", + "//staging/src/k8s.io/apimachinery/pkg/api/resource:go_default_library", + "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", + "//staging/src/k8s.io/apimachinery/pkg/util/diff:go_default_library", + "//staging/src/k8s.io/apiserver/pkg/endpoints/request:go_default_library", + "//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library", + "//staging/src/k8s.io/component-base/featuregate/testing:go_default_library", + ], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [ + ":package-srcs", + "//pkg/registry/storage/csistoragecapacity/storage:all-srcs", + ], + tags = ["automanaged"], + visibility = ["//visibility:public"], +) diff --git a/pkg/registry/storage/csistoragecapacity/doc.go b/pkg/registry/storage/csistoragecapacity/doc.go new file mode 100644 index 00000000000..3b99e2cf6bf --- /dev/null +++ b/pkg/registry/storage/csistoragecapacity/doc.go @@ -0,0 +1,19 @@ +/* +Copyright 2020 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 csistoragecapacity provides Registry interface and its REST +// implementation for storing csistoragecapacity api objects. +package csistoragecapacity diff --git a/pkg/registry/storage/csistoragecapacity/storage/BUILD b/pkg/registry/storage/csistoragecapacity/storage/BUILD new file mode 100644 index 00000000000..d66268f11e2 --- /dev/null +++ b/pkg/registry/storage/csistoragecapacity/storage/BUILD @@ -0,0 +1,49 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "go_default_library", + srcs = ["storage.go"], + importpath = "k8s.io/kubernetes/pkg/registry/storage/csistoragecapacity/storage", + visibility = ["//visibility:public"], + deps = [ + "//pkg/apis/storage:go_default_library", + "//pkg/registry/storage/csistoragecapacity:go_default_library", + "//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library", + "//staging/src/k8s.io/apiserver/pkg/registry/generic:go_default_library", + "//staging/src/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library", + "//staging/src/k8s.io/apiserver/pkg/registry/rest:go_default_library", + ], +) + +go_test( + name = "go_default_test", + srcs = ["storage_test.go"], + embed = [":go_default_library"], + deps = [ + "//pkg/apis/storage:go_default_library", + "//pkg/apis/storage/install:go_default_library", + "//pkg/registry/registrytest:go_default_library", + "//staging/src/k8s.io/apimachinery/pkg/api/resource:go_default_library", + "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", + "//staging/src/k8s.io/apimachinery/pkg/fields:go_default_library", + "//staging/src/k8s.io/apimachinery/pkg/labels:go_default_library", + "//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library", + "//staging/src/k8s.io/apiserver/pkg/registry/generic:go_default_library", + "//staging/src/k8s.io/apiserver/pkg/registry/generic/testing:go_default_library", + "//staging/src/k8s.io/apiserver/pkg/storage/etcd3/testing:go_default_library", + ], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [":package-srcs"], + tags = ["automanaged"], + visibility = ["//visibility:public"], +) diff --git a/pkg/registry/storage/csistoragecapacity/storage/storage.go b/pkg/registry/storage/csistoragecapacity/storage/storage.go new file mode 100644 index 00000000000..b638d96b0f0 --- /dev/null +++ b/pkg/registry/storage/csistoragecapacity/storage/storage.go @@ -0,0 +1,59 @@ +/* +Copyright 2020 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 storage + +import ( + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apiserver/pkg/registry/generic" + genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" + "k8s.io/apiserver/pkg/registry/rest" + storageapi "k8s.io/kubernetes/pkg/apis/storage" + "k8s.io/kubernetes/pkg/registry/storage/csistoragecapacity" +) + +// CSIStorageCapacityStorage includes storage for CSIStorageCapacity and all subresources +type CSIStorageCapacityStorage struct { + CSIStorageCapacity *REST +} + +// REST object that will work for CSIStorageCapacity +type REST struct { + *genericregistry.Store +} + +// NewStorage returns a RESTStorage object that will work against CSIStorageCapacity +func NewStorage(optsGetter generic.RESTOptionsGetter) (*CSIStorageCapacityStorage, error) { + store := &genericregistry.Store{ + NewFunc: func() runtime.Object { return &storageapi.CSIStorageCapacity{} }, + NewListFunc: func() runtime.Object { return &storageapi.CSIStorageCapacityList{} }, + DefaultQualifiedResource: storageapi.Resource("csistoragecapacities"), + + TableConvertor: rest.NewDefaultTableConvertor(storageapi.Resource("csistoragecapacities")), + + CreateStrategy: csistoragecapacity.Strategy, + UpdateStrategy: csistoragecapacity.Strategy, + DeleteStrategy: csistoragecapacity.Strategy, + } + options := &generic.StoreOptions{RESTOptions: optsGetter} + if err := store.CompleteWithOptions(options); err != nil { + return nil, err + } + + return &CSIStorageCapacityStorage{ + CSIStorageCapacity: &REST{store}, + }, nil +} diff --git a/pkg/registry/storage/csistoragecapacity/storage/storage_test.go b/pkg/registry/storage/csistoragecapacity/storage/storage_test.go new file mode 100644 index 00000000000..4e0f536c0d4 --- /dev/null +++ b/pkg/registry/storage/csistoragecapacity/storage/storage_test.go @@ -0,0 +1,153 @@ +/* +Copyright 2020 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 storage + +import ( + "testing" + + "k8s.io/apimachinery/pkg/api/resource" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/fields" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apiserver/pkg/registry/generic" + genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing" + etcd3testing "k8s.io/apiserver/pkg/storage/etcd3/testing" + storageapi "k8s.io/kubernetes/pkg/apis/storage" + _ "k8s.io/kubernetes/pkg/apis/storage/install" + "k8s.io/kubernetes/pkg/registry/registrytest" +) + +func newStorage(t *testing.T) (*REST, *etcd3testing.EtcdTestServer) { + etcdStorage, server := registrytest.NewEtcdStorageForResource(t, storageapi.SchemeGroupVersion.WithResource("csistoragecapacities").GroupResource()) + restOptions := generic.RESTOptions{ + StorageConfig: etcdStorage, + Decorator: generic.UndecoratedStorage, + DeleteCollectionWorkers: 1, + ResourcePrefix: "csistoragecapacities", + } + csiStorageCapacityStorage, err := NewStorage(restOptions) + if err != nil { + t.Fatalf("unexpected error from REST storage: %v", err) + } + return csiStorageCapacityStorage.CSIStorageCapacity, server +} + +func validNewCSIStorageCapacity(name string) *storageapi.CSIStorageCapacity { + selector := metav1.LabelSelector{ + MatchLabels: map[string]string{"kubernetes.io/hostname": "node-a"}, + } + capacity := resource.MustParse("1Gi") + return &storageapi.CSIStorageCapacity{ + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Namespace: metav1.NamespaceDefault, + }, + NodeTopology: &selector, + StorageClassName: "some-storage-class", + Capacity: &capacity, + } +} + +func TestCreate(t *testing.T) { + storage, server := newStorage(t) + defer server.Terminate(t) + defer storage.Store.DestroyFunc() + test := genericregistrytest.New(t, storage.Store) + csiStorageCapacity := validNewCSIStorageCapacity("foo") + csiStorageCapacity.ObjectMeta = metav1.ObjectMeta{GenerateName: "foo-"} + test.TestCreate( + // valid + csiStorageCapacity, + // invalid + &storageapi.CSIStorageCapacity{ + ObjectMeta: metav1.ObjectMeta{Name: "*BadName!"}, + }, + ) +} + +func TestUpdate(t *testing.T) { + storage, server := newStorage(t) + defer server.Terminate(t) + defer storage.Store.DestroyFunc() + test := genericregistrytest.New(t, storage.Store) + + test.TestUpdate( + // valid + validNewCSIStorageCapacity("foo"), + // updateFunc + func(obj runtime.Object) runtime.Object { + object := obj.(*storageapi.CSIStorageCapacity) + object.Labels = map[string]string{"a": "b"} + return object + }, + //invalid update + func(obj runtime.Object) runtime.Object { + object := obj.(*storageapi.CSIStorageCapacity) + object.Name = "!@#$%" + return object + }, + ) +} + +func TestDelete(t *testing.T) { + storage, server := newStorage(t) + defer server.Terminate(t) + defer storage.Store.DestroyFunc() + test := genericregistrytest.New(t, storage.Store).ReturnDeletedObject() + test.TestDelete(validNewCSIStorageCapacity("foo")) +} + +func TestGet(t *testing.T) { + storage, server := newStorage(t) + defer server.Terminate(t) + defer storage.Store.DestroyFunc() + test := genericregistrytest.New(t, storage.Store) + test.TestGet(validNewCSIStorageCapacity("foo")) +} + +func TestList(t *testing.T) { + storage, server := newStorage(t) + defer server.Terminate(t) + defer storage.Store.DestroyFunc() + test := genericregistrytest.New(t, storage.Store) + test.TestList(validNewCSIStorageCapacity("foo")) +} + +func TestWatch(t *testing.T) { + storage, server := newStorage(t) + defer server.Terminate(t) + defer storage.Store.DestroyFunc() + test := genericregistrytest.New(t, storage.Store) + test.TestWatch( + validNewCSIStorageCapacity("foo"), + // matching labels + []labels.Set{}, + // not matching labels + []labels.Set{ + {"foo": "bar"}, + }, + // matching fields + []fields.Set{ + {"metadata.name": "foo"}, + }, + // not matching fields + []fields.Set{ + {"metadata.name": "bar"}, + }, + ) +} diff --git a/pkg/registry/storage/csistoragecapacity/strategy.go b/pkg/registry/storage/csistoragecapacity/strategy.go new file mode 100644 index 00000000000..35e1df57be7 --- /dev/null +++ b/pkg/registry/storage/csistoragecapacity/strategy.go @@ -0,0 +1,78 @@ +/* +Copyright 2020 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 csistoragecapacity + +import ( + "context" + + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/validation/field" + "k8s.io/apiserver/pkg/storage/names" + "k8s.io/kubernetes/pkg/api/legacyscheme" + "k8s.io/kubernetes/pkg/apis/storage" + "k8s.io/kubernetes/pkg/apis/storage/validation" +) + +// csiStorageCapacityStrategy implements behavior for CSIStorageCapacity objects +type csiStorageCapacityStrategy struct { + runtime.ObjectTyper + names.NameGenerator +} + +// Strategy is the default logic that applies when creating and updating +// CSIStorageCapacity objects via the REST API. +var Strategy = csiStorageCapacityStrategy{legacyscheme.Scheme, names.SimpleNameGenerator} + +func (csiStorageCapacityStrategy) NamespaceScoped() bool { + return true +} + +// PrepareForCreate is currently a NOP. +func (csiStorageCapacityStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) { +} + +func (csiStorageCapacityStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList { + csiStorageCapacity := obj.(*storage.CSIStorageCapacity) + + errs := validation.ValidateCSIStorageCapacity(csiStorageCapacity) + errs = append(errs, validation.ValidateCSIStorageCapacity(csiStorageCapacity)...) + + return errs +} + +// Canonicalize normalizes the object after validation. +func (csiStorageCapacityStrategy) Canonicalize(obj runtime.Object) { +} + +func (csiStorageCapacityStrategy) AllowCreateOnUpdate() bool { + return false +} + +// PrepareForUpdate is currently a NOP. +func (csiStorageCapacityStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) { +} + +func (csiStorageCapacityStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList { + newCSIStorageCapacityObj := obj.(*storage.CSIStorageCapacity) + oldCSIStorageCapacityObj := old.(*storage.CSIStorageCapacity) + errorList := validation.ValidateCSIStorageCapacity(newCSIStorageCapacityObj) + return append(errorList, validation.ValidateCSIStorageCapacityUpdate(newCSIStorageCapacityObj, oldCSIStorageCapacityObj)...) +} + +func (csiStorageCapacityStrategy) AllowUnconditionalUpdate() bool { + return false +} diff --git a/pkg/registry/storage/csistoragecapacity/strategy_test.go b/pkg/registry/storage/csistoragecapacity/strategy_test.go new file mode 100644 index 00000000000..048503274fc --- /dev/null +++ b/pkg/registry/storage/csistoragecapacity/strategy_test.go @@ -0,0 +1,182 @@ +/* +Copyright 2020 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 csistoragecapacity + +import ( + "testing" + + apiequality "k8s.io/apimachinery/pkg/api/equality" + "k8s.io/apimachinery/pkg/api/resource" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/util/diff" + genericapirequest "k8s.io/apiserver/pkg/endpoints/request" + utilfeature "k8s.io/apiserver/pkg/util/feature" + featuregatetesting "k8s.io/component-base/featuregate/testing" + "k8s.io/kubernetes/pkg/apis/storage" + "k8s.io/kubernetes/pkg/features" +) + +// getValidCSIStorageCapacity returns a fully-populated CSIStorageCapacity. +func getValidCSIStorageCapacity(name string, capacityStr string) *storage.CSIStorageCapacity { + mib := resource.MustParse("1Mi") + c := &storage.CSIStorageCapacity{ + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Namespace: metav1.NamespaceDefault, + ResourceVersion: "1", + }, + StorageClassName: "bar", + NodeTopology: &metav1.LabelSelector{ + MatchExpressions: []metav1.LabelSelectorRequirement{ + { + Key: "node", + Operator: metav1.LabelSelectorOpIn, + Values: []string{ + "node1", + }, + }, + }, + }, + Capacity: &mib, + } + if capacityStr != "" { + capacityQuantity := resource.MustParse(capacityStr) + c.Capacity = &capacityQuantity + } + return c +} + +func TestCSIStorageCapacityStrategy(t *testing.T) { + ctx := genericapirequest.WithRequestInfo(genericapirequest.NewContext(), &genericapirequest.RequestInfo{ + APIGroup: "storage.k8s.io", + APIVersion: "v1alphav1", + Resource: "csistoragecapacities", + }) + if !Strategy.NamespaceScoped() { + t.Errorf("CSIStorageCapacity must be namespace scoped") + } + if Strategy.AllowCreateOnUpdate() { + t.Errorf("CSIStorageCapacity should not allow create on update") + } + + capacity := getValidCSIStorageCapacity("valid", "") + original := capacity.DeepCopy() + Strategy.PrepareForCreate(ctx, capacity) + errs := Strategy.Validate(ctx, capacity) + if len(errs) != 0 { + t.Errorf("unexpected error validating %v", errs) + } + + // Create with status should have kept status and all other fields. + if !apiequality.Semantic.DeepEqual(capacity, original) { + t.Errorf("unexpected objects difference after creation: %v", diff.ObjectDiff(original, capacity)) + } + + // Update of immutable fields is disallowed + fields := []struct { + name string + update func(capacity *storage.CSIStorageCapacity) + }{ + { + name: "Topology", + update: func(capacity *storage.CSIStorageCapacity) { + capacity.NodeTopology.MatchLabels = map[string]string{"some-label": "some-value"} + }, + }, + { + name: "StorageClass", + update: func(capacity *storage.CSIStorageCapacity) { + capacity.StorageClassName += "-suffix" + }, + }, + } + for _, field := range fields { + t.Run(field.name, func(t *testing.T) { + newCapacity := capacity.DeepCopy() + field.update(newCapacity) + Strategy.PrepareForUpdate(ctx, newCapacity, capacity) + errs = Strategy.ValidateUpdate(ctx, newCapacity, capacity) + if len(errs) == 0 { + t.Errorf("Expected a validation error") + } + }) + } +} + +func TestCSIStorageCapacityValidation(t *testing.T) { + ctx := genericapirequest.WithRequestInfo(genericapirequest.NewContext(), &genericapirequest.RequestInfo{ + APIGroup: "storage.k8s.io", + APIVersion: "v1alphav1", + Resource: "csistoragecapacities", + }) + + tests := []struct { + name string + expectError bool + old, update *storage.CSIStorageCapacity + }{ + { + name: "before: no capacity, update: 1Gi capacity", + old: getValidCSIStorageCapacity("test", ""), + update: getValidCSIStorageCapacity("test", "1Gi"), + }, + { + name: "before: 1Gi capacity, update: no capacity", + old: getValidCSIStorageCapacity("test", "1Gi"), + update: getValidCSIStorageCapacity("test", ""), + }, + { + name: "name change", + expectError: true, + old: getValidCSIStorageCapacity("a", ""), + update: getValidCSIStorageCapacity("b", ""), + }, + { + name: "storage class name change", + expectError: true, + old: getValidCSIStorageCapacity("test", ""), + update: func() *storage.CSIStorageCapacity { + capacity := getValidCSIStorageCapacity("test", "") + capacity.StorageClassName += "-update" + return capacity + }(), + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSIStorageCapacity, true)() + + oldCapacity := test.old.DeepCopy() + Strategy.PrepareForCreate(ctx, oldCapacity) + errs := Strategy.Validate(ctx, oldCapacity) + if len(errs) != 0 { + t.Errorf("unexpected validating errors for create: %v", errs) + } + + newCapacity := test.update.DeepCopy() + Strategy.PrepareForUpdate(ctx, newCapacity, test.old) + errs = Strategy.ValidateUpdate(ctx, newCapacity, oldCapacity) + if len(errs) > 0 && !test.expectError { + t.Errorf("unexpected validation failure: %+v", errs) + } + if len(errs) == 0 && test.expectError { + t.Errorf("validation unexpectedly succeeded") + } + }) + } +} diff --git a/pkg/registry/storage/rest/BUILD b/pkg/registry/storage/rest/BUILD index 8c773060cf3..e7608f24201 100644 --- a/pkg/registry/storage/rest/BUILD +++ b/pkg/registry/storage/rest/BUILD @@ -15,6 +15,7 @@ go_library( "//pkg/features:go_default_library", "//pkg/registry/storage/csidriver/storage:go_default_library", "//pkg/registry/storage/csinode/storage:go_default_library", + "//pkg/registry/storage/csistoragecapacity/storage:go_default_library", "//pkg/registry/storage/storageclass/storage:go_default_library", "//pkg/registry/storage/volumeattachment/storage:go_default_library", "//staging/src/k8s.io/api/storage/v1:go_default_library", diff --git a/pkg/registry/storage/rest/storage_storage.go b/pkg/registry/storage/rest/storage_storage.go index cb86ab2d3b5..9deb79e0f43 100644 --- a/pkg/registry/storage/rest/storage_storage.go +++ b/pkg/registry/storage/rest/storage_storage.go @@ -30,6 +30,7 @@ import ( "k8s.io/kubernetes/pkg/features" csidriverstore "k8s.io/kubernetes/pkg/registry/storage/csidriver/storage" csinodestore "k8s.io/kubernetes/pkg/registry/storage/csinode/storage" + csistoragecapacitystore "k8s.io/kubernetes/pkg/registry/storage/csistoragecapacity/storage" storageclassstore "k8s.io/kubernetes/pkg/registry/storage/storageclass/storage" volumeattachmentstore "k8s.io/kubernetes/pkg/registry/storage/volumeattachment/storage" ) @@ -76,6 +77,15 @@ func (p RESTStorageProvider) v1alpha1Storage(apiResourceConfigSource serverstora } storage["volumeattachments"] = volumeAttachmentStorage.VolumeAttachment + // register csistoragecapacity if CSIStorageCapacity feature gate is enabled + if utilfeature.DefaultFeatureGate.Enabled(features.CSIStorageCapacity) { + csiStorageStorage, err := csistoragecapacitystore.NewStorage(restOptionsGetter) + if err != nil { + return storage, err + } + storage["csistoragecapacities"] = csiStorageStorage.CSIStorageCapacity + } + return storage, nil } diff --git a/pkg/scheduler/framework/plugins/volumebinding/BUILD b/pkg/scheduler/framework/plugins/volumebinding/BUILD index 9b8a012cdd1..dd70db1ea9d 100644 --- a/pkg/scheduler/framework/plugins/volumebinding/BUILD +++ b/pkg/scheduler/framework/plugins/volumebinding/BUILD @@ -7,10 +7,12 @@ go_library( visibility = ["//visibility:public"], deps = [ "//pkg/controller/volume/scheduling:go_default_library", + "//pkg/features:go_default_library", "//pkg/scheduler/apis/config:go_default_library", "//pkg/scheduler/framework/v1alpha1:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library", + "//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library", "//vendor/k8s.io/klog/v2:go_default_library", ], ) diff --git a/pkg/scheduler/framework/plugins/volumebinding/volume_binding.go b/pkg/scheduler/framework/plugins/volumebinding/volume_binding.go index 18614a43c89..0fee9534f40 100644 --- a/pkg/scheduler/framework/plugins/volumebinding/volume_binding.go +++ b/pkg/scheduler/framework/plugins/volumebinding/volume_binding.go @@ -24,8 +24,10 @@ import ( v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime" + utilfeature "k8s.io/apiserver/pkg/util/feature" "k8s.io/klog/v2" "k8s.io/kubernetes/pkg/controller/volume/scheduling" + "k8s.io/kubernetes/pkg/features" "k8s.io/kubernetes/pkg/scheduler/apis/config" framework "k8s.io/kubernetes/pkg/scheduler/framework/v1alpha1" ) @@ -136,6 +138,9 @@ func getStateData(cs *framework.CycleState) (*stateData, error) { // For PVCs that are unbound, it tries to find available PVs that can satisfy the PVC requirements // and that the PV node affinity is satisfied by the given node. // +// If storage capacity tracking is enabled, then enough space has to be available +// for the node and volumes that still need to be created. +// // The predicate returns true if all bound PVCs have compatible PVs with the node, and if all unbound // PVCs can be matched with an available and node-compatible PV. func (pl *VolumeBinding) Filter(ctx context.Context, cs *framework.CycleState, pod *v1.Pod, nodeInfo *framework.NodeInfo) *framework.Status { @@ -254,7 +259,14 @@ func New(plArgs runtime.Object, fh framework.FrameworkHandle) (framework.Plugin, pvInformer := fh.SharedInformerFactory().Core().V1().PersistentVolumes() storageClassInformer := fh.SharedInformerFactory().Storage().V1().StorageClasses() csiNodeInformer := fh.SharedInformerFactory().Storage().V1().CSINodes() - binder := scheduling.NewVolumeBinder(fh.ClientSet(), podInformer, nodeInformer, csiNodeInformer, pvcInformer, pvInformer, storageClassInformer, time.Duration(args.BindTimeoutSeconds)*time.Second) + var capacityCheck *scheduling.CapacityCheck + if utilfeature.DefaultFeatureGate.Enabled(features.CSIStorageCapacity) { + capacityCheck = &scheduling.CapacityCheck{ + CSIDriverInformer: fh.SharedInformerFactory().Storage().V1().CSIDrivers(), + CSIStorageCapacityInformer: fh.SharedInformerFactory().Storage().V1alpha1().CSIStorageCapacities(), + } + } + binder := scheduling.NewVolumeBinder(fh.ClientSet(), podInformer, nodeInformer, csiNodeInformer, pvcInformer, pvInformer, storageClassInformer, capacityCheck, time.Duration(args.BindTimeoutSeconds)*time.Second) return &VolumeBinding{ Binder: binder, }, nil diff --git a/plugin/pkg/auth/authorizer/rbac/bootstrappolicy/policy.go b/plugin/pkg/auth/authorizer/rbac/bootstrappolicy/policy.go index 8dd4ef80a9b..c3624119d2e 100644 --- a/plugin/pkg/auth/authorizer/rbac/bootstrappolicy/policy.go +++ b/plugin/pkg/auth/authorizer/rbac/bootstrappolicy/policy.go @@ -541,6 +541,12 @@ func ClusterRoles() []rbacv1.ClusterRole { // Needed for volume limits rbacv1helpers.NewRule(Read...).Groups(storageGroup).Resources("csinodes").RuleOrDie(), } + if utilfeature.DefaultFeatureGate.Enabled(features.CSIStorageCapacity) { + kubeSchedulerRules = append(kubeSchedulerRules, + rbacv1helpers.NewRule(Read...).Groups(storageGroup).Resources("csidrivers").RuleOrDie(), + rbacv1helpers.NewRule(Read...).Groups(storageGroup).Resources("csistoragecapacities").RuleOrDie(), + ) + } roles = append(roles, rbacv1.ClusterRole{ // a role to use for the kube-scheduler ObjectMeta: metav1.ObjectMeta{Name: "system:kube-scheduler"}, diff --git a/staging/src/k8s.io/api/storage/v1/generated.pb.go b/staging/src/k8s.io/api/storage/v1/generated.pb.go index 9e57369106d..bb54822193e 100644 --- a/staging/src/k8s.io/api/storage/v1/generated.pb.go +++ b/staging/src/k8s.io/api/storage/v1/generated.pb.go @@ -520,91 +520,93 @@ func init() { } var fileDescriptor_3b530c1983504d8d = []byte{ - // 1336 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x57, 0x4f, 0x6f, 0x1b, 0x45, - 0x14, 0xcf, 0xc6, 0xf9, 0x3b, 0x4e, 0x5a, 0x67, 0x1a, 0xc0, 0xe4, 0xe0, 0x8d, 0x96, 0x0a, 0x42, - 0xa1, 0xeb, 0xa6, 0x94, 0xaa, 0xaa, 0x04, 0x52, 0x36, 0x31, 0x22, 0x22, 0x4e, 0xa2, 0x49, 0xa9, - 0x10, 0x02, 0xc4, 0x64, 0xf7, 0xd5, 0xd9, 0xc6, 0xbb, 0xb3, 0xdd, 0x1d, 0x1b, 0x7c, 0xe3, 0xc4, - 0x0d, 0x09, 0xae, 0x7c, 0x0a, 0x90, 0xe0, 0xc2, 0x91, 0x53, 0xb9, 0x55, 0x9c, 0x7a, 0xb2, 0xe8, - 0x72, 0x05, 0x3e, 0x40, 0x4e, 0x68, 0x66, 0xc7, 0xde, 0xb5, 0xbd, 0x4e, 0xd3, 0x8b, 0x6f, 0x9e, - 0xf7, 0xde, 0xef, 0xf7, 0xde, 0x9b, 0xf7, 0x67, 0xd6, 0xe8, 0xfd, 0xd3, 0x3b, 0x91, 0xe9, 0xb2, - 0xea, 0x69, 0xeb, 0x18, 0x42, 0x1f, 0x38, 0x44, 0xd5, 0x36, 0xf8, 0x0e, 0x0b, 0xab, 0x4a, 0x41, - 0x03, 0xb7, 0x1a, 0x71, 0x16, 0xd2, 0x06, 0x54, 0xdb, 0x9b, 0xd5, 0x06, 0xf8, 0x10, 0x52, 0x0e, - 0x8e, 0x19, 0x84, 0x8c, 0x33, 0xfc, 0x52, 0x62, 0x66, 0xd2, 0xc0, 0x35, 0x95, 0x99, 0xd9, 0xde, - 0x5c, 0xbb, 0xde, 0x70, 0xf9, 0x49, 0xeb, 0xd8, 0xb4, 0x99, 0x57, 0x6d, 0xb0, 0x06, 0xab, 0x4a, -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c, 0x0b, 0x2d, - 0x71, 0x16, 0xb0, 0x26, 0x6b, 0x74, 0x3e, 0x82, 0x4e, 0xef, 0xb2, 0x4b, 0x71, 0x57, 0x5f, 0xba, - 0x97, 0x91, 0x93, 0x01, 0x2b, 0xfc, 0x39, 0x2a, 0xd2, 0x66, 0x93, 0xd9, 0x94, 0xd3, 0xe3, 0x26, - 0x94, 0x67, 0x64, 0x7a, 0xd7, 0xc6, 0xa4, 0x97, 0x14, 0x47, 0xf8, 0x25, 0x10, 0xb1, 0x56, 0x68, - 0x43, 0x64, 0x5d, 0x8e, 0xbb, 0x7a, 0x71, 0x2b, 0xa5, 0x20, 0x59, 0x3e, 0xe3, 0x27, 0x0d, 0x15, - 0x55, 0xc2, 0x13, 0x18, 0xa4, 0xed, 0xc1, 0x41, 0xaa, 0x9c, 0x5f, 0xa5, 0x31, 0x63, 0xf4, 0x45, - 0x3f, 0x62, 0x39, 0x43, 0x07, 0x68, 0xde, 0x91, 0xa5, 0x8a, 0xca, 0x9a, 0x64, 0xbd, 0x7a, 0x3e, - 0xab, 0x1a, 0xd1, 0xcb, 0x8a, 0x7b, 0x3e, 0x39, 0x47, 0xa4, 0xc7, 0x62, 0x7c, 0x37, 0x87, 0x96, - 0x8e, 0x12, 0xd8, 0x76, 0x93, 0x46, 0xd1, 0x04, 0x9a, 0xf7, 0x5d, 0x54, 0x0c, 0x42, 0xd6, 0x76, - 0x23, 0x97, 0xf9, 0x10, 0xaa, 0x3e, 0xba, 0xa2, 0x20, 0xc5, 0xc3, 0x54, 0x45, 0xb2, 0x76, 0xb8, - 0x81, 0x50, 0x40, 0x43, 0xea, 0x01, 0x17, 0xd9, 0x17, 0x64, 0xf6, 0xef, 0x8c, 0xc9, 0x3e, 0x9b, - 0x91, 0x79, 0xd8, 0x47, 0xd5, 0x7c, 0x1e, 0x76, 0xd2, 0xe8, 0x52, 0x05, 0xc9, 0x50, 0xe3, 0x53, - 0xb4, 0x1c, 0x82, 0xdd, 0xa4, 0xae, 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x24, 0x02, 0x9a, 0xb5, 0x16, 0xc5, 0x46, 0xd9, 0x96, 0x7f, 0x93, - 0x12, 0xb9, 0xb5, 0xf1, 0xf8, 0x59, 0x65, 0xea, 0xc9, 0xb3, 0xca, 0xd4, 0xd3, 0x67, 0x95, 0xa9, - 0x6f, 0xe2, 0x8a, 0xf6, 0x38, 0xae, 0x68, 0x4f, 0xe2, 0x8a, 0xf6, 0x34, 0xae, 0x68, 0x7f, 0xc5, - 0x15, 0xed, 0xfb, 0xbf, 0x2b, 0x53, 0x9f, 0x4e, 0xb7, 0x37, 0xff, 0x0f, 0x00, 0x00, 0xff, 0xff, - 0x9b, 0x74, 0xdf, 0x56, 0x8a, 0x10, 0x00, 0x00, + // 1363 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x57, 0xcf, 0x6f, 0x1b, 0xc5, + 0x17, 0xcf, 0xc6, 0xf9, 0x39, 0x4e, 0x1a, 0x67, 0x92, 0xef, 0x17, 0x93, 0x83, 0x37, 0x5a, 0x2a, + 0x08, 0x85, 0xae, 0x9b, 0x52, 0xaa, 0xaa, 0x52, 0x91, 0xe2, 0xc4, 0x88, 0x88, 0x38, 0x89, 0x26, + 0xa5, 0x42, 0x08, 0x10, 0x93, 0xdd, 0x57, 0x67, 0x1b, 0xef, 0xce, 0x76, 0x77, 0x6c, 0xf0, 0x8d, + 0x13, 0x37, 0x24, 0xb8, 0xf2, 0x2f, 0x70, 0x01, 0x09, 0x2e, 0x1c, 0x39, 0x95, 0x5b, 0xc5, 0xa9, + 0x27, 0x8b, 0x2e, 0x67, 0xf8, 0x03, 0x72, 0x42, 0x33, 0x3b, 0xf6, 0xee, 0xda, 0xeb, 0x34, 0xbd, + 0xe4, 0xe6, 0x79, 0xef, 0x7d, 0x3e, 0xef, 0xbd, 0x79, 0x3f, 0x66, 0x8d, 0xde, 0x3b, 0xbd, 0x13, + 0x9a, 0x0e,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, 0x7a, 0xd6, 0xd3, 0x8b, 0x29, 0x3d, 0x49, 0xd3, + 0x0a, 0x2f, 0x36, 0x24, 0x5e, 0xa6, 0x5e, 0xce, 0xcb, 0x0e, 0x8c, 0xf7, 0x92, 0xa2, 0x5d, 0xab, + 0xa3, 0x57, 0xc6, 0x5c, 0xcb, 0x4b, 0xbd, 0x17, 0xdf, 0x68, 0x28, 0xed, 0x03, 0xef, 0xa1, 0x29, + 0xf1, 0x1f, 0x56, 0x2d, 0x92, 0x6b, 0x17, 0x5b, 0x24, 0xf7, 0x1d, 0x17, 0x92, 0x55, 0x28, 0x4e, + 0x44, 0xb2, 0xe0, 0x37, 0xd1, 0xac, 0x0b, 0x61, 0x48, 0x9b, 0xca, 0x73, 0xf2, 0x21, 0xd7, 0x88, + 0xc5, 0xa4, 0xaf, 0x37, 0x6e, 0xa3, 0x95, 0x9c, 0x0f, 0x62, 0xac, 0xa3, 0x69, 0x4b, 0xfe, 0xdd, + 0x12, 0x01, 0x4d, 0xd7, 0xe6, 0xc5, 0x46, 0xd9, 0x96, 0xff, 0xb2, 0x62, 0x79, 0x6d, 0xe3, 0xc9, + 0xf3, 0xca, 0xc4, 0xd3, 0xe7, 0x95, 0x89, 0x67, 0xcf, 0x2b, 0x13, 0x5f, 0x47, 0x15, 0xed, 0x49, + 0x54, 0xd1, 0x9e, 0x46, 0x15, 0xed, 0x59, 0x54, 0xd1, 0xfe, 0x8a, 0x2a, 0xda, 0x77, 0x7f, 0x57, + 0x26, 0x3e, 0x99, 0xec, 0x6c, 0xfe, 0x17, 0x00, 0x00, 0xff, 0xff, 0x6c, 0x40, 0x09, 0x76, 0xc9, + 0x10, 0x00, 0x00, } func (m *CSIDriver) Marshal() (dAtA []byte, err error) { @@ -717,6 +719,16 @@ func (m *CSIDriverSpec) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.StorageCapacity != nil { + i-- + if *m.StorageCapacity { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x20 + } if len(m.VolumeLifecycleModes) > 0 { for iNdEx := len(m.VolumeLifecycleModes) - 1; iNdEx >= 0; iNdEx-- { i -= len(m.VolumeLifecycleModes[iNdEx]) @@ -1475,6 +1487,9 @@ func (m *CSIDriverSpec) Size() (n int) { n += 1 + l + sovGenerated(uint64(l)) } } + if m.StorageCapacity != nil { + n += 2 + } return n } @@ -1763,6 +1778,7 @@ func (this *CSIDriverSpec) String() string { `AttachRequired:` + valueToStringGenerated(this.AttachRequired) + `,`, `PodInfoOnMount:` + valueToStringGenerated(this.PodInfoOnMount) + `,`, `VolumeLifecycleModes:` + fmt.Sprintf("%v", this.VolumeLifecycleModes) + `,`, + `StorageCapacity:` + valueToStringGenerated(this.StorageCapacity) + `,`, `}`, }, "") return s @@ -2315,6 +2331,27 @@ func (m *CSIDriverSpec) Unmarshal(dAtA []byte) error { } m.VolumeLifecycleModes = append(m.VolumeLifecycleModes, VolumeLifecycleMode(dAtA[iNdEx:postIndex])) iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field StorageCapacity", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + b := bool(v != 0) + m.StorageCapacity = &b default: iNdEx = preIndex skippy, err := skipGenerated(dAtA[iNdEx:]) diff --git a/staging/src/k8s.io/api/storage/v1/generated.proto b/staging/src/k8s.io/api/storage/v1/generated.proto index cb3c42c7fe1..584d7dcb28a 100644 --- a/staging/src/k8s.io/api/storage/v1/generated.proto +++ b/staging/src/k8s.io/api/storage/v1/generated.proto @@ -118,6 +118,26 @@ message CSIDriverSpec { // +optional // +listType=set repeated string volumeLifecycleModes = 3; + + // If set to true, storageCapacity indicates that the CSI + // volume driver wants pod scheduling to consider the storage + // capacity that the driver deployment will report by creating + // CSIStorageCapacity objects with capacity information. + // + // The check can be enabled immediately when deploying a driver. + // In that case, provisioning new volumes with late binding + // will pause until the driver deployment has published + // some suitable CSIStorageCapacity object. + // + // Alternatively, the driver can be deployed with the field + // unset or false and it can be flipped later when storage + // capacity information has been published. + // + // This is an alpha field and only available when the CSIStorageCapacity + // feature is enabled. The default is false. + // + // +optional + optional bool storageCapacity = 4; } // CSINode holds information about all CSI drivers installed on a node. diff --git a/staging/src/k8s.io/api/storage/v1/types.go b/staging/src/k8s.io/api/storage/v1/types.go index 556427bb20e..6f0b3ee465b 100644 --- a/staging/src/k8s.io/api/storage/v1/types.go +++ b/staging/src/k8s.io/api/storage/v1/types.go @@ -316,6 +316,26 @@ type CSIDriverSpec struct { // +optional // +listType=set VolumeLifecycleModes []VolumeLifecycleMode `json:"volumeLifecycleModes,omitempty" protobuf:"bytes,3,opt,name=volumeLifecycleModes"` + + // If set to true, storageCapacity indicates that the CSI + // volume driver wants pod scheduling to consider the storage + // capacity that the driver deployment will report by creating + // CSIStorageCapacity objects with capacity information. + // + // The check can be enabled immediately when deploying a driver. + // In that case, provisioning new volumes with late binding + // will pause until the driver deployment has published + // some suitable CSIStorageCapacity object. + // + // Alternatively, the driver can be deployed with the field + // unset or false and it can be flipped later when storage + // capacity information has been published. + // + // This is an alpha field and only available when the CSIStorageCapacity + // feature is enabled. The default is false. + // + // +optional + StorageCapacity *bool `json:"storageCapacity,omitempty" protobuf:"bytes,4,opt,name=storageCapacity"` } // VolumeLifecycleMode is an enumeration of possible usage modes for a volume diff --git a/staging/src/k8s.io/api/storage/v1/types_swagger_doc_generated.go b/staging/src/k8s.io/api/storage/v1/types_swagger_doc_generated.go index 0e524a28cd9..374e933254c 100644 --- a/staging/src/k8s.io/api/storage/v1/types_swagger_doc_generated.go +++ b/staging/src/k8s.io/api/storage/v1/types_swagger_doc_generated.go @@ -52,6 +52,7 @@ var map_CSIDriverSpec = map[string]string{ "attachRequired": "attachRequired indicates this CSI volume driver requires an attach operation (because it implements the CSI ControllerPublishVolume() method), and that the Kubernetes attach detach controller should call the attach volume interface which checks the volumeattachment status and waits until the volume is attached before proceeding to mounting. The CSI external-attacher coordinates with CSI volume driver and updates the volumeattachment status when the attach operation is complete. If the CSIDriverRegistry feature gate is enabled and the value is specified to false, the attach operation will be skipped. Otherwise the attach operation will be called.", "podInfoOnMount": "If set to true, podInfoOnMount indicates this CSI volume driver requires additional pod information (like podName, podUID, etc.) during mount operations. If set to false, pod information will not be passed on mount. Default is false. The CSI driver specifies podInfoOnMount as part of driver deployment. If true, Kubelet will pass pod information as VolumeContext in the CSI NodePublishVolume() calls. The CSI driver is responsible for parsing and validating the information passed in as VolumeContext. The following VolumeConext will be passed if podInfoOnMount is set to true. This list might grow, but the prefix will be used. \"csi.storage.k8s.io/pod.name\": pod.Name \"csi.storage.k8s.io/pod.namespace\": pod.Namespace \"csi.storage.k8s.io/pod.uid\": string(pod.UID) \"csi.storage.k8s.io/ephemeral\": \"true\" iff the volume is an ephemeral inline volume\n defined by a CSIVolumeSource, otherwise \"false\"\n\n\"csi.storage.k8s.io/ephemeral\" is a new feature in Kubernetes 1.16. It is only required for drivers which support both the \"Persistent\" and \"Ephemeral\" VolumeLifecycleMode. Other drivers can leave pod info disabled and/or ignore this field. As Kubernetes 1.15 doesn't support this field, drivers can only support one mode when deployed on such a cluster and the deployment determines which mode that is, for example via a command line parameter of the driver.", "volumeLifecycleModes": "volumeLifecycleModes defines what kind of volumes this CSI volume driver supports. The default if the list is empty is \"Persistent\", which is the usage defined by the CSI specification and implemented in Kubernetes via the usual PV/PVC mechanism. The other mode is \"Ephemeral\". In this mode, volumes are defined inline inside the pod spec with CSIVolumeSource and their lifecycle is tied to the lifecycle of that pod. A driver has to be aware of this because it is only going to get a NodePublishVolume call for such a volume. For more information about implementing this mode, see https://kubernetes-csi.github.io/docs/ephemeral-local-volumes.html A driver can support one or more of these modes and more modes may be added in the future. This field is beta.", + "storageCapacity": "If set to true, storageCapacity indicates that the CSI volume driver wants pod scheduling to consider the storage capacity that the driver deployment will report by creating CSIStorageCapacity objects with capacity information.\n\nThe check can be enabled immediately when deploying a driver. In that case, provisioning new volumes with late binding will pause until the driver deployment has published some suitable CSIStorageCapacity object.\n\nAlternatively, the driver can be deployed with the field unset or false and it can be flipped later when storage capacity information has been published.\n\nThis is an alpha field and only available when the CSIStorageCapacity feature is enabled. The default is false.", } func (CSIDriverSpec) SwaggerDoc() map[string]string { diff --git a/staging/src/k8s.io/api/storage/v1/zz_generated.deepcopy.go b/staging/src/k8s.io/api/storage/v1/zz_generated.deepcopy.go index efaa40aa790..d05dfa56f9e 100644 --- a/staging/src/k8s.io/api/storage/v1/zz_generated.deepcopy.go +++ b/staging/src/k8s.io/api/storage/v1/zz_generated.deepcopy.go @@ -103,6 +103,11 @@ func (in *CSIDriverSpec) DeepCopyInto(out *CSIDriverSpec) { *out = make([]VolumeLifecycleMode, len(*in)) copy(*out, *in) } + if in.StorageCapacity != nil { + in, out := &in.StorageCapacity, &out.StorageCapacity + *out = new(bool) + **out = **in + } return } diff --git a/staging/src/k8s.io/api/storage/v1alpha1/BUILD b/staging/src/k8s.io/api/storage/v1alpha1/BUILD index aa03c3f23af..c8c9cda81bb 100644 --- a/staging/src/k8s.io/api/storage/v1alpha1/BUILD +++ b/staging/src/k8s.io/api/storage/v1alpha1/BUILD @@ -15,6 +15,7 @@ go_library( visibility = ["//visibility:public"], deps = [ "//staging/src/k8s.io/api/core/v1:go_default_library", + "//staging/src/k8s.io/apimachinery/pkg/api/resource:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library", diff --git a/staging/src/k8s.io/api/storage/v1alpha1/generated.pb.go b/staging/src/k8s.io/api/storage/v1alpha1/generated.pb.go index 1f9db7ae08a..1b7767fdccc 100644 --- a/staging/src/k8s.io/api/storage/v1alpha1/generated.pb.go +++ b/staging/src/k8s.io/api/storage/v1alpha1/generated.pb.go @@ -27,6 +27,8 @@ import ( proto "github.com/gogo/protobuf/proto" github_com_gogo_protobuf_sortkeys "github.com/gogo/protobuf/sortkeys" v11 "k8s.io/api/core/v1" + resource "k8s.io/apimachinery/pkg/api/resource" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" math "math" math_bits "math/bits" @@ -45,10 +47,66 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +func (m *CSIStorageCapacity) Reset() { *m = CSIStorageCapacity{} } +func (*CSIStorageCapacity) ProtoMessage() {} +func (*CSIStorageCapacity) Descriptor() ([]byte, []int) { + return fileDescriptor_10f856db1e670dc4, []int{0} +} +func (m *CSIStorageCapacity) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CSIStorageCapacity) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *CSIStorageCapacity) XXX_Merge(src proto.Message) { + xxx_messageInfo_CSIStorageCapacity.Merge(m, src) +} +func (m *CSIStorageCapacity) XXX_Size() int { + return m.Size() +} +func (m *CSIStorageCapacity) XXX_DiscardUnknown() { + xxx_messageInfo_CSIStorageCapacity.DiscardUnknown(m) +} + +var xxx_messageInfo_CSIStorageCapacity proto.InternalMessageInfo + +func (m *CSIStorageCapacityList) Reset() { *m = CSIStorageCapacityList{} } +func (*CSIStorageCapacityList) ProtoMessage() {} +func (*CSIStorageCapacityList) Descriptor() ([]byte, []int) { + return fileDescriptor_10f856db1e670dc4, []int{1} +} +func (m *CSIStorageCapacityList) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CSIStorageCapacityList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *CSIStorageCapacityList) XXX_Merge(src proto.Message) { + xxx_messageInfo_CSIStorageCapacityList.Merge(m, src) +} +func (m *CSIStorageCapacityList) XXX_Size() int { + return m.Size() +} +func (m *CSIStorageCapacityList) XXX_DiscardUnknown() { + xxx_messageInfo_CSIStorageCapacityList.DiscardUnknown(m) +} + +var xxx_messageInfo_CSIStorageCapacityList proto.InternalMessageInfo + func (m *VolumeAttachment) Reset() { *m = VolumeAttachment{} } func (*VolumeAttachment) ProtoMessage() {} func (*VolumeAttachment) Descriptor() ([]byte, []int) { - return fileDescriptor_10f856db1e670dc4, []int{0} + return fileDescriptor_10f856db1e670dc4, []int{2} } func (m *VolumeAttachment) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -76,7 +134,7 @@ var xxx_messageInfo_VolumeAttachment proto.InternalMessageInfo func (m *VolumeAttachmentList) Reset() { *m = VolumeAttachmentList{} } func (*VolumeAttachmentList) ProtoMessage() {} func (*VolumeAttachmentList) Descriptor() ([]byte, []int) { - return fileDescriptor_10f856db1e670dc4, []int{1} + return fileDescriptor_10f856db1e670dc4, []int{3} } func (m *VolumeAttachmentList) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -104,7 +162,7 @@ var xxx_messageInfo_VolumeAttachmentList proto.InternalMessageInfo func (m *VolumeAttachmentSource) Reset() { *m = VolumeAttachmentSource{} } func (*VolumeAttachmentSource) ProtoMessage() {} func (*VolumeAttachmentSource) Descriptor() ([]byte, []int) { - return fileDescriptor_10f856db1e670dc4, []int{2} + return fileDescriptor_10f856db1e670dc4, []int{4} } func (m *VolumeAttachmentSource) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -132,7 +190,7 @@ var xxx_messageInfo_VolumeAttachmentSource proto.InternalMessageInfo func (m *VolumeAttachmentSpec) Reset() { *m = VolumeAttachmentSpec{} } func (*VolumeAttachmentSpec) ProtoMessage() {} func (*VolumeAttachmentSpec) Descriptor() ([]byte, []int) { - return fileDescriptor_10f856db1e670dc4, []int{3} + return fileDescriptor_10f856db1e670dc4, []int{5} } func (m *VolumeAttachmentSpec) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -160,7 +218,7 @@ var xxx_messageInfo_VolumeAttachmentSpec proto.InternalMessageInfo func (m *VolumeAttachmentStatus) Reset() { *m = VolumeAttachmentStatus{} } func (*VolumeAttachmentStatus) ProtoMessage() {} func (*VolumeAttachmentStatus) Descriptor() ([]byte, []int) { - return fileDescriptor_10f856db1e670dc4, []int{4} + return fileDescriptor_10f856db1e670dc4, []int{6} } func (m *VolumeAttachmentStatus) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -188,7 +246,7 @@ var xxx_messageInfo_VolumeAttachmentStatus proto.InternalMessageInfo func (m *VolumeError) Reset() { *m = VolumeError{} } func (*VolumeError) ProtoMessage() {} func (*VolumeError) Descriptor() ([]byte, []int) { - return fileDescriptor_10f856db1e670dc4, []int{5} + return fileDescriptor_10f856db1e670dc4, []int{7} } func (m *VolumeError) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -214,6 +272,8 @@ func (m *VolumeError) XXX_DiscardUnknown() { var xxx_messageInfo_VolumeError proto.InternalMessageInfo func init() { + proto.RegisterType((*CSIStorageCapacity)(nil), "k8s.io.api.storage.v1alpha1.CSIStorageCapacity") + proto.RegisterType((*CSIStorageCapacityList)(nil), "k8s.io.api.storage.v1alpha1.CSIStorageCapacityList") proto.RegisterType((*VolumeAttachment)(nil), "k8s.io.api.storage.v1alpha1.VolumeAttachment") proto.RegisterType((*VolumeAttachmentList)(nil), "k8s.io.api.storage.v1alpha1.VolumeAttachmentList") proto.RegisterType((*VolumeAttachmentSource)(nil), "k8s.io.api.storage.v1alpha1.VolumeAttachmentSource") @@ -228,54 +288,172 @@ func init() { } var fileDescriptor_10f856db1e670dc4 = []byte{ - // 745 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0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xab, 0x07, 0x00, 0x00, + // 895 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0x4f, 0x6f, 0xe3, 0x44, + 0x14, 0x8f, 0x9b, 0x74, 0x37, 0x3b, 0x29, 0x10, 0x8d, 0xa2, 0x25, 0x0a, 0x92, 0x53, 0xe5, 0x14, + 0x10, 0x3b, 0xa6, 0x0b, 0x42, 0x2b, 0x6e, 0x75, 0xdb, 0x43, 0x45, 0x5b, 0x60, 0x52, 0x21, 0x04, + 0x1c, 0x98, 0x38, 0x0f, 0xc7, 0x4d, 0xfc, 0x47, 0x33, 0xe3, 0x4a, 0xb9, 0xc1, 0x85, 0x33, 0x37, + 0xbe, 0x01, 0x9f, 0xa5, 0x07, 0x24, 0x56, 0x9c, 0xf6, 0x14, 0x51, 0xf3, 0x2d, 0xb8, 0x80, 0x3c, + 0x9e, 0x38, 0x6e, 0x9c, 0x74, 0xb3, 0x7b, 0xd8, 0x9b, 0xe7, 0xcd, 0x7b, 0xbf, 0xdf, 0xfb, 0xf3, + 0x9b, 0x27, 0xa3, 0xe3, 0xc9, 0x33, 0x41, 0xbc, 0xd0, 0x9a, 0xc4, 0x43, 0xe0, 0x01, 0x48, 0x10, + 0xd6, 0x35, 0x04, 0xa3, 0x90, 0x5b, 0xfa, 0x82, 0x45, 0x9e, 0x25, 0x64, 0xc8, 0x99, 0x0b, 0xd6, + 0xf5, 0x01, 0x9b, 0x46, 0x63, 0x76, 0x60, 0xb9, 0x10, 0x00, 0x67, 0x12, 0x46, 0x24, 0xe2, 0xa1, + 0x0c, 0xf1, 0x7b, 0x99, 0x33, 0x61, 0x91, 0x47, 0xb4, 0x33, 0x59, 0x38, 0x77, 0x9e, 0xb8, 0x9e, + 0x1c, 0xc7, 0x43, 0xe2, 0x84, 0xbe, 0xe5, 0x86, 0x6e, 0x68, 0xa9, 0x98, 0x61, 0xfc, 0xa3, 0x3a, +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, 0xd6, 0x13, 0xce, 0x43, 0xae, 0x9f, 0x6d, 0x7f, 0x8b, 0x8c, 0x94, 0xbf, 0x6d, + 0x26, 0xf3, 0x6e, 0xe3, 0x70, 0x09, 0xf0, 0xef, 0xbc, 0xdb, 0x28, 0xdc, 0xd3, 0x22, 0x78, 0xca, + 0x35, 0x82, 0x25, 0x57, 0xed, 0x75, 0xb8, 0x8e, 0x61, 0x33, 0x57, 0x01, 0xbc, 0x73, 0x82, 0xde, + 0xdd, 0xd0, 0x22, 0xdc, 0x44, 0xd5, 0x09, 0xcc, 0x32, 0x25, 0xd2, 0xf4, 0x13, 0xb7, 0xd0, 0xee, + 0x35, 0x9b, 0xc6, 0x99, 0xe2, 0x1e, 0xd1, 0xec, 0xf0, 0xd9, 0xce, 0x33, 0xa3, 0xf7, 0x8b, 0x81, + 0x8a, 0x1c, 0xf8, 0x0c, 0xd5, 0xd2, 0xdf, 0x03, 0xbd, 0x66, 0x3e, 0xd8, 0x6e, 0xcd, 0x5c, 0x7a, + 0x3e, 0x2c, 0xd7, 0x65, 0x7a, 0xa2, 0x0a, 0x05, 0xbf, 0x8f, 0x1e, 0xfa, 0x20, 0x04, 0x73, 0x35, + 0xb3, 0xfd, 0x8e, 0x76, 0x7a, 0x78, 0x9e, 0x99, 0xe9, 0xe2, 0xde, 0x26, 0x37, 0xb7, 0x66, 0xe5, + 0xf9, 0xad, 0x59, 0x79, 0x71, 0x6b, 0x56, 0x7e, 0x4a, 0x4c, 0xe3, 0x26, 0x31, 0x8d, 0xe7, 0x89, + 0x69, 0xbc, 0x48, 0x4c, 0xe3, 0xef, 0xc4, 0x34, 0x7e, 0xfd, 0xc7, 0xac, 0x7c, 0x5b, 0x5f, 0x34, + 0xee, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x6e, 0xb9, 0x9d, 0xb3, 0x34, 0x0a, 0x00, 0x00, +} + +func (m *CSIStorageCapacity) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *CSIStorageCapacity) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CSIStorageCapacity) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Capacity != nil { + { + size, err := m.Capacity.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenerated(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + i -= len(m.StorageClassName) + copy(dAtA[i:], m.StorageClassName) + i = encodeVarintGenerated(dAtA, i, uint64(len(m.StorageClassName))) + i-- + dAtA[i] = 0x1a + if m.NodeTopology != nil { + { + size, err := m.NodeTopology.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenerated(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + { + size, err := m.ObjectMeta.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenerated(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *CSIStorageCapacityList) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *CSIStorageCapacityList) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CSIStorageCapacityList) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Items) > 0 { + for iNdEx := len(m.Items) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Items[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenerated(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + { + size, err := m.ListMeta.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenerated(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil } func (m *VolumeAttachment) Marshal() (dAtA []byte, err error) { @@ -591,6 +769,44 @@ func encodeVarintGenerated(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } +func (m *CSIStorageCapacity) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.ObjectMeta.Size() + n += 1 + l + sovGenerated(uint64(l)) + if m.NodeTopology != nil { + l = m.NodeTopology.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + l = len(m.StorageClassName) + n += 1 + l + sovGenerated(uint64(l)) + if m.Capacity != nil { + l = m.Capacity.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + return n +} + +func (m *CSIStorageCapacityList) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.ListMeta.Size() + n += 1 + l + sovGenerated(uint64(l)) + if len(m.Items) > 0 { + for _, e := range m.Items { + l = e.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + } + return n +} + func (m *VolumeAttachment) Size() (n int) { if m == nil { return 0 @@ -700,6 +916,35 @@ func sovGenerated(x uint64) (n int) { func sozGenerated(x uint64) (n int) { return sovGenerated(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } +func (this *CSIStorageCapacity) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&CSIStorageCapacity{`, + `ObjectMeta:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.ObjectMeta), "ObjectMeta", "v1.ObjectMeta", 1), `&`, ``, 1) + `,`, + `NodeTopology:` + strings.Replace(fmt.Sprintf("%v", this.NodeTopology), "LabelSelector", "v1.LabelSelector", 1) + `,`, + `StorageClassName:` + fmt.Sprintf("%v", this.StorageClassName) + `,`, + `Capacity:` + strings.Replace(fmt.Sprintf("%v", this.Capacity), "Quantity", "resource.Quantity", 1) + `,`, + `}`, + }, "") + return s +} +func (this *CSIStorageCapacityList) String() string { + if this == nil { + return "nil" + } + repeatedStringForItems := "[]CSIStorageCapacity{" + for _, f := range this.Items { + repeatedStringForItems += strings.Replace(strings.Replace(f.String(), "CSIStorageCapacity", "CSIStorageCapacity", 1), `&`, ``, 1) + "," + } + repeatedStringForItems += "}" + s := strings.Join([]string{`&CSIStorageCapacityList{`, + `ListMeta:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.ListMeta), "ListMeta", "v1.ListMeta", 1), `&`, ``, 1) + `,`, + `Items:` + repeatedStringForItems + `,`, + `}`, + }, "") + return s +} func (this *VolumeAttachment) String() string { if this == nil { return "nil" @@ -793,6 +1038,316 @@ func valueToStringGenerated(v interface{}) string { pv := reflect.Indirect(rv).Interface() return fmt.Sprintf("*%v", pv) } +func (m *CSIStorageCapacity) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: CSIStorageCapacity: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CSIStorageCapacity: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ObjectMeta", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ObjectMeta.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NodeTopology", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.NodeTopology == nil { + m.NodeTopology = &v1.LabelSelector{} + } + if err := m.NodeTopology.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StorageClassName", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.StorageClassName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Capacity", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Capacity == nil { + m.Capacity = &resource.Quantity{} + } + if err := m.Capacity.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenerated(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CSIStorageCapacityList) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: CSIStorageCapacityList: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CSIStorageCapacityList: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ListMeta", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ListMeta.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Items", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Items = append(m.Items, CSIStorageCapacity{}) + if err := m.Items[len(m.Items)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenerated(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *VolumeAttachment) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/staging/src/k8s.io/api/storage/v1alpha1/generated.proto b/staging/src/k8s.io/api/storage/v1alpha1/generated.proto index 76019639240..40a76405181 100644 --- a/staging/src/k8s.io/api/storage/v1alpha1/generated.proto +++ b/staging/src/k8s.io/api/storage/v1alpha1/generated.proto @@ -22,6 +22,7 @@ syntax = 'proto2'; package k8s.io.api.storage.v1alpha1; import "k8s.io/api/core/v1/generated.proto"; +import "k8s.io/apimachinery/pkg/api/resource/generated.proto"; import "k8s.io/apimachinery/pkg/apis/meta/v1/generated.proto"; import "k8s.io/apimachinery/pkg/runtime/generated.proto"; import "k8s.io/apimachinery/pkg/runtime/schema/generated.proto"; @@ -29,6 +30,80 @@ import "k8s.io/apimachinery/pkg/runtime/schema/generated.proto"; // Package-wide variables from generator "generated". option go_package = "v1alpha1"; +// CSIStorageCapacity stores the result of one CSI GetCapacity call. +// For a given StorageClass, this describes the available capacity in a +// particular topology segment. This can be used when considering where to +// instantiate new PersistentVolumes. +// +// For example this can express things like: +// - StorageClass "standard" has "1234 GiB" available in "topology.kubernetes.io/zone=us-east1" +// - StorageClass "localssd" has "10 GiB" available in "kubernetes.io/hostname=knode-abc123" +// +// The following three cases all imply that no capacity is available for +// a certain combination: +// - no object exists with suitable topology and storage class name +// - such an object exists, but the capacity is unset +// - such an object exists, but the capacity is zero +// +// The producer of these objects can decide which approach is more suitable. +// +// This is an alpha feature and only available when the CSIStorageCapacity feature is enabled. +message CSIStorageCapacity { + // Standard object's metadata. The name has no particular meaning. It must be + // be a DNS subdomain (dots allowed, 253 characters). To ensure that + // there are no conflicts with other CSI drivers on the cluster, the recommendation + // is to use csisc-, a generated name, or a reverse-domain name which ends + // with the unique CSI driver name. + // + // Objects are namespaced. + // + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata + // +optional + optional k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta metadata = 1; + + // NodeTopology defines which nodes have access to the storage + // for which capacity was reported. If not set, the storage is + // not accessible from any node in the cluster. If empty, the + // storage is accessible from all nodes. This field is + // immutable. + // + // +optional + optional k8s.io.apimachinery.pkg.apis.meta.v1.LabelSelector nodeTopology = 2; + + // The name of the StorageClass that the reported capacity applies to. + // It must meet the same requirements as the name of a StorageClass + // object (non-empty, DNS subdomain). If that object no longer exists, + // the CSIStorageCapacity object is obsolete and should be removed by its + // creator. + // This field is immutable. + optional string storageClassName = 3; + + // Capacity is the value reported by the CSI driver in its GetCapacityResponse + // for a GetCapacityRequest with topology and parameters that match the + // previous fields. + // + // The semantic is currently (CSI spec 1.2) defined as: + // The available capacity, in bytes, of the storage that can be used + // to provision volumes. If not set, that information is currently + // unavailable and treated like zero capacity. + // + // +optional + optional k8s.io.apimachinery.pkg.api.resource.Quantity capacity = 4; +} + +// CSIStorageCapacityList is a collection of CSIStorageCapacity objects. +message CSIStorageCapacityList { + // Standard list metadata + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata + // +optional + optional k8s.io.apimachinery.pkg.apis.meta.v1.ListMeta metadata = 1; + + // Items is the list of CSIStorageCapacity objects. + // +listType=map + // +listMapKey=name + repeated CSIStorageCapacity items = 2; +} + // VolumeAttachment captures the intent to attach or detach the specified volume // to/from the specified node. // diff --git a/staging/src/k8s.io/api/storage/v1alpha1/register.go b/staging/src/k8s.io/api/storage/v1alpha1/register.go index 7b81ee49c2b..779c858028c 100644 --- a/staging/src/k8s.io/api/storage/v1alpha1/register.go +++ b/staging/src/k8s.io/api/storage/v1alpha1/register.go @@ -43,6 +43,8 @@ func addKnownTypes(scheme *runtime.Scheme) error { scheme.AddKnownTypes(SchemeGroupVersion, &VolumeAttachment{}, &VolumeAttachmentList{}, + &CSIStorageCapacity{}, + &CSIStorageCapacityList{}, ) metav1.AddToGroupVersion(scheme, SchemeGroupVersion) diff --git a/staging/src/k8s.io/api/storage/v1alpha1/types.go b/staging/src/k8s.io/api/storage/v1alpha1/types.go index 39408857c26..5e65bcebcf9 100644 --- a/staging/src/k8s.io/api/storage/v1alpha1/types.go +++ b/staging/src/k8s.io/api/storage/v1alpha1/types.go @@ -18,6 +18,7 @@ package v1alpha1 import ( "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -134,3 +135,84 @@ type VolumeError struct { // +optional Message string `json:"message,omitempty" protobuf:"bytes,2,opt,name=message"` } + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// CSIStorageCapacity stores the result of one CSI GetCapacity call. +// For a given StorageClass, this describes the available capacity in a +// particular topology segment. This can be used when considering where to +// instantiate new PersistentVolumes. +// +// For example this can express things like: +// - StorageClass "standard" has "1234 GiB" available in "topology.kubernetes.io/zone=us-east1" +// - StorageClass "localssd" has "10 GiB" available in "kubernetes.io/hostname=knode-abc123" +// +// The following three cases all imply that no capacity is available for +// a certain combination: +// - no object exists with suitable topology and storage class name +// - such an object exists, but the capacity is unset +// - such an object exists, but the capacity is zero +// +// The producer of these objects can decide which approach is more suitable. +// +// This is an alpha feature and only available when the CSIStorageCapacity feature is enabled. +type CSIStorageCapacity struct { + metav1.TypeMeta `json:",inline"` + // Standard object's metadata. The name has no particular meaning. It must be + // be a DNS subdomain (dots allowed, 253 characters). To ensure that + // there are no conflicts with other CSI drivers on the cluster, the recommendation + // is to use csisc-, a generated name, or a reverse-domain name which ends + // with the unique CSI driver name. + // + // Objects are namespaced. + // + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata + // +optional + metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` + + // NodeTopology defines which nodes have access to the storage + // for which capacity was reported. If not set, the storage is + // not accessible from any node in the cluster. If empty, the + // storage is accessible from all nodes. This field is + // immutable. + // + // +optional + NodeTopology *metav1.LabelSelector `json:"nodeTopology,omitempty" protobuf:"bytes,2,opt,name=nodeTopology"` + + // The name of the StorageClass that the reported capacity applies to. + // It must meet the same requirements as the name of a StorageClass + // object (non-empty, DNS subdomain). If that object no longer exists, + // the CSIStorageCapacity object is obsolete and should be removed by its + // creator. + // This field is immutable. + StorageClassName string `json:"storageClassName" protobuf:"bytes,3,name=storageClassName"` + + // Capacity is the value reported by the CSI driver in its GetCapacityResponse + // for a GetCapacityRequest with topology and parameters that match the + // previous fields. + // + // The semantic is currently (CSI spec 1.2) defined as: + // The available capacity, in bytes, of the storage that can be used + // to provision volumes. If not set, that information is currently + // unavailable and treated like zero capacity. + // + // +optional + Capacity *resource.Quantity `json:"capacity,omitempty" protobuf:"bytes,4,opt,name=capacity"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// CSIStorageCapacityList is a collection of CSIStorageCapacity objects. +type CSIStorageCapacityList struct { + metav1.TypeMeta `json:",inline"` + // Standard list metadata + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata + // +optional + metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` + + // Items is the list of CSIStorageCapacity objects. + // +listType=map + // +listMapKey=name + Items []CSIStorageCapacity `json:"items" protobuf:"bytes,2,rep,name=items"` +} diff --git a/staging/src/k8s.io/api/storage/v1alpha1/types_swagger_doc_generated.go b/staging/src/k8s.io/api/storage/v1alpha1/types_swagger_doc_generated.go index 2e821616649..51778d183d6 100644 --- a/staging/src/k8s.io/api/storage/v1alpha1/types_swagger_doc_generated.go +++ b/staging/src/k8s.io/api/storage/v1alpha1/types_swagger_doc_generated.go @@ -27,6 +27,28 @@ package v1alpha1 // Those methods can be generated by using hack/update-generated-swagger-docs.sh // AUTO-GENERATED FUNCTIONS START HERE. DO NOT EDIT. +var map_CSIStorageCapacity = map[string]string{ + "": "CSIStorageCapacity stores the result of one CSI GetCapacity call. For a given StorageClass, this describes the available capacity in a particular topology segment. This can be used when considering where to instantiate new PersistentVolumes.\n\nFor example this can express things like: - StorageClass \"standard\" has \"1234 GiB\" available in \"topology.kubernetes.io/zone=us-east1\" - StorageClass \"localssd\" has \"10 GiB\" available in \"kubernetes.io/hostname=knode-abc123\"\n\nThe following three cases all imply that no capacity is available for a certain combination: - no object exists with suitable topology and storage class name - such an object exists, but the capacity is unset - such an object exists, but the capacity is zero\n\nThe producer of these objects can decide which approach is more suitable.\n\nThis is an alpha feature and only available when the CSIStorageCapacity feature is enabled.", + "metadata": "Standard object's metadata. The name has no particular meaning. It must be be a DNS subdomain (dots allowed, 253 characters). To ensure that there are no conflicts with other CSI drivers on the cluster, the recommendation is to use csisc-, a generated name, or a reverse-domain name which ends with the unique CSI driver name.\n\nObjects are namespaced.\n\nMore info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata", + "nodeTopology": "NodeTopology defines which nodes have access to the storage for which capacity was reported. If not set, the storage is not accessible from any node in the cluster. If empty, the storage is accessible from all nodes. This field is immutable.", + "storageClassName": "The name of the StorageClass that the reported capacity applies to. It must meet the same requirements as the name of a StorageClass object (non-empty, DNS subdomain). If that object no longer exists, the CSIStorageCapacity object is obsolete and should be removed by its creator. This field is immutable.", + "capacity": "Capacity is the value reported by the CSI driver in its GetCapacityResponse for a GetCapacityRequest with topology and parameters that match the previous fields.\n\nThe semantic is currently (CSI spec 1.2) defined as: The available capacity, in bytes, of the storage that can be used to provision volumes. If not set, that information is currently unavailable and treated like zero capacity.", +} + +func (CSIStorageCapacity) SwaggerDoc() map[string]string { + return map_CSIStorageCapacity +} + +var map_CSIStorageCapacityList = map[string]string{ + "": "CSIStorageCapacityList is a collection of CSIStorageCapacity objects.", + "metadata": "Standard list metadata More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata", + "items": "Items is the list of CSIStorageCapacity objects.", +} + +func (CSIStorageCapacityList) SwaggerDoc() map[string]string { + return map_CSIStorageCapacityList +} + var map_VolumeAttachment = map[string]string{ "": "VolumeAttachment captures the intent to attach or detach the specified volume to/from the specified node.\n\nVolumeAttachment objects are non-namespaced.", "metadata": "Standard object metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata", diff --git a/staging/src/k8s.io/api/storage/v1alpha1/zz_generated.deepcopy.go b/staging/src/k8s.io/api/storage/v1alpha1/zz_generated.deepcopy.go index 3debf9df108..7f3b357ba8e 100644 --- a/staging/src/k8s.io/api/storage/v1alpha1/zz_generated.deepcopy.go +++ b/staging/src/k8s.io/api/storage/v1alpha1/zz_generated.deepcopy.go @@ -21,10 +21,80 @@ limitations under the License. package v1alpha1 import ( - v1 "k8s.io/api/core/v1" + corev1 "k8s.io/api/core/v1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 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 *CSIStorageCapacity) DeepCopyInto(out *CSIStorageCapacity) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + if in.NodeTopology != nil { + in, out := &in.NodeTopology, &out.NodeTopology + *out = new(v1.LabelSelector) + (*in).DeepCopyInto(*out) + } + if in.Capacity != nil { + in, out := &in.Capacity, &out.Capacity + x := (*in).DeepCopy() + *out = &x + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CSIStorageCapacity. +func (in *CSIStorageCapacity) DeepCopy() *CSIStorageCapacity { + if in == nil { + return nil + } + out := new(CSIStorageCapacity) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *CSIStorageCapacity) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CSIStorageCapacityList) DeepCopyInto(out *CSIStorageCapacityList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]CSIStorageCapacity, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CSIStorageCapacityList. +func (in *CSIStorageCapacityList) DeepCopy() *CSIStorageCapacityList { + if in == nil { + return nil + } + out := new(CSIStorageCapacityList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *CSIStorageCapacityList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *VolumeAttachment) DeepCopyInto(out *VolumeAttachment) { *out = *in @@ -96,7 +166,7 @@ func (in *VolumeAttachmentSource) DeepCopyInto(out *VolumeAttachmentSource) { } if in.InlineVolumeSpec != nil { in, out := &in.InlineVolumeSpec, &out.InlineVolumeSpec - *out = new(v1.PersistentVolumeSpec) + *out = new(corev1.PersistentVolumeSpec) (*in).DeepCopyInto(*out) } return diff --git a/staging/src/k8s.io/api/storage/v1beta1/generated.pb.go b/staging/src/k8s.io/api/storage/v1beta1/generated.pb.go index af4ce59f24a..8547f88fee9 100644 --- a/staging/src/k8s.io/api/storage/v1beta1/generated.pb.go +++ b/staging/src/k8s.io/api/storage/v1beta1/generated.pb.go @@ -520,91 +520,93 @@ func init() { } var fileDescriptor_7d2980599fd0de80 = []byte{ - // 1344 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x57, 0xbd, 0x6f, 0xdb, 0x46, - 0x1b, 0x37, 0x2d, 0x7f, 0x9e, 0xec, 0x44, 0xbe, 0x18, 0xef, 0xab, 0x57, 0x83, 0x64, 0xe8, 0x45, - 0x1b, 0x27, 0x48, 0xc8, 0x24, 0x48, 0x83, 0x20, 0x40, 0x07, 0xd3, 0x31, 0x50, 0x25, 0x96, 0xe3, - 0x9e, 0x8d, 0xa0, 0x08, 0x3a, 0xf4, 0x44, 0x3e, 0x91, 0x19, 0x93, 0x3c, 0x86, 0x3c, 0xa9, 0xd5, - 0xd6, 0xa9, 0x73, 0xd1, 0xa1, 0x7f, 0x41, 0xff, 0x85, 0x16, 0x68, 0x97, 0x8e, 0xcd, 0x54, 0x04, - 0x9d, 0x32, 0x09, 0x0d, 0xbb, 0x76, 0xeb, 0x66, 0x74, 0x28, 0xee, 0x78, 0x12, 0x29, 0x89, 0x8a, - 0xed, 0x0e, 0xde, 0x78, 0xcf, 0xc7, 0xef, 0xf9, 0x7e, 0xee, 0x88, 0xb6, 0x8f, 0xef, 0x47, 0xba, - 0xc3, 0x8c, 0xe3, 0x4e, 0x0b, 0x42, 0x1f, 0x38, 0x44, 0x46, 0x17, 0x7c, 0x9b, 0x85, 0x86, 0x62, - 0xd0, 0xc0, 0x31, 0x22, 0xce, 0x42, 0xda, 0x06, 0xa3, 0x7b, 0xbb, 0x05, 0x9c, 0xde, 0x36, 0xda, - 0xe0, 0x43, 0x48, 0x39, 0xd8, 0x7a, 0x10, 0x32, 0xce, 0x70, 0x25, 0x91, 0xd5, 0x69, 0xe0, 0xe8, - 0x4a, 0x56, 0x57, 0xb2, 0x95, 0x9b, 0x6d, 0x87, 0x1f, 0x75, 0x5a, 0xba, 0xc5, 0x3c, 0xa3, 0xcd, - 0xda, 0xcc, 0x90, 0x2a, 0xad, 0xce, 0x73, 0x79, 0x92, 0x07, 0xf9, 0x95, 0x40, 0x55, 0xea, 0x19, - 0xb3, 0x16, 0x0b, 0x85, 0xcd, 0x71, 0x73, 0x95, 0xbb, 0xa9, 0x8c, 0x47, 0xad, 0x23, 0xc7, 0x87, - 0xb0, 0x67, 0x04, 0xc7, 0x6d, 0x41, 0x88, 0x0c, 0x0f, 0x38, 0xcd, 0xd3, 0x32, 0xa6, 0x69, 0x85, - 0x1d, 0x9f, 0x3b, 0x1e, 0x4c, 0x28, 0xdc, 0x3b, 0x4d, 0x21, 0xb2, 0x8e, 0xc0, 0xa3, 0xe3, 0x7a, - 0xf5, 0x9f, 0x34, 0xb4, 0xbc, 0x7d, 0xd0, 0x78, 0x18, 0x3a, 0x5d, 0x08, 0xf1, 0x67, 0x68, 0x49, - 0x78, 0x64, 0x53, 0x4e, 0xcb, 0xda, 0x86, 0xb6, 0x59, 0xbc, 0x73, 0x4b, 0x4f, 0xd3, 0x35, 0x04, - 0xd6, 0x83, 0xe3, 0xb6, 0x20, 0x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xff, 0xa4, 0x5f, 0x2b, 0x66, 0xf8, 0x24, 0x8b, 0x2d, 0x4c, 0xd9, - 0x90, 0x9a, 0x9a, 0xfb, 0x17, 0xa6, 0x1e, 0xc2, 0x74, 0x53, 0x19, 0xec, 0xca, 0x0e, 0xfa, 0xef, - 0x94, 0x04, 0x9d, 0xeb, 0x5e, 0xf9, 0x4a, 0x43, 0x59, 0x1b, 0x78, 0x17, 0xcd, 0x89, 0xff, 0x59, - 0xb5, 0x61, 0xae, 0x9f, 0x6d, 0xc3, 0x1c, 0x3a, 0x1e, 0xa4, 0x8b, 0x52, 0x9c, 0x88, 0x44, 0xc1, - 0xd7, 0xd0, 0xa2, 0x07, 0x51, 0x44, 0xdb, 0xca, 0x72, 0xfa, 0xea, 0x6b, 0x26, 0x64, 0x32, 0xe0, - 0xd7, 0xef, 0xa1, 0x2b, 0x39, 0xef, 0x68, 0x5c, 0x43, 0xf3, 0x96, 0xfc, 0xe1, 0x12, 0x0e, 0xcd, - 0x9b, 0xcb, 0x62, 0xcb, 0x6c, 0xcb, 0xff, 0xac, 0x84, 0x6e, 0xde, 0x7c, 0xf5, 0xb6, 0x3a, 0xf3, - 0xfa, 0x6d, 0x75, 0xe6, 0xcd, 0xdb, 0xea, 0xcc, 0x97, 0x71, 0x55, 0x7b, 0x15, 0x57, 0xb5, 0xd7, - 0x71, 0x55, 0x7b, 0x13, 0x57, 0xb5, 0xdf, 0xe3, 0xaa, 0xf6, 0xf5, 0x1f, 0xd5, 0x99, 0x67, 0x8b, - 0x2a, 0xdf, 0xff, 0x04, 0x00, 0x00, 0xff, 0xff, 0x72, 0xff, 0xde, 0x2e, 0xe4, 0x10, 0x00, 0x00, + // 1368 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x57, 0x3d, 0x6f, 0xdb, 0xc6, + 0x1b, 0x37, 0x2d, 0xbf, 0x9e, 0xec, 0x58, 0x3e,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0xff, 0x9a, 0x70, 0x68, 0xb6, 0xb6, 0x28, 0xb6, 0xcc, 0x8e, 0xfc, 0x4d, 0x8b, + 0xe8, 0xb5, 0x9b, 0xaf, 0xde, 0x96, 0xa7, 0x5e, 0xbf, 0x2d, 0x4f, 0xbd, 0x79, 0x5b, 0x9e, 0xfa, + 0x2a, 0x2c, 0x6b, 0xaf, 0xc2, 0xb2, 0xf6, 0x3a, 0x2c, 0x6b, 0x6f, 0xc2, 0xb2, 0xf6, 0x67, 0x58, + 0xd6, 0xbe, 0xf9, 0xab, 0x3c, 0xf5, 0x6c, 0x5e, 0xe5, 0xfb, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, + 0xeb, 0xa0, 0x59, 0x1b, 0x23, 0x11, 0x00, 0x00, } func (m *CSIDriver) Marshal() (dAtA []byte, err error) { @@ -717,6 +719,16 @@ func (m *CSIDriverSpec) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.StorageCapacity != nil { + i-- + if *m.StorageCapacity { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x20 + } if len(m.VolumeLifecycleModes) > 0 { for iNdEx := len(m.VolumeLifecycleModes) - 1; iNdEx >= 0; iNdEx-- { i -= len(m.VolumeLifecycleModes[iNdEx]) @@ -1475,6 +1487,9 @@ func (m *CSIDriverSpec) Size() (n int) { n += 1 + l + sovGenerated(uint64(l)) } } + if m.StorageCapacity != nil { + n += 2 + } return n } @@ -1763,6 +1778,7 @@ func (this *CSIDriverSpec) String() string { `AttachRequired:` + valueToStringGenerated(this.AttachRequired) + `,`, `PodInfoOnMount:` + valueToStringGenerated(this.PodInfoOnMount) + `,`, `VolumeLifecycleModes:` + fmt.Sprintf("%v", this.VolumeLifecycleModes) + `,`, + `StorageCapacity:` + valueToStringGenerated(this.StorageCapacity) + `,`, `}`, }, "") return s @@ -2315,6 +2331,27 @@ func (m *CSIDriverSpec) Unmarshal(dAtA []byte) error { } m.VolumeLifecycleModes = append(m.VolumeLifecycleModes, VolumeLifecycleMode(dAtA[iNdEx:postIndex])) iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field StorageCapacity", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + b := bool(v != 0) + m.StorageCapacity = &b default: iNdEx = preIndex skippy, err := skipGenerated(dAtA[iNdEx:]) diff --git a/staging/src/k8s.io/api/storage/v1beta1/generated.proto b/staging/src/k8s.io/api/storage/v1beta1/generated.proto index 373a154b112..8d934a3c655 100644 --- a/staging/src/k8s.io/api/storage/v1beta1/generated.proto +++ b/staging/src/k8s.io/api/storage/v1beta1/generated.proto @@ -119,6 +119,26 @@ message CSIDriverSpec { // more modes may be added in the future. // +optional repeated string volumeLifecycleModes = 3; + + // If set to true, storageCapacity indicates that the CSI + // volume driver wants pod scheduling to consider the storage + // capacity that the driver deployment will report by creating + // CSIStorageCapacity objects with capacity information. + // + // The check can be enabled immediately when deploying a driver. + // In that case, provisioning new volumes with late binding + // will pause until the driver deployment has published + // some suitable CSIStorageCapacity object. + // + // Alternatively, the driver can be deployed with the field + // unset or false and it can be flipped later when storage + // capacity information has been published. + // + // This is an alpha field and only available when the CSIStorageCapacity + // feature is enabled. The default is false. + // + // +optional + optional bool storageCapacity = 4; } // DEPRECATED - This group version of CSINode is deprecated by storage/v1/CSINode. diff --git a/staging/src/k8s.io/api/storage/v1beta1/types.go b/staging/src/k8s.io/api/storage/v1beta1/types.go index 95f647ab2f3..40d8ba20334 100644 --- a/staging/src/k8s.io/api/storage/v1beta1/types.go +++ b/staging/src/k8s.io/api/storage/v1beta1/types.go @@ -335,6 +335,27 @@ type CSIDriverSpec struct { // more modes may be added in the future. // +optional VolumeLifecycleModes []VolumeLifecycleMode `json:"volumeLifecycleModes,omitempty" protobuf:"bytes,3,opt,name=volumeLifecycleModes"` + + // If set to true, storageCapacity indicates that the CSI + // volume driver wants pod scheduling to consider the storage + // capacity that the driver deployment will report by creating + // CSIStorageCapacity objects with capacity information. + // + // + // The check can be enabled immediately when deploying a driver. + // In that case, provisioning new volumes with late binding + // will pause until the driver deployment has published + // some suitable CSIStorageCapacity object. + // + // Alternatively, the driver can be deployed with the field + // unset or false and it can be flipped later when storage + // capacity information has been published. + // + // This is an alpha field and only available when the CSIStorageCapacity + // feature is enabled. The default is false. + // + // +optional + StorageCapacity *bool `json:"storageCapacity,omitempty" protobuf:"bytes,4,opt,name=storageCapacity"` } // VolumeLifecycleMode is an enumeration of possible usage modes for a volume diff --git a/staging/src/k8s.io/api/storage/v1beta1/types_swagger_doc_generated.go b/staging/src/k8s.io/api/storage/v1beta1/types_swagger_doc_generated.go index 53fa666ba0a..278d73f1bfe 100644 --- a/staging/src/k8s.io/api/storage/v1beta1/types_swagger_doc_generated.go +++ b/staging/src/k8s.io/api/storage/v1beta1/types_swagger_doc_generated.go @@ -52,6 +52,7 @@ var map_CSIDriverSpec = map[string]string{ "attachRequired": "attachRequired indicates this CSI volume driver requires an attach operation (because it implements the CSI ControllerPublishVolume() method), and that the Kubernetes attach detach controller should call the attach volume interface which checks the volumeattachment status and waits until the volume is attached before proceeding to mounting. The CSI external-attacher coordinates with CSI volume driver and updates the volumeattachment status when the attach operation is complete. If the CSIDriverRegistry feature gate is enabled and the value is specified to false, the attach operation will be skipped. Otherwise the attach operation will be called.", "podInfoOnMount": "If set to true, podInfoOnMount indicates this CSI volume driver requires additional pod information (like podName, podUID, etc.) during mount operations. If set to false, pod information will not be passed on mount. Default is false. The CSI driver specifies podInfoOnMount as part of driver deployment. If true, Kubelet will pass pod information as VolumeContext in the CSI NodePublishVolume() calls. The CSI driver is responsible for parsing and validating the information passed in as VolumeContext. The following VolumeConext will be passed if podInfoOnMount is set to true. This list might grow, but the prefix will be used. \"csi.storage.k8s.io/pod.name\": pod.Name \"csi.storage.k8s.io/pod.namespace\": pod.Namespace \"csi.storage.k8s.io/pod.uid\": string(pod.UID) \"csi.storage.k8s.io/ephemeral\": \"true\" iff the volume is an ephemeral inline volume\n defined by a CSIVolumeSource, otherwise \"false\"\n\n\"csi.storage.k8s.io/ephemeral\" is a new feature in Kubernetes 1.16. It is only required for drivers which support both the \"Persistent\" and \"Ephemeral\" VolumeLifecycleMode. Other drivers can leave pod info disabled and/or ignore this field. As Kubernetes 1.15 doesn't support this field, drivers can only support one mode when deployed on such a cluster and the deployment determines which mode that is, for example via a command line parameter of the driver.", "volumeLifecycleModes": "VolumeLifecycleModes defines what kind of volumes this CSI volume driver supports. The default if the list is empty is \"Persistent\", which is the usage defined by the CSI specification and implemented in Kubernetes via the usual PV/PVC mechanism. The other mode is \"Ephemeral\". In this mode, volumes are defined inline inside the pod spec with CSIVolumeSource and their lifecycle is tied to the lifecycle of that pod. A driver has to be aware of this because it is only going to get a NodePublishVolume call for such a volume. For more information about implementing this mode, see https://kubernetes-csi.github.io/docs/ephemeral-local-volumes.html A driver can support one or more of these modes and more modes may be added in the future.", + "storageCapacity": "If set to true, storageCapacity indicates that the CSI volume driver wants pod scheduling to consider the storage capacity that the driver deployment will report by creating CSIStorageCapacity objects with capacity information.\n\nThe check can be enabled immediately when deploying a driver. In that case, provisioning new volumes with late binding will pause until the driver deployment has published some suitable CSIStorageCapacity object.\n\nAlternatively, the driver can be deployed with the field unset or false and it can be flipped later when storage capacity information has been published.\n\nThis is an alpha field and only available when the CSIStorageCapacity feature is enabled. The default is false.", } func (CSIDriverSpec) SwaggerDoc() map[string]string { diff --git a/staging/src/k8s.io/api/storage/v1beta1/zz_generated.deepcopy.go b/staging/src/k8s.io/api/storage/v1beta1/zz_generated.deepcopy.go index 52433fcdf2c..19979cf9733 100644 --- a/staging/src/k8s.io/api/storage/v1beta1/zz_generated.deepcopy.go +++ b/staging/src/k8s.io/api/storage/v1beta1/zz_generated.deepcopy.go @@ -103,6 +103,11 @@ func (in *CSIDriverSpec) DeepCopyInto(out *CSIDriverSpec) { *out = make([]VolumeLifecycleMode, len(*in)) copy(*out, *in) } + if in.StorageCapacity != nil { + in, out := &in.StorageCapacity, &out.StorageCapacity + *out = new(bool) + **out = **in + } return } diff --git a/staging/src/k8s.io/api/testdata/HEAD/storage.k8s.io.v1.CSIDriver.json b/staging/src/k8s.io/api/testdata/HEAD/storage.k8s.io.v1.CSIDriver.json index 3027013e9e1..d590a43bb60 100644 --- a/staging/src/k8s.io/api/testdata/HEAD/storage.k8s.io.v1.CSIDriver.json +++ b/staging/src/k8s.io/api/testdata/HEAD/storage.k8s.io.v1.CSIDriver.json @@ -45,6 +45,7 @@ "podInfoOnMount": false, "volumeLifecycleModes": [ "r鯹)晿\u003co,c鮽ort昍řČ扷5ƗǸ" - ] + ], + "storageCapacity": true } } \ No newline at end of file diff --git a/staging/src/k8s.io/api/testdata/HEAD/storage.k8s.io.v1.CSIDriver.pb b/staging/src/k8s.io/api/testdata/HEAD/storage.k8s.io.v1.CSIDriver.pb index 9a95870585d..8fe4cf4e5f8 100644 Binary files a/staging/src/k8s.io/api/testdata/HEAD/storage.k8s.io.v1.CSIDriver.pb and b/staging/src/k8s.io/api/testdata/HEAD/storage.k8s.io.v1.CSIDriver.pb differ diff --git a/staging/src/k8s.io/api/testdata/HEAD/storage.k8s.io.v1.CSIDriver.yaml b/staging/src/k8s.io/api/testdata/HEAD/storage.k8s.io.v1.CSIDriver.yaml index 6121efe66f9..f942706f0ad 100644 --- a/staging/src/k8s.io/api/testdata/HEAD/storage.k8s.io.v1.CSIDriver.yaml +++ b/staging/src/k8s.io/api/testdata/HEAD/storage.k8s.io.v1.CSIDriver.yaml @@ -32,5 +32,6 @@ metadata: spec: attachRequired: false podInfoOnMount: false + storageCapacity: true volumeLifecycleModes: - r鯹)晿