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

Changes for picking updated podmon image while running E2E tests #253

Merged
merged 3 commits into from
May 26, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
43 changes: 29 additions & 14 deletions pkg/modules/resiliency.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
drivers "github.com/dell/csm-operator/pkg/drivers"
"github.com/dell/csm-operator/pkg/logger"
utils "github.com/dell/csm-operator/pkg/utils"
corev1 "k8s.io/api/core/v1"
rbacv1 "k8s.io/api/rbac/v1"
applyv1 "k8s.io/client-go/applyconfigurations/apps/v1"
acorev1 "k8s.io/client-go/applyconfigurations/core/v1"
Expand Down Expand Up @@ -129,16 +130,34 @@ func getResiliencyEnv(resiliencyModule csmv1.Module, driverType csmv1.DriverType
return ""
}

func getResiliencyArgs(m csmv1.Module, mode string) []string {
func applyModuleToSideCar(component csmv1.ContainerTemplate, container *acorev1.ContainerApplyConfiguration) {
suryagupta4 marked this conversation as resolved.
Show resolved Hide resolved
if component.Image != "" {
image := string(component.Image)
if container.Image != nil {
*container.Image = image
}
container.Image = &image
}
if component.ImagePullPolicy != "" {
if container.ImagePullPolicy != nil {
*container.ImagePullPolicy = component.ImagePullPolicy
}
container.ImagePullPolicy = &component.ImagePullPolicy
}
emptyEnv := make([]corev1.EnvVar, 0)
container.Env = utils.ReplaceAllApplyCustomEnvs(container.Env, emptyEnv, component.Envs)
container.Args = utils.ReplaceAllArgs(container.Args, component.Args)
}

func setResiliencyArgs(m csmv1.Module, mode string, container *acorev1.ContainerApplyConfiguration) {
for _, component := range m.Components {
if component.Name == utils.PodmonControllerComponent && mode == "controller" {
return component.Args
applyModuleToSideCar(component, container)
}
if component.Name == utils.PodmonNodeComponent && mode == "node" {
return component.Args
applyModuleToSideCar(component, container)
}
}
return nil
}

func getPollRateFromArgs(args []string) string {
Expand All @@ -152,6 +171,7 @@ func getPollRateFromArgs(args []string) string {
}
return ""
}

func getResiliencyApplyCR(cr csmv1.ContainerStorageModule, op utils.OperatorConfig, driverType, mode string) (*csmv1.Module, *acorev1.ContainerApplyConfiguration, error) {
resiliencyModule := csmv1.Module{}
for _, m := range cr.Spec.Modules {
Expand All @@ -174,16 +194,13 @@ func getResiliencyApplyCR(cr csmv1.ContainerStorageModule, op utils.OperatorConf

YamlString := utils.ModifyCommonCR(string(buf), cr)

// read args from the respective components
args := getResiliencyArgs(resiliencyModule, mode)

var container acorev1.ContainerApplyConfiguration
err = yaml.Unmarshal([]byte(YamlString), &container)
if err != nil {
return nil, nil, err
}
// set arguments
container.Args = args
// read args from the respective components
setResiliencyArgs(resiliencyModule, mode, &container)
return &resiliencyModule, &container, nil
}

Expand All @@ -194,7 +211,6 @@ func ResiliencyInjectDeployment(dp applyv1.DeploymentApplyConfiguration, cr csmv
return nil, err
}
podmon := *podmonPtr
utils.UpdateSideCarApply(resiliencyModule.Components, &podmon)
// prepend podmon container in controller-pod
dp.Spec.Template.Spec.Containers = append([]acorev1.ContainerApplyConfiguration{podmon}, dp.Spec.Template.Spec.Containers...)

Expand Down Expand Up @@ -236,7 +252,6 @@ func ResiliencyInjectDaemonset(ds applyv1.DaemonSetApplyConfiguration, cr csmv1.
}

podmon := *podmonPtr
utils.UpdateSideCarApply(resiliencyModule.Components, &podmon)
// prepend podmon container in node-pod
ds.Spec.Template.Spec.Containers = append([]acorev1.ContainerApplyConfiguration{podmon}, ds.Spec.Template.Spec.Containers...)

Expand Down Expand Up @@ -268,10 +283,10 @@ func CheckApplyContainersResiliency(containers []acorev1.ContainerApplyConfigura

// fetch podmonAPIPort
podmonAPIPort := getResiliencyEnv(resiliencyModule, cr.Spec.Driver.CSIDriverType)

var container acorev1.ContainerApplyConfiguration
// fetch podmonArrayConnectivityPollRate
args := getResiliencyArgs(resiliencyModule, "node")
podmonArrayConnectivityPollRate := getPollRateFromArgs(args)
setResiliencyArgs(resiliencyModule, "node", &container)
podmonArrayConnectivityPollRate := getPollRateFromArgs(container.Args)

for _, cnt := range containers {
if *cnt.Name == utils.ResiliencySideCarName {
Expand Down
4 changes: 4 additions & 0 deletions pkg/modules/testdata/cr_powerstore_resiliency.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ spec:
enabled: true
components:
- name: podmon-controller
image: dellemc/podmon:nightly
imagePullPolicy: IfNotPresent
args:
- "--csisock=unix:/var/run/csi/csi.sock"
- "--labelvalue=csi-powerstore"
Expand All @@ -30,6 +32,8 @@ spec:
- "--driverPodLabelValue=dell-storage"
- "--ignoreVolumelessPods=false"
- name: podmon-node
image: dellemc/podmon:nightly
imagePullPolicy: IfNotPresent
envs:
# podmonAPIPort: Defines the port to be used within the kubernetes cluster
# Allowed values: Any valid and free port (string)
Expand Down
4 changes: 4 additions & 0 deletions tests/e2e/testfiles/storage_csm_powerflex.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,8 @@ spec:
configVersion: v1.6.0
components:
- name: podmon-controller
image: dellemc/podmon:nightly
imagePullPolicy: IfNotPresent
args:
- "--csisock=unix:/var/run/csi/csi.sock"
- "--labelvalue=csi-vxflexos"
Expand All @@ -344,6 +346,8 @@ spec:
- "--driverPodLabelValue=dell-storage"
- "--ignoreVolumelessPods=false"
- name: podmon-node
image: dellemc/podmon:nightly
imagePullPolicy: IfNotPresent
envs:
# podmonAPIPort: Defines the port to be used within the kubernetes cluster
# Allowed values: Any valid and free port (string)
Expand Down
4 changes: 4 additions & 0 deletions tests/e2e/testfiles/storage_csm_powerflex_resiliency.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ spec:
configVersion: v1.6.0
components:
- name: podmon-controller
image: dellemc/podmon:nightly
imagePullPolicy: IfNotPresent
args:
- "--csisock=unix:/var/run/csi/csi.sock"
- "--labelvalue=csi-vxflexos"
Expand All @@ -179,6 +181,8 @@ spec:
- "--driverPodLabelValue=dell-storage"
- "--ignoreVolumelessPods=false"
- name: podmon-node
image: dellemc/podmon:nightly
imagePullPolicy: IfNotPresent
envs:
# podmonAPIPort: Defines the port to be used within the kubernetes cluster
# Allowed values: Any valid and free port (string)
Expand Down
4 changes: 4 additions & 0 deletions tests/e2e/testfiles/storage_csm_powerscale.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,8 @@ spec:
configVersion: v1.6.0
components:
- name: podmon-controller
image: dellemc/podmon:nightly
imagePullPolicy: IfNotPresent
args:
- "--csisock=unix:/var/run/csi/csi.sock"
- "--labelvalue=csi-isilon"
Expand All @@ -444,6 +446,8 @@ spec:
- "--driverPodLabelValue=dell-storage"
- "--ignoreVolumelessPods=false"
- name: podmon-node
image: dellemc/podmon:nightly
imagePullPolicy: IfNotPresent
envs:
# podmonAPIPort: Defines the port to be used within the kubernetes cluster
# Allowed values: Any valid and free port (string)
Expand Down
4 changes: 4 additions & 0 deletions tests/e2e/testfiles/storage_csm_powerscale_resiliency.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ spec:
configVersion: v1.6.0
components:
- name: podmon-controller
image: dellemc/podmon:nightly
imagePullPolicy: IfNotPresent
args:
- "--csisock=unix:/var/run/csi/csi.sock"
- "--labelvalue=csi-isilon"
Expand All @@ -279,6 +281,8 @@ spec:
- "--driverPodLabelValue=dell-storage"
- "--ignoreVolumelessPods=false"
- name: podmon-node
image: dellemc/podmon:nightly
imagePullPolicy: IfNotPresent
envs:
# podmonAPIPort: Defines the port to be used within the kubernetes cluster
# Allowed values: Any valid and free port (string)
Expand Down
4 changes: 4 additions & 0 deletions tests/e2e/testfiles/storage_csm_powerstore.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ spec:
configVersion: v1.6.0
components:
- name: podmon-controller
image: dellemc/podmon:nightly
imagePullPolicy: IfNotPresent
args:
- "--csisock=unix:/var/run/csi/csi.sock"
- "--labelvalue=csi-powerstore"
Expand All @@ -162,6 +164,8 @@ spec:
- "--driverPodLabelValue=dell-storage"
- "--ignoreVolumelessPods=false"
- name: podmon-node
image: dellemc/podmon:nightly
imagePullPolicy: IfNotPresent
envs:
# podmonAPIPort: Defines the port to be used within the kubernetes cluster
# Allowed values: Any valid and free port (string)
Expand Down
4 changes: 4 additions & 0 deletions tests/e2e/testfiles/storage_csm_powerstore_resiliency.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ spec:
configVersion: v1.6.0
components:
- name: podmon-controller
image: dellemc/podmon:nightly
imagePullPolicy: IfNotPresent
args:
- "--csisock=unix:/var/run/csi/csi.sock"
- "--labelvalue=csi-powerstore"
Expand All @@ -162,6 +164,8 @@ spec:
- "--driverPodLabelValue=dell-storage"
- "--ignoreVolumelessPods=false"
- name: podmon-node
image: dellemc/podmon:nightly
imagePullPolicy: IfNotPresent
envs:
# podmonAPIPort: Defines the port to be used within the kubernetes cluster
# Allowed values: Any valid and free port (string)
Expand Down