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

Ensure that the fields mentioned in samples are configurable. #162

Merged
merged 5 commits into from
Feb 14, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
12 changes: 6 additions & 6 deletions operatorconfig/driverconfig/powerstore/v2.5.0/controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,13 @@ spec:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
- labelSelector:
matchExpressions:
- key: "name"
- key: name
operator: In
values:
- <DriverDefaultReleaseName>-controller
topologyKey: "kubernetes.io/hostname"
- <DriverDefaultReleaseName>-controller
topologyKey: kubernetes.io/hostname
containers:
- name: attacher
image: k8s.gcr.io/sig-storage/csi-attacher:v4.0.0
Expand Down Expand Up @@ -226,7 +226,7 @@ spec:
- name: X_CSI_POWERSTORE_EXTERNAL_ACCESS
value: "None"
- name: X_CSI_NFS_ACLS
value: "0777"
value: "<X_CSI_NFS_ACLS>"
- name: X_CSI_POWERSTORE_CONFIG_PATH
value: /powerstore-config/config
- name: X_CSI_POWERSTORE_CONFIG_PARAMS_PATH
Expand All @@ -238,7 +238,7 @@ spec:
- name: X_CSI_PODMON_API_PORT
value: 8083
- name: X_CSI_HEALTH_MONITOR_ENABLED
value: "false"
value: "<X_CSI_HEALTH_MONITOR_ENABLED>"
volumeMounts:
- name: socket-dir
mountPath: /var/run/csi
Expand Down
21 changes: 15 additions & 6 deletions operatorconfig/driverconfig/powerstore/v2.5.0/node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,26 +94,35 @@ spec:
apiVersion: v1
fieldPath: spec.nodeName
- name: X_CSI_POWERSTORE_NODE_NAME_PREFIX
value: csi-node
value: <X_CSI_POWERSTORE_NODE_NAME_PREFIX>
- name: X_CSI_POWERSTORE_NODE_ID_PATH
value: /node-id
- name: X_CSI_POWERSTORE_NODE_CHROOT_PATH
value: /noderoot
- name: X_CSI_POWERSTORE_TMP_DIR
value: var/lib/kubelet/plugins/csi-powerstore.dellemc.com/tmp
value: /var/lib/kubelet/plugins/csi-powerstore.dellemc.com/tmp
- name: X_CSI_DRIVER_NAME
value: "csi-powerstore"
value: "csi-powerstore.dellemc.com"
- name: X_CSI_FC_PORTS_FILTER_FILE_PATH
value: /etc/fc-ports-filter
value: <X_CSI_FC_PORTS_FILTER_FILE_PATH>
- name: X_CSI_POWERSTORE_ENABLE_CHAP
value: "false"
value: "<X_CSI_POWERSTORE_ENABLE_CHAP>"
- name: X_CSI_POWERSTORE_CONFIG_PATH
value: /powerstore-config/config
- name: X_CSI_POWERSTORE_CONFIG_PARAMS_PATH
value: /powerstore-config-params/driver-config-params.yaml
- name: GOPOWERSTORE_DEBUG
value: "true"
- name: X_CSI_HEALTH_MONITOR_ENABLED
value: "<X_CSI_HEALTH_MONITOR_ENABLED>"
Copy link
Contributor

Choose a reason for hiding this comment

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

@karthikk92 , Do we need quotes here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

taken care

volumeMounts:
Copy link
Contributor

Choose a reason for hiding this comment

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

@kk3, please check if volumeMounts section is duplicated in this file

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

taken care

- name: driver-path
mountPath: /var/lib/kubelet/plugins/csi-powerstore.dellemc.com
- name: csi-path
mountPath: /var/lib/kubelet/plugins/kubernetes.io/csi
mountPropagation: "Bidirectional"
- name: pods-path
mountPath: /var/lib/kubelet/pods
value: "false"
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have value for volumeMounts. @kk3 please check

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

taken care

volumeMounts:
- name: driver-path
Expand Down Expand Up @@ -148,7 +157,7 @@ spec:
args:
- "--v=5"
- "--csi-address=$(ADDRESS)"
- --kubelet-registration-path=var/lib/kubelet/plugins/csi-powerstore.dellemc.com/csi_sock
- --kubelet-registration-path=/var/lib/kubelet/plugins/csi-powerstore.dellemc.com/csi_sock
env:
- name: ADDRESS
value: /csi/csi_sock
Expand Down
6 changes: 6 additions & 0 deletions pkg/drivers/commonconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ func GetController(ctx context.Context, cr csmv1.ContainerStorageModule, operato
}

YamlString := utils.ModifyCommonCR(string(buf), cr)
if cr.Spec.Driver.CSIDriverType == "powerstore" {
YamlString = ModifyPowerstoreCR(YamlString, cr, "Controller")
}

driverYAML, err := utils.GetDriverYaml(YamlString, "Deployment")
if err != nil {
Expand Down Expand Up @@ -158,6 +161,9 @@ func GetNode(ctx context.Context, cr csmv1.ContainerStorageModule, operatorConfi
}

YamlString := utils.ModifyCommonCR(string(buf), cr)
if cr.Spec.Driver.CSIDriverType == "powerstore" {
YamlString = ModifyPowerstoreCR(YamlString, cr, "Node")
}

driverYAML, err := utils.GetDriverYaml(YamlString, "DaemonSet")
if err != nil {
Expand Down
80 changes: 79 additions & 1 deletion pkg/drivers/powerstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@ package drivers
import (
"context"
"fmt"
"os"
"strings"

csmv1 "github.com/dell/csm-operator/api/v1"
"github.com/dell/csm-operator/pkg/logger"
"github.com/dell/csm-operator/pkg/utils"
"os"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"
)

Expand All @@ -28,6 +33,21 @@ const (

// PowerStoreConfigParamsVolumeMount -
PowerStoreConfigParamsVolumeMount = "csi-powerstore-config-params"

// CsiPowerstoreNodeNamePrefix - Node Name Prefix
CsiPowerstoreNodeNamePrefix = "<X_CSI_POWERSTORE_NODE_NAME_PREFIX>"

// CsiFcPortFilterFilePath - Fc Port Filter File Path
CsiFcPortFilterFilePath = "<X_CSI_FC_PORTS_FILTER_FILE_PATH>"

// CsiNfsAcls - variable setting the permissions on NFS mount directory
CsiNfsAcls = "<X_CSI_NFS_ACLS>"

// CsiHealthMonitorEnabled - health monitor flag
CsiHealthMonitorEnabled = "<X_CSI_HEALTH_MONITOR_ENABLED>"

// CsiPowerstoreEnableChap - CHAP flag
CsiPowerstoreEnableChap = "<X_CSI_POWERSTORE_ENABLE_CHAP>"
)

// PrecheckPowerStore do input validation
Expand All @@ -44,6 +64,64 @@ func PrecheckPowerStore(ctx context.Context, cr *csmv1.ContainerStorageModule, o
}
secrets := []string{config}

for _, name := range secrets {
found := &corev1.Secret{}
err := ct.Get(ctx, types.NamespacedName{Name: name, Namespace: cr.GetNamespace()}, found)
if err != nil {
log.Error(err, "Failed query for secret ", name)
if errors.IsNotFound(err) {
return fmt.Errorf("failed to find secret %s", name)
}
}
}

log.Debugw("preCheck", "secrets", len(secrets))
return nil
}

// ModifyPowerstoreCR -
func ModifyPowerstoreCR(yamlString string, cr csmv1.ContainerStorageModule, fileType string) string {
// Parameters to initialise CR values
nodePrefix := ""
fcPortFilter := ""
nfsAcls := ""
healthMonitorController := ""
chap := ""
healthMonitorNode := ""

switch fileType {
case "Node":
for _, env := range cr.Spec.Driver.Common.Envs {
if env.Name == "X_CSI_POWERSTORE_NODE_NAME_PREFIX" {
nodePrefix = env.Value
}
if env.Name == "X_CSI_FC_PORTS_FILTER_FILE_PATH" {
fcPortFilter = env.Value
}
}
for _, env := range cr.Spec.Driver.Node.Envs {
if env.Name == "X_CSI_POWERSTORE_ENABLE_CHAP" {
chap = env.Value
}
if env.Name == "X_CSI_HEALTH_MONITOR_ENABLED" {
healthMonitorNode = env.Value
}
}
yamlString = strings.ReplaceAll(yamlString, CsiPowerstoreNodeNamePrefix, nodePrefix)
yamlString = strings.ReplaceAll(yamlString, CsiFcPortFilterFilePath, fcPortFilter)
yamlString = strings.ReplaceAll(yamlString, CsiPowerstoreEnableChap, chap)
yamlString = strings.ReplaceAll(yamlString, CsiHealthMonitorEnabled, healthMonitorNode)
case "Controller":
for _, env := range cr.Spec.Driver.Controller.Envs {
if env.Name == "X_CSI_NFS_ACLS" {
nfsAcls = env.Value
}
if env.Name == "X_CSI_HEALTH_MONITOR_ENABLED" {
healthMonitorController = env.Value
}
}
yamlString = strings.ReplaceAll(yamlString, CsiNfsAcls, nfsAcls)
yamlString = strings.ReplaceAll(yamlString, CsiHealthMonitorEnabled, healthMonitorController)
}
return yamlString
}
11 changes: 1 addition & 10 deletions samples/storage_csm_powerstore_v250.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ spec:
fSGroupPolicy: "ReadWriteOnceWithFSType"
# Config version for CSI PowerStore v2.5.0 driver
configVersion: v2.5.0
authSecret: test-powerstore-config
# Controller count
replicas: 2
dnsPolicy: ClusterFirstWithHostNet
Expand Down Expand Up @@ -115,13 +116,3 @@ spec:
# - key: "node-role.kubernetes.io/control-plane"
# operator: "Exists"
# effect: "NoSchedule"
---
apiVersion: v1
kind: ConfigMap
metadata:
name: test-powerstore-config-params
namespace: test-powerstore
data:
driver-config-params.yaml: |
CSI_LOG_LEVEL: "debug"
CSI_LOG_FORMAT: "JSON"