Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

various operator fixes #830

Merged
merged 2 commits into from
Dec 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 20 additions & 12 deletions deploy/crd/pmem-csi.intel.com_deployments.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,10 @@ spec:
type: object
type: object
deviceMode:
description: DeviceMode to use to manage PMEM devices. One of lvm,
direct
description: DeviceMode to use to manage PMEM devices.
enum:
- lvm
- direct
type: string
image:
description: PMEM-CSI driver container image
Expand All @@ -106,7 +108,7 @@ spec:
by the operator.
type: object
logLevel:
description: LogLevel number for the log verbosity kubebuilder:default=3
description: LogLevel number for the log verbosity
type: integer
nodeControllerCert:
description: NodeControllerCert encoded certificate signed by a CA
Expand Down Expand Up @@ -158,9 +160,11 @@ spec:
type: object
pmemPercentage:
description: PMEMPercentage represents the percentage of space to
be used by the driver in each PMEM region on every node. This is
only valid for driver in LVM mode. -kubebuilder:validation:Minimum=1
-kubebuilder:validation:Maximum=100 -kubebuilder:default=100
be used by the driver in each PMEM region on every node. Unset (=
zero) selects the default of 100%. This is only valid for driver
in LVM mode.
maximum: 100
minimum: 0
type: integer
provisionerImage:
description: ProvisionerImage CSI provisioner sidecar image
Expand Down Expand Up @@ -315,8 +319,10 @@ spec:
type: object
type: object
deviceMode:
description: DeviceMode to use to manage PMEM devices. One of lvm,
direct
description: DeviceMode to use to manage PMEM devices.
enum:
- lvm
- direct
type: string
image:
description: PMEM-CSI driver container image
Expand All @@ -334,7 +340,7 @@ spec:
by the operator.
type: object
logLevel:
description: LogLevel number for the log verbosity kubebuilder:default=3
description: LogLevel number for the log verbosity
type: integer
nodeControllerCert:
description: NodeControllerCert encoded certificate signed by a CA
Expand Down Expand Up @@ -414,9 +420,11 @@ spec:
type: object
pmemPercentage:
description: PMEMPercentage represents the percentage of space to
be used by the driver in each PMEM region on every node. This is
only valid for driver in LVM mode. -kubebuilder:validation:Minimum=1
-kubebuilder:validation:Maximum=100 -kubebuilder:default=100
be used by the driver in each PMEM region on every node. Unset (=
zero) selects the default of 100%. This is only valid for driver
in LVM mode.
maximum: 100
minimum: 0
type: integer
provisionerImage:
description: ProvisionerImage CSI provisioner sidecar image
Expand Down
22 changes: 16 additions & 6 deletions deploy/crd/pmem-csi.intel.com_deployments_webhook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ spec:
type: object
type: object
deviceMode:
description: DeviceMode to use to manage PMEM devices. One of lvm, direct
description: DeviceMode to use to manage PMEM devices.
enum:
- lvm
- direct
type: string
image:
description: PMEM-CSI driver container image
Expand All @@ -104,7 +107,7 @@ spec:
description: Labels contains additional labels for all objects created by the operator.
type: object
logLevel:
description: LogLevel number for the log verbosity kubebuilder:default=3
description: LogLevel number for the log verbosity
type: integer
nodeControllerCert:
description: NodeControllerCert encoded certificate signed by a CA for node controller server authentication If not provided, provisioned one by the operator using self-signed CA
Expand Down Expand Up @@ -145,7 +148,9 @@ spec:
description: NodeSelector node labels to use for selection of driver node
type: object
pmemPercentage:
description: PMEMPercentage represents the percentage of space to be used by the driver in each PMEM region on every node. This is only valid for driver in LVM mode. -kubebuilder:validation:Minimum=1 -kubebuilder:validation:Maximum=100 -kubebuilder:default=100
description: PMEMPercentage represents the percentage of space to be used by the driver in each PMEM region on every node. Unset (= zero) selects the default of 100%. This is only valid for driver in LVM mode.
maximum: 100
minimum: 0
type: integer
provisionerImage:
description: ProvisionerImage CSI provisioner sidecar image
Expand Down Expand Up @@ -280,7 +285,10 @@ spec:
type: object
type: object
deviceMode:
description: DeviceMode to use to manage PMEM devices. One of lvm, direct
description: DeviceMode to use to manage PMEM devices.
enum:
- lvm
- direct
type: string
image:
description: PMEM-CSI driver container image
Expand All @@ -297,7 +305,7 @@ spec:
description: Labels contains additional labels for all objects created by the operator.
type: object
logLevel:
description: LogLevel number for the log verbosity kubebuilder:default=3
description: LogLevel number for the log verbosity
type: integer
nodeControllerCert:
description: NodeControllerCert encoded certificate signed by a CA for node controller server authentication If not provided, provisioned one by the operator using self-signed CA
Expand Down Expand Up @@ -360,7 +368,9 @@ spec:
description: NodeSelector node labels to use for selection of driver node
type: object
pmemPercentage:
description: PMEMPercentage represents the percentage of space to be used by the driver in each PMEM region on every node. This is only valid for driver in LVM mode. -kubebuilder:validation:Minimum=1 -kubebuilder:validation:Maximum=100 -kubebuilder:default=100
description: PMEMPercentage represents the percentage of space to be used by the driver in each PMEM region on every node. Unset (= zero) selects the default of 100%. This is only valid for driver in LVM mode.
maximum: 100
minimum: 0
type: integer
provisionerImage:
description: ProvisionerImage CSI provisioner sidecar image
Expand Down
4 changes: 4 additions & 0 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -1221,6 +1221,10 @@ The current API for PMEM-CSI `Deployment` resources is:

Below specification fields are valid in all API versions unless noted otherwise in the description.

The default values are used by the operator when no value is set for a
field explicitly. Those defaults can change over time and are not part
of the API specification.

|Field | Type | Description | Default Value |
|---|---|---|---|
| image | string | PMEM-CSI docker image name used for the deployment | the same image as the operator<sup>1</sup> |
Expand Down
22 changes: 17 additions & 5 deletions pkg/apis/pmemcsi/v1alpha1/deployment_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,21 @@ func (d *Deployment) ConvertTo(dst conversion.Hub) error {

// no change in other fields
out.ObjectMeta = in.ObjectMeta
out.Spec.LogLevel = in.Spec.LogLevel
out.Spec.Image = in.Spec.Image
out.Spec.CACert = in.Spec.CACert
out.Spec.PullPolicy = in.Spec.PullPolicy
Copy link
Contributor

@avalluri avalluri Dec 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pohly I googled about this missing conversions and came across about conversion-gen code generation tool, that generates the type conversion code as mentioned here. What do you think, shall we use that as a separate change or part of this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we use it, then in a separate PR.

I want to get into a stable state as quickly as possible again and using that tool may need further investigations and discussions.

out.Spec.ProvisionerImage = in.Spec.ProvisionerImage
out.Spec.NodeRegistrarImage = in.Spec.NodeRegistrarImage
out.Spec.DeviceMode = v1beta1.DeviceMode(string(in.Spec.DeviceMode))
out.Spec.LogLevel = in.Spec.LogLevel
out.Spec.RegistryCert = in.Spec.RegistryCert
out.Spec.RegistryPrivateKey = in.Spec.RegistryPrivateKey
out.Spec.NodeControllerCert = in.Spec.NodeControllerCert
out.Spec.NodeControllerPrivateKey = in.Spec.NodeControllerPrivateKey
out.Spec.CACert = in.Spec.CACert
out.Spec.NodeSelector = in.Spec.NodeSelector
out.Spec.PMEMPercentage = in.Spec.PMEMPercentage
out.Spec.Labels = in.Spec.Labels
out.Spec.KubeletDir = in.Spec.KubeletDir

out.Status.Components = nil
for _, s := range in.Status.Components {
Expand All @@ -71,7 +77,7 @@ func (d *Deployment) ConvertTo(dst conversion.Hub) error {

// +kubebuilder:docs-gen:collapse=rote conversion

klog.Infof("Coverted Object: %+v", *out)
klog.Infof("Converted Object: %+v", *out)

return nil
}
Expand All @@ -88,15 +94,21 @@ func (d *Deployment) ConvertFrom(src conversion.Hub) error {

// no change in other fields
out.ObjectMeta = in.ObjectMeta
out.Spec.LogLevel = in.Spec.LogLevel
out.Spec.Image = in.Spec.Image
out.Spec.CACert = in.Spec.CACert
out.Spec.PullPolicy = in.Spec.PullPolicy
out.Spec.ProvisionerImage = in.Spec.ProvisionerImage
out.Spec.NodeRegistrarImage = in.Spec.NodeRegistrarImage
out.Spec.DeviceMode = DeviceMode(string(in.Spec.DeviceMode))
out.Spec.LogLevel = in.Spec.LogLevel
out.Spec.RegistryCert = in.Spec.RegistryCert
out.Spec.RegistryPrivateKey = in.Spec.RegistryPrivateKey
out.Spec.NodeControllerCert = in.Spec.NodeControllerCert
out.Spec.NodeControllerPrivateKey = in.Spec.NodeControllerPrivateKey
out.Spec.CACert = in.Spec.CACert
out.Spec.NodeSelector = in.Spec.NodeSelector
out.Spec.PMEMPercentage = in.Spec.PMEMPercentage
out.Spec.Labels = in.Spec.Labels
out.Spec.KubeletDir = in.Spec.KubeletDir

out.Status.Components = nil
for _, s := range in.Status.Components {
Expand Down
23 changes: 6 additions & 17 deletions pkg/apis/pmemcsi/v1alpha1/deployment_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,6 @@ const (
DeviceModeFake DeviceMode = "fake"
)

// NOTE(avalluri): Due to below errors we stop setting
// few CRD schema fields by prefixing those lines a '-'.
// Once the below issues go fixed replace those '-' with '+'
// Setting default(+kubebuilder:default=value) for v1beta1 CRD fails, only supports since v1 CRD.
// Related issue : https://github.com/kubernetes-sigs/controller-tools/issues/478
// Fails setting min/max for integers: https://github.com/helm/helm/issues/5806

// +k8s:deepcopy-gen=true
// DeploymentSpec defines the desired state of Deployment
type DeploymentSpec struct {
Expand All @@ -74,12 +67,10 @@ type DeploymentSpec struct {
ControllerResources *corev1.ResourceRequirements `json:"controllerResources,omitempty"`
// NodeResources Compute resources required by Node driver
NodeResources *corev1.ResourceRequirements `json:"nodeResources,omitempty"`
// DeviceMode to use to manage PMEM devices. One of lvm, direct
// +kubebuilder:default:lvm
// DeviceMode to use to manage PMEM devices.
// +kubebuilder:validation:Enum=lvm;direct
DeviceMode DeviceMode `json:"deviceMode,omitempty"`
// LogLevel number for the log verbosity
// +kubebuilder:validation:Required
// kubebuilder:default=3
LogLevel uint16 `json:"logLevel,omitempty"`
// RegistryCert encoded certificate signed by a CA for registry server authentication
// If not provided, provisioned one by the operator using self-signed CA
Expand All @@ -99,12 +90,10 @@ type DeploymentSpec struct {
// NodeSelector node labels to use for selection of driver node
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
// PMEMPercentage represents the percentage of space to be used by the driver in each PMEM region
// on every node.
// on every node. Unset (= zero) selects the default of 100%.
// This is only valid for driver in LVM mode.
// +kubebuilder:validation:Required
// -kubebuilder:validation:Minimum=1
// -kubebuilder:validation:Maximum=100
// -kubebuilder:default=100
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=100
PMEMPercentage uint16 `json:"pmemPercentage,omitempty"`
// Labels contains additional labels for all objects created by the operator.
Labels map[string]string `json:"labels,omitempty"`
Expand Down Expand Up @@ -231,7 +220,7 @@ const (

const (
// DefaultLogLevel default logging level used for the driver
DefaultLogLevel = uint16(5)
DefaultLogLevel = uint16(3)
// DefaultImagePullPolicy default image pull policy for all the images used by the deployment
DefaultImagePullPolicy = corev1.PullIfNotPresent

Expand Down
23 changes: 6 additions & 17 deletions pkg/apis/pmemcsi/v1beta1/deployment_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,6 @@ const (
DeviceModeFake DeviceMode = "fake"
)

// NOTE(avalluri): Due to below errors we stop setting
// few CRD schema fields by prefixing those lines a '-'.
// Once the below issues go fixed replace those '-' with '+'
// Setting default(+kubebuilder:default=value) for v1beta1 CRD fails, only supports since v1 CRD.
// Related issue : https://github.com/kubernetes-sigs/controller-tools/issues/478
// Fails setting min/max for integers: https://github.com/helm/helm/issues/5806

// +k8s:deepcopy-gen=true
// DeploymentSpec defines the desired state of Deployment
type DeploymentSpec struct {
Expand All @@ -78,12 +71,10 @@ type DeploymentSpec struct {
NodeDriverResources *corev1.ResourceRequirements `json:"nodeDriverResources,omitempty"`
// ControllerDriverResources Compute resources required by driver container running on master node
ControllerDriverResources *corev1.ResourceRequirements `json:"controllerDriverResources,omitempty"`
// DeviceMode to use to manage PMEM devices. One of lvm, direct
// +kubebuilder:default:lvm
// DeviceMode to use to manage PMEM devices.
// +kubebuilder:validation:Enum=lvm;direct
DeviceMode DeviceMode `json:"deviceMode,omitempty"`
// LogLevel number for the log verbosity
// +kubebuilder:validation:Required
// kubebuilder:default=3
LogLevel uint16 `json:"logLevel,omitempty"`
// RegistryCert encoded certificate signed by a CA for registry server authentication
// If not provided, provisioned one by the operator using self-signed CA
Expand All @@ -103,12 +94,10 @@ type DeploymentSpec struct {
// NodeSelector node labels to use for selection of driver node
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
// PMEMPercentage represents the percentage of space to be used by the driver in each PMEM region
// on every node.
// on every node. Unset (= zero) selects the default of 100%.
// This is only valid for driver in LVM mode.
// +kubebuilder:validation:Required
// -kubebuilder:validation:Minimum=1
// -kubebuilder:validation:Maximum=100
// -kubebuilder:default=100
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=100
PMEMPercentage uint16 `json:"pmemPercentage,omitempty"`
// Labels contains additional labels for all objects created by the operator.
Labels map[string]string `json:"labels,omitempty"`
Expand Down Expand Up @@ -236,7 +225,7 @@ const (

const (
// DefaultLogLevel default logging level used for the driver
DefaultLogLevel = uint16(5)
DefaultLogLevel = uint16(3)
// DefaultImagePullPolicy default image pull policy for all the images used by the deployment
DefaultImagePullPolicy = corev1.PullIfNotPresent

Expand Down
4 changes: 2 additions & 2 deletions test/e2e/deploy/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,14 @@ func createDeploymentCR(f *framework.Framework, dep *unstructured.Unstructured,
func CreateDeploymentCR(f *framework.Framework, dep api.Deployment) api.Deployment {
in := DeploymentToUnstructured(&dep)
out := createDeploymentCR(f, in, DeploymentResource)
framework.Logf("Created deployment %q", dep.Name)
framework.Logf("Created deployment %q = (%+v)", dep.Name, out)
return *DeploymentFromUnstructured(out)
}

func CreateAlphaDeploymentCR(f *framework.Framework, dep alphaapi.Deployment) alphaapi.Deployment {
in := AlphaDeploymentToUnstructured(&dep)
out := createDeploymentCR(f, in, AlphaDeploymentResource)
framework.Logf("Created deployment %q(%+v)", dep.Name, out)
framework.Logf("Created deployment %q = (%+v)", dep.Name, out)
return *AlphaDeploymentFromUnstructured(out)
}

Expand Down
Loading