Skip to content

Commit

Permalink
Merge branch 'main' into feature/resiliency_module
Browse files Browse the repository at this point in the history
  • Loading branch information
adarsh-dell authored May 22, 2023
2 parents c3b29e2 + e76c52d commit 0c8f926
Show file tree
Hide file tree
Showing 34 changed files with 1,601 additions and 123 deletions.
10 changes: 3 additions & 7 deletions bundle/manifests/dell-csm-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -387,18 +387,14 @@ metadata:
"apiVersion": "storage.dell.com/v1",
"kind": "ContainerStorageModule",
"metadata": {
"name": "test-unity",
"namespace": "test-unity"
"name": "unity",
"namespace": "unity"
},
"spec": {
"driver": {
"authSecret": "test-unity-creds",
"authSecret": "unity-creds",
"common": {
"envs": [
{
"name": "X_CSI_UNITY_NODENAME_PREFIX",
"value": "csi-node"
},
{
"name": "X_CSI_UNITY_ALLOW_MULTI_POD_ACCESS",
"value": "false"
Expand Down
10 changes: 4 additions & 6 deletions config/samples/storage_v1_csm_unity.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
apiVersion: storage.dell.com/v1
kind: ContainerStorageModule
metadata:
name: test-unity
namespace: test-unity
name: unity
namespace: unity
spec:
driver:
csiDriverType: "unity"
Expand All @@ -15,8 +15,8 @@ spec:
configVersion: v2.7.0
# authSecret: This is the secret used to validate the default Unity secret used for installation
# Allowed values: <metadataName specified in the Manifest>-creds
# For example: If the metadataName is set to test-unity, authSecret value should be set to test-unity-creds
authSecret: test-unity-creds
# For example: If the metadataName is set to unity, authSecret value should be set to unity-creds
authSecret: unity-creds
# Controller count
replicas: 2
dnsPolicy: ClusterFirstWithHostNet
Expand All @@ -27,8 +27,6 @@ spec:
image: "dellemc/csi-unity:v2.7.0"
imagePullPolicy: IfNotPresent
envs:
- name: X_CSI_UNITY_NODENAME_PREFIX
value: "csi-node"
# X_CSI_UNITY_ALLOW_MULTI_POD_ACCESS - Flag to enable sharing of volumes across multiple pods within the same node in RWO access mode.
# Allowed values: boolean
# Default value: "false"
Expand Down
10 changes: 9 additions & 1 deletion controllers/csm_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"context"
"encoding/json"
"fmt"
"strconv"
"sync/atomic"
"time"

Expand Down Expand Up @@ -357,18 +358,25 @@ func (r *ContainerStorageModuleReconciler) handleDeploymentUpdate(oldObj interfa

csm := new(csmv1.ContainerStorageModule)
err := r.Client.Get(ctx, namespacedName, csm)

if err != nil {
log.Error("deployment get csm", "error", err.Error())
}

newStatus := csm.GetCSMStatus()

// Updating controller status manually as controller runtime API is not updating csm object with latest data
// TODO: Can remove this once the controller runtime repo has a fix for updating the object passed
newStatus.ControllerStatus.Available = strconv.Itoa(int(available))
newStatus.ControllerStatus.Desired = strconv.Itoa(int(desired))
newStatus.ControllerStatus.Failed = strconv.Itoa(int(numberUnavailable))

err = utils.UpdateStatus(ctx, csm, r, newStatus)
if err != nil {
log.Debugw("deployment status ", "pods", err.Error())
} else {
r.EventRecorder.Eventf(csm, corev1.EventTypeNormal, csmv1.EventCompleted, "Driver deployment running OK")
}

}

func (r *ContainerStorageModuleReconciler) handlePodsUpdate(oldObj interface{}, obj interface{}) {
Expand Down
2 changes: 0 additions & 2 deletions operatorconfig/driverconfig/unity/v2.5.0/node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ spec:
fieldRef:
apiVersion: v1
fieldPath: spec.nodeName
- name: X_CSI_UNITY_NODENAME_PREFIX
value: <X_CSI_UNITY_NODENAME_PREFIX>
- name: SSL_CERT_DIR
value: /certs
- name: X_CSI_UNITY_SYNC_NODEINFO_INTERVAL
Expand Down
2 changes: 0 additions & 2 deletions operatorconfig/driverconfig/unity/v2.6.0/node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ spec:
fieldRef:
apiVersion: v1
fieldPath: spec.nodeName
- name: X_CSI_UNITY_NODENAME_PREFIX
value: <X_CSI_UNITY_NODENAME_PREFIX>
- name: SSL_CERT_DIR
value: /certs
- name: X_CSI_UNITY_SYNC_NODEINFO_INTERVAL
Expand Down
2 changes: 0 additions & 2 deletions operatorconfig/driverconfig/unity/v2.7.0/node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ spec:
fieldRef:
apiVersion: v1
fieldPath: spec.nodeName
- name: X_CSI_UNITY_NODENAME_PREFIX
value: <X_CSI_UNITY_NODENAME_PREFIX>
- name: SSL_CERT_DIR
value: /certs
- name: X_CSI_UNITY_SYNC_NODEINFO_INTERVAL
Expand Down
3 changes: 0 additions & 3 deletions pkg/drivers/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,6 @@ func csmWithUnity(driver csmv1.DriverType, version string, certProvided bool) cs
}
res.Spec.Driver.Common.Envs = []corev1.EnvVar{envVar1, envVar2, envVar3, envVar4, envVar5, envVar6, envVar7}

// Add node name prefix to cover some code in GetNode
// nodeNamePrefix := corev1.EnvVar{Name: "X_CSI_UNITY_NODENAME_PREFIX"}

// Add node fields specific to unity
healthMonitor := corev1.EnvVar{Name: "X_CSI_HEALTH_MONITOR_ENABLED", Value: "true"}
res.Spec.Driver.Node.Envs = []corev1.EnvVar{healthMonitor}
Expand Down
10 changes: 0 additions & 10 deletions pkg/drivers/unity.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ const (
// UnityConfigParamsVolumeMount - Volume mount
UnityConfigParamsVolumeMount = "csi-unity-config-params"

// CsiUnityNodeNamePrefix - Node Name Prefix
CsiUnityNodeNamePrefix = "<X_CSI_UNITY_NODENAME_PREFIX>"

// CsiLogLevel - Defines the log level
CsiLogLevel = "<CSI_LOG_LEVEL>"

Expand Down Expand Up @@ -116,24 +113,17 @@ func PrecheckUnity(ctx context.Context, cr *csmv1.ContainerStorageModule, operat
// ModifyUnityCR - Configuring CR parameters
func ModifyUnityCR(yamlString string, cr csmv1.ContainerStorageModule, fileType string) string {
// Parameters to initialise CR values
nodePrefix := ""
healthMonitorNode := ""
healthMonitorController := ""

switch fileType {
case "Node":
for _, env := range cr.Spec.Driver.Common.Envs {
if env.Name == "X_CSI_UNITY_NODENAME_PREFIX" {
nodePrefix = env.Value
}
}
for _, env := range cr.Spec.Driver.Node.Envs {

if env.Name == "X_CSI_HEALTH_MONITOR_ENABLED" {
healthMonitorNode = env.Value
}
}
yamlString = strings.ReplaceAll(yamlString, CsiUnityNodeNamePrefix, nodePrefix)
yamlString = strings.ReplaceAll(yamlString, CsiHealthMonitorEnabled, healthMonitorNode)
case "Controller":
for _, env := range cr.Spec.Driver.Controller.Envs {
Expand Down
43 changes: 32 additions & 11 deletions pkg/utils/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ func getDeploymentStatus(ctx context.Context, instance *csmv1.ContainerStorageMo
err = errors.New(msg)
}

log.Infof("Deployment totalReplicas count %d totalReadyPods %d totalFailedCount %d", totalReplicas, totalReadyPods, totalFailedCount)

return totalReplicas, csmv1.PodStatus{
Available: fmt.Sprintf("%d", totalReadyPods),
Desired: fmt.Sprintf("%d", totalReplicas),
Expand Down Expand Up @@ -221,33 +223,46 @@ func getDaemonSetStatus(ctx context.Context, instance *csmv1.ContainerStorageMod
func calculateState(ctx context.Context, instance *csmv1.ContainerStorageModule, r ReconcileCSM, newStatus *csmv1.ContainerStorageModuleStatus) (bool, error) {
log := logger.GetLogger(ctx)
running := false
controllerReplicas, controllerStatus, controllerErr := getDeploymentStatus(ctx, instance, r)
// TODO: Currently commented this block of code as the API used to get the latest deployment status is not working as expected
// TODO: Can be uncommented once this issues gets sorted out
/* controllerReplicas, controllerStatus, controllerErr := getDeploymentStatus(ctx, instance, r)
expected, nodeStatus, daemonSetErr := getDaemonSetStatus(ctx, instance, r)
newStatus.ControllerStatus = controllerStatus
newStatus.NodeStatus = nodeStatus */
expected, nodeStatus, daemonSetErr := getDaemonSetStatus(ctx, instance, r)
newStatus.NodeStatus = nodeStatus
controllerReplicas := newStatus.ControllerStatus.Desired
controllerStatus := newStatus.ControllerStatus

newStatus.State = constants.Failed
log.Infof("deployment controllerReplicas [%d]", controllerReplicas)
log.Infof("deployment controllerReplicas [%s]", controllerReplicas)
log.Infof("deployment controllerStatus.Available [%s]", controllerStatus.Available)

log.Infof("daemonset expected [%d]", expected)
log.Infof("daemonset nodeStatus.Available [%s]", nodeStatus.Available)

if (fmt.Sprintf("%d", controllerReplicas) == controllerStatus.Available) && (fmt.Sprintf("%d", expected) == nodeStatus.Available) {
if (controllerReplicas == controllerStatus.Available) && (fmt.Sprintf("%d", expected) == nodeStatus.Available) {
running = true
newStatus.State = constants.Succeeded
}
log.Infof("calculate overall state [%s]", newStatus.State)
var err error
if controllerErr != nil {
err = controllerErr
}
var err error = nil
// TODO: Uncomment this when the controller runtime API gets fixed
/*
if controllerErr != nil {
err = controllerErr
}
if daemonSetErr != nil {
err = daemonSetErr
}
if daemonSetErr != nil && controllerErr != nil {
err = fmt.Errorf("ControllerError: %s, Daemonseterror: %s", controllerErr.Error(), daemonSetErr.Error())
log.Infof("calculate overall error msg [%s]", err.Error())
} */

if daemonSetErr != nil {
err = daemonSetErr
}
if daemonSetErr != nil && controllerErr != nil {
err = fmt.Errorf("ControllerError: %s, Daemonseterror: %s", controllerErr.Error(), daemonSetErr.Error())
log.Infof("calculate overall error msg [%s]", err.Error())
log.Infof("calculate Daemonseterror msg [%s]", daemonSetErr.Error())
}
SetStatus(ctx, r, instance, newStatus)
return running, err
Expand Down Expand Up @@ -284,6 +299,12 @@ func UpdateStatus(ctx context.Context, instance *csmv1.ContainerStorageModule, r
if err != nil {
return err
}

log.Infow("instance - new controller Status", "desired", instance.Status.ControllerStatus.Desired)
log.Infow("instance - new controller Status", "Available", instance.Status.ControllerStatus.Available)
log.Infow("instance - new controller Status", "numberUnavailable", instance.Status.ControllerStatus.Failed)
log.Infow("instance - new controller Status", "State", instance.Status.State)

csm.Status = instance.Status
err = r.GetClient().Status().Update(ctx, csm)
if err != nil {
Expand Down
10 changes: 4 additions & 6 deletions samples/storage_csm_unity_v250.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
apiVersion: storage.dell.com/v1
kind: ContainerStorageModule
metadata:
name: test-unity
namespace: test-unity
name: unity
namespace: unity
spec:
driver:
csiDriverType: "unity"
Expand All @@ -15,8 +15,8 @@ spec:
configVersion: v2.5.0
# authSecret: This is the secret used to validate the default Unity secret used for installation
# Allowed values: <metadataName specified in the Manifest>-creds
# For example: If the metadataName is set to test-unity, authSecret value should be set to test-unity-creds
authSecret: test-unity-creds
# For example: If the metadataName is set to unity, authSecret value should be set to unity-creds
authSecret: unity-creds
# Controller count
replicas: 2
dnsPolicy: ClusterFirstWithHostNet
Expand All @@ -27,8 +27,6 @@ spec:
image: "dellemc/csi-unity:v2.5.0"
imagePullPolicy: IfNotPresent
envs:
- name: X_CSI_UNITY_NODENAME_PREFIX
value: "csi-node"
# X_CSI_UNITY_ALLOW_MULTI_POD_ACCESS - Flag to enable sharing of volumes across multiple pods within the same node in RWO access mode.
# Allowed values: boolean
# Default value: "false"
Expand Down
10 changes: 4 additions & 6 deletions samples/storage_csm_unity_v260.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
apiVersion: storage.dell.com/v1
kind: ContainerStorageModule
metadata:
name: test-unity
namespace: test-unity
name: unity
namespace: unity
spec:
driver:
csiDriverType: "unity"
Expand All @@ -15,8 +15,8 @@ spec:
configVersion: v2.6.0
# authSecret: This is the secret used to validate the default Unity secret used for installation
# Allowed values: <metadataName specified in the Manifest>-creds
# For example: If the metadataName is set to test-unity, authSecret value should be set to test-unity-creds
authSecret: test-unity-creds
# For example: If the metadataName is set to unity, authSecret value should be set to unity-creds
authSecret: unity-creds
# Controller count
replicas: 2
dnsPolicy: ClusterFirstWithHostNet
Expand All @@ -27,8 +27,6 @@ spec:
image: "dellemc/csi-unity:v2.6.0"
imagePullPolicy: IfNotPresent
envs:
- name: X_CSI_UNITY_NODENAME_PREFIX
value: "csi-node"
# X_CSI_UNITY_ALLOW_MULTI_POD_ACCESS - Flag to enable sharing of volumes across multiple pods within the same node in RWO access mode.
# Allowed values: boolean
# Default value: "false"
Expand Down
10 changes: 4 additions & 6 deletions samples/storage_csm_unity_v270.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
apiVersion: storage.dell.com/v1
kind: ContainerStorageModule
metadata:
name: test-unity
namespace: test-unity
name: unity
namespace: unity
spec:
driver:
csiDriverType: "unity"
Expand All @@ -15,8 +15,8 @@ spec:
configVersion: v2.7.0
# authSecret: This is the secret used to validate the default Unity secret used for installation
# Allowed values: <metadataName specified in the Manifest>-creds
# For example: If the metadataName is set to test-unity, authSecret value should be set to test-unity-creds
authSecret: test-unity-creds
# For example: If the metadataName is set to unity, authSecret value should be set to unity-creds
authSecret: unity-creds
# Controller count
replicas: 2
dnsPolicy: ClusterFirstWithHostNet
Expand All @@ -27,8 +27,6 @@ spec:
image: "dellemc/csi-unity:v2.7.0"
imagePullPolicy: IfNotPresent
envs:
- name: X_CSI_UNITY_NODENAME_PREFIX
value: "csi-node"
# X_CSI_UNITY_ALLOW_MULTI_POD_ACCESS - Flag to enable sharing of volumes across multiple pods within the same node in RWO access mode.
# Allowed values: boolean
# Default value: "false"
Expand Down
10 changes: 5 additions & 5 deletions tests/config/driverconfig/unity/v2.6.0/controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ spec:
topologyKey: "kubernetes.io/hostname"
containers:
- name: attacher
image: k8s.gcr.io/sig-storage/csi-attacher:v4.0.0
image: registry.k8s.io/sig-storage/csi-attacher:v4.0.0
imagePullPolicy: IfNotPresent
args:
- "--csi-address=$(ADDRESS)"
Expand All @@ -126,7 +126,7 @@ spec:
- name: socket-dir
mountPath: /var/run/csi
- name: provisioner
image: k8s.gcr.io/sig-storage/csi-provisioner:v3.3.0
image: registry.k8s.io/sig-storage/csi-provisioner:v3.3.0
imagePullPolicy: IfNotPresent
args:
- "--csi-address=$(ADDRESS)"
Expand All @@ -147,7 +147,7 @@ spec:
- name: socket-dir
mountPath: /var/run/csi
- name: snapshotter
image: k8s.gcr.io/sig-storage/csi-snapshotter:v6.1.0
image: registry.k8s.io/sig-storage/csi-snapshotter:v6.1.0
imagePullPolicy: IfNotPresent
args:
- "--csi-address=$(ADDRESS)"
Expand All @@ -163,7 +163,7 @@ spec:
- name: socket-dir
mountPath: /var/run/csi
- name: resizer
image: k8s.gcr.io/sig-storage/csi-resizer:v1.6.0
image: registry.k8s.io/sig-storage/csi-resizer:v1.6.0
imagePullPolicy: IfNotPresent
args:
- "--csi-address=$(ADDRESS)"
Expand All @@ -176,7 +176,7 @@ spec:
- name: socket-dir
mountPath: /var/run/csi
- name: external-health-monitor
image: k8s.gcr.io/sig-storage/csi-external-health-monitor-controller:v0.7.0
image: registry.k8s.io/sig-storage/csi-external-health-monitor-controller:v0.7.0
imagePullPolicy: IfNotPresent
args:
- "--v=5"
Expand Down
4 changes: 1 addition & 3 deletions tests/config/driverconfig/unity/v2.6.0/node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ spec:
fieldRef:
apiVersion: v1
fieldPath: spec.nodeName
- name: X_CSI_UNITY_NODENAME_PREFIX
value: <X_CSI_UNITY_NODENAME_PREFIX>
- name: SSL_CERT_DIR
value: /certs
- name: X_CSI_UNITY_SYNC_NODEINFO_INTERVAL
Expand Down Expand Up @@ -132,7 +130,7 @@ spec:
- name: unity-secret
mountPath: /unity-secret
- name: registrar
image: k8s.gcr.io/sig-storage/csi-node-driver-registrar:v2.6.0
image: registry.k8s.io/sig-storage/csi-node-driver-registrar:v2.6.0
args:
- "--v=5"
- "--csi-address=$(ADDRESS)"
Expand Down
Loading

0 comments on commit 0c8f926

Please sign in to comment.