diff --git a/pkg/controller/volume/attachdetach/attach_detach_controller.go b/pkg/controller/volume/attachdetach/attach_detach_controller.go index b0b941008ad42..58da718521a00 100644 --- a/pkg/controller/volume/attachdetach/attach_detach_controller.go +++ b/pkg/controller/volume/attachdetach/attach_detach_controller.go @@ -148,7 +148,7 @@ func NewAttachDetachController( } // Install required CSI CRDs on API server - if utilfeature.DefaultFeatureGate.Enabled(features.CSICrdAutoInstall) { + if utilfeature.DefaultFeatureGate.Enabled(features.CSICRDAutoInstall) { adc.installCRDs() } @@ -685,15 +685,16 @@ func (adc *attachDetachController) installCRDs() error { } res, err := adc.crdClient.ApiextensionsV1beta1().CustomResourceDefinitions().Create(crd) - if err != nil && !apierrors.IsAlreadyExists(err) { - glog.Errorf("failed to create CSIDrivers CRD: %#v, err: %#v", - res, err) + if err == nil { + glog.Infof("CSIDrivers CRD created successfully: %#v", + res) } else if apierrors.IsAlreadyExists(err) { glog.Warningf("CSIDrivers CRD already exists: %#v, err: %#v", res, err) } else { - glog.Infof("CSIDrivers CRD created successfully: %#v", - res) + glog.Errorf("failed to create CSIDrivers CRD: %#v, err: %#v", + res, err) + return err } crd = &apiextensionsv1beta1.CustomResourceDefinition{ @@ -712,15 +713,16 @@ func (adc *attachDetachController) installCRDs() error { } res, err = adc.crdClient.ApiextensionsV1beta1().CustomResourceDefinitions().Create(crd) - if err != nil && !apierrors.IsAlreadyExists(err) { - glog.Errorf("failed to create CSINodeInfo CRD: %#v, err: %#v", - res, err) + if err == nil { + glog.Infof("CSINodeInfo CRD created successfully: %#v", + res) } else if apierrors.IsAlreadyExists(err) { glog.Warningf("CSINodeInfo CRD already exists: %#v, err: %#v", res, err) } else { - glog.Infof("CSINodeInfo CRD created successfully: %#v", - res) + glog.Errorf("failed to create CSINodeInfo CRD: %#v, err: %#v", + res, err) + return err } return nil diff --git a/pkg/features/kube_features.go b/pkg/features/kube_features.go index 56a7ed33e7d9d..84ee3d4f03f1b 100644 --- a/pkg/features/kube_features.go +++ b/pkg/features/kube_features.go @@ -207,9 +207,8 @@ const ( // owner: @saad-ali // alpha: v1.12 - // // Enable automatic installation of CRD for csi.storage.k8s.io API objects. - CSICrdAutoInstall utilfeature.Feature = "CSICrdAutoInstall" + CSICRDAutoInstall utilfeature.Feature = "CSICRDAutoInstall" // owner @MrHohn // beta: v1.10 @@ -425,7 +424,7 @@ var defaultKubernetesFeatureGates = map[utilfeature.Feature]utilfeature.FeatureS MountContainers: {Default: false, PreRelease: utilfeature.Alpha}, VolumeScheduling: {Default: true, PreRelease: utilfeature.Beta}, CSIPersistentVolume: {Default: true, PreRelease: utilfeature.Beta}, - CSICrdAutoInstall: {Default: false, PreRelease: utilfeature.Alpha}, + CSICRDAutoInstall: {Default: false, PreRelease: utilfeature.Alpha}, CustomPodDNS: {Default: true, PreRelease: utilfeature.Beta}, BlockVolume: {Default: false, PreRelease: utilfeature.Alpha}, StorageObjectInUseProtection: {Default: true, PreRelease: utilfeature.GA}, diff --git a/staging/src/k8s.io/csi-api/pkg/apis/csi/v1alpha1/doc.go b/staging/src/k8s.io/csi-api/pkg/apis/csi/v1alpha1/doc.go index 59bbb3f3f0aa1..67f44299aa5eb 100644 --- a/staging/src/k8s.io/csi-api/pkg/apis/csi/v1alpha1/doc.go +++ b/staging/src/k8s.io/csi-api/pkg/apis/csi/v1alpha1/doc.go @@ -14,8 +14,9 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Package v1alpha1 provides alpha API for CSI API objects. // +k8s:deepcopy-gen=package,register // +groupName=csi.storage.k8s.io // +k8s:openapi-gen=true + +// Package v1alpha1 provides alpha API for CSI API objects. package v1alpha1 // import "k8s.io/csi-api/pkg/apis/csi/v1alpha1" diff --git a/staging/src/k8s.io/csi-api/pkg/apis/csi/v1alpha1/types.go b/staging/src/k8s.io/csi-api/pkg/apis/csi/v1alpha1/types.go index 457942b1f86f6..d2fbe0aa5713a 100644 --- a/staging/src/k8s.io/csi-api/pkg/apis/csi/v1alpha1/types.go +++ b/staging/src/k8s.io/csi-api/pkg/apis/csi/v1alpha1/types.go @@ -50,29 +50,34 @@ type CSIDriverList struct { // +optional metav1.ListMeta `json:"metadata,omitempty"` - // Items is the list of CSIDriver + // items is the list of CSIDriver Items []CSIDriver `json:"items"` } // CSIDriverSpec is the specification of a CSIDriver. type CSIDriverSpec struct { - // Indicates this CSI volume driver requires an attach operation (because it - // implements the CSI ControllerPublishVolume() method), and that Kubernetes - // should call attach and wait for any attach operation to complete before - // proceeding to mounting. + // attachRequired indicates this CSI volume driver requires an attach + // operation (because it implements the CSI ControllerPublishVolume() + // method), and that Kubernetes should call attach and wait for any attach + // operation to complete before proceeding to mounting. // If value is not specified, default is false -- meaning attach will not be // called. // +optional AttachRequired *bool `json:"attachRequired"` - // Indicates this CSI volume driver requires additional pod information - // (like podName, podUID, etc.) during mount operations. - // If this is set to true, Kubelet will pass pod information as + // If specified, podInfoRequiredOnMount indicates this CSI volume driver + // requires additional pod information (like podName, podUID, etc.) during + // mount operations. + // If value is not specified, pod information will not be passed on mount. + // If value is set to a valid version, Kubelet will pass pod information as // VolumeAttributes in the CSI NodePublishVolume() calls. - // If value is not specified, default is false -- meaning pod information - // will not be passed on mount. + // Supported versions: + // Version "v1" will pass the following ValueAttributes + // "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) // +optional - PodInfoRequiredOnMount *bool `json:"podInfoRequiredOnMount"` + PodInfoOnMountVersion *string `json:"podInfoOnMountVersion"` } // +genclient @@ -82,24 +87,42 @@ type CSIDriverSpec struct { // CSINodeInfo holds information about all CSI drivers installed on a node. type CSINodeInfo struct { metav1.TypeMeta `json:",inline"` - // ObjectMeta.Name must be node name. + + // metadata.name must be the Kubernetes node name. metav1.ObjectMeta `json:"metadata,omitempty"` // List of CSI drivers running on the node and their properties. - CSIDrivers []CSIDriverInfo `json:"csiDrivers"` + // +patchMergeKey=driver + // +patchStrategy=merge + CSIDrivers []CSIDriverInfo `json:"csiDrivers" patchStrategy:"merge" patchMergeKey:"driver"` } // CSIDriverInfo contains information about one CSI driver installed on a node. type CSIDriverInfo struct { - // Driver is the name of the CSI driver that this object refers to. + // driver is the name of the CSI driver that this object refers to. // This MUST be the same name returned by the CSI GetPluginName() call for // that driver. Driver string `json:"driver"` - // ID of the node from the driver point of view. + // nodeID of the node from the driver point of view. + // This field enables Kubernetes to communicate with storage systems that do + // not share the same nomenclature for nodes. For example, Kubernetes may + // refer to a given node as "node1", but the storage system may refer to + // the same node as "nodeA". When Kubernetes issues a command to the storage + // system to attach a volume to a specific node, it can use this field to + // refer to the node name using the ID that the storage system will + // understand, e.g. "nodeA" instead of "node1". NodeID string `json:"nodeID"` - // Topology keys reported by the driver on the node. + // topologyKeys is the list of keys supported by the driver. + // When a driver is initialized on a cluster, it provides a set of topology + // keys that it understands (e.g. "company.com/zone", "company.com/region"). + // When a driver is initialized on a node it provides the same topology keys + // along with values that kubelet applies to the coresponding node API + // object as labels. + // When Kubernetes does topology aware provisioning, it can use this list to + // determine which labels it should retrieve from the node object and pass + // back to the driver. TopologyKeys []string `json:"topologyKeys"` } @@ -108,10 +131,12 @@ type CSIDriverInfo struct { // CSINodeInfoList is a collection of CSINodeInfo objects. type CSINodeInfoList struct { metav1.TypeMeta `json:",inline"` + // Standard list metadata // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata // +optional metav1.ListMeta `json:"metadata,omitempty"` - // Items is the list of CSINodeInfo + + // items is the list of CSINodeInfo Items []CSINodeInfo `json:"items"` } diff --git a/staging/src/k8s.io/csi-api/pkg/apis/csi/v1alpha1/zz_generated.deepcopy.go b/staging/src/k8s.io/csi-api/pkg/apis/csi/v1alpha1/zz_generated.deepcopy.go index 5ab1104675b07..aa9ccbbaae852 100644 --- a/staging/src/k8s.io/csi-api/pkg/apis/csi/v1alpha1/zz_generated.deepcopy.go +++ b/staging/src/k8s.io/csi-api/pkg/apis/csi/v1alpha1/zz_generated.deepcopy.go @@ -113,9 +113,9 @@ func (in *CSIDriverSpec) DeepCopyInto(out *CSIDriverSpec) { *out = new(bool) **out = **in } - if in.PodInfoRequiredOnMount != nil { - in, out := &in.PodInfoRequiredOnMount, &out.PodInfoRequiredOnMount - *out = new(bool) + if in.PodInfoOnMountVersion != nil { + in, out := &in.PodInfoOnMountVersion, &out.PodInfoOnMountVersion + *out = new(string) **out = **in } return