Skip to content

Commit

Permalink
Merge branch 'main' into ccoff/add-env-vars
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianAtDell authored Feb 26, 2025
2 parents 899d8f1 + 4d5e2bd commit f3c6c0b
Show file tree
Hide file tree
Showing 37 changed files with 3,948 additions and 53 deletions.
3 changes: 2 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ updates:
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "daily"
interval: "weekly"
day: "sunday"
time: "18:00"
allow:
# Allow direct updates for packages
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/update-libraries-to-commits.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
name: Dell Libraries Commit Update
on: # yamllint disable-line rule:truthy
workflow_dispatch:
repository_dispatch:
types: [latest-commits-libraries]

jobs:
package-update:
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ test: manifests gen-semver fmt vet envtest ## Run tests.
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test ./... -coverprofile cover.out

controller-unit-test:
go clean -cache && go test -v -coverpkg=github.com/dell/csm-operator/pkg/logger,github.com/dell/csm-operator/pkg/resources/daemonset,github.com/dell/csm-operator/pkg/resources/deployment,github.com/dell/csm-operator/pkg/resources/statefulset,github.com/dell/csm-operator/pkg/resources/configmap,github.com/dell/csm-operator/pkg/resources/serviceaccount,github.com/dell/csm-operator/pkg/resources/rbac,github.com/dell/csm-operator/pkg/resources/csidriver,github.com/dell/csm-operator/pkg/constants,github.com/dell/csm-operator/controllers -coverprofile=c.out github.com/dell/csm-operator/controllers
go clean -cache && go test -v -coverprofile=c.out github.com/dell/csm-operator/controllers

driver-unit-test:
go clean -cache && go test -v -coverprofile=c.out github.com/dell/csm-operator/pkg/drivers

Expand Down
20 changes: 18 additions & 2 deletions controllers/csm_controller.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2021 - 2023 Dell Inc. or its subsidiaries. All Rights Reserved.
// Copyright © 2021 - 2025 Dell Inc. or its subsidiaries. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -769,6 +769,10 @@ func (r *ContainerStorageModuleReconciler) SyncCSM(ctx context.Context, cr csmv1
log.Infof("DeployAsSidar is false...csi-reverseproxy should be present as deployement\n")
log.Infof("adding proxy service name...\n")
modules.AddReverseProxyServiceName(&controller.Deployment)

// Set the secret mount for powermax controller.
// Note: No need to catch error since it only returns one if the interface casting fails which it shouldn't here.
_ = drivers.DynamicallyMountPowermaxContent(&controller.Deployment, cr)
} else {
log.Info("Starting CSI ReverseProxy Service")
if err := modules.ReverseProxyStartService(ctx, false, operatorConfig, cr, ctrlClient); err != nil {
Expand All @@ -777,10 +781,18 @@ func (r *ContainerStorageModuleReconciler) SyncCSM(ctx context.Context, cr csmv1
log.Info("Injecting CSI ReverseProxy")
dp, err := modules.ReverseProxyInjectDeployment(controller.Deployment, cr, operatorConfig)
if err != nil {
return fmt.Errorf("injecting replication into deployment: %v", err)
return fmt.Errorf("unable to inject ReverseProxy into deployment: %v", err)
}

controller.Deployment = *dp
}

// Set the secret mount for powermax node.
// Note: No need to catch error since it only returns one if the interface casting fails which it shouldn't here.
_ = drivers.DynamicallyMountPowermaxContent(&node.DaemonSetApplyConfig, cr)

// Dynamically update the drivers config param.
modules.UpdatePowerMaxConfigMap(configMap, cr)
}

replicationEnabled, clusterClients, err := utils.GetDefaultClusters(ctx, cr, r)
Expand Down Expand Up @@ -1370,6 +1382,10 @@ func (r *ContainerStorageModuleReconciler) PreChecks(ctx context.Context, cr *cs
if err != nil {
return fmt.Errorf("failed powermax validation: %v", err)
}

// To ensure that we are handling minimal manifests correctly and consistent, we must reset DeployAsSidecar to the original value.
// This variable will be set correctly if the reverseproxy is found in the manifests.
modules.ResetDeployAsSidecar()
default:
// Go to checkUpgrade if it is standalone module i.e. app mobility or authorizatio proxy server
if cr.HasModule(csmv1.ApplicationMobility) || cr.HasModule(csmv1.AuthorizationServer) {
Expand Down
65 changes: 63 additions & 2 deletions controllers/csm_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,17 @@ func (suite *CSMControllerTestSuite) TestReverseProxyReconcile() {
suite.runFakeCSMManager("", true)
}

func (suite *CSMControllerTestSuite) TestReverseProxyWithSecretReconcile() {
csm := suite.buildFakeRevProxyCSM(csmName, suite.namespace, true, getReverseProxyModuleWithSecret(), string(v1.PowerMax))
csm.Spec.Driver.Common.Envs = append(csm.Spec.Driver.Common.Envs, corev1.EnvVar{Name: "X_CSI_REVPROXY_USE_SECRET", Value: "true"})
err := suite.fakeClient.Create(ctx, &csm)
assert.Nil(suite.T(), err)

suite.runFakeCSMManager("", false)
suite.deleteCSM(csmName)
suite.runFakeCSMManager("", true)
}

func (suite *CSMControllerTestSuite) TestReverseProxySidecarReconcile() {
revProxy := getReverseProxyModule()
deploAsSidecar := corev1.EnvVar{Name: "DeployAsSidecar", Value: "true"}
Expand Down Expand Up @@ -834,6 +845,10 @@ func (suite *CSMControllerTestSuite) TestSyncCSM() {
reverseProxyServerCSM.Spec.Modules = getReverseProxyModule()
modules.IsReverseProxySidecar = func() bool { return false }

reverseProxyWithSecret := shared.MakeCSM(csmName, suite.namespace, configVersion)
reverseProxyWithSecret.Spec.Modules = getReverseProxyModuleWithSecret()
reverseProxyServerCSM.Spec.Driver.CSIDriverType = csmv1.PowerMax

syncCSMTests := []struct {
name string
csm csmv1.ContainerStorageModule
Expand All @@ -846,6 +861,7 @@ func (suite *CSMControllerTestSuite) TestSyncCSM() {
{"reverse proxy server bad op conf", reverseProxyServerCSM, badOperatorConfig, "failed to deploy reverseproxy proxy server"},
{"getDriverConfig bad op config", csm, badOperatorConfig, ""},
{"getDriverConfig error", csmBadType, badOperatorConfig, "no such file or directory"},
{"success: deployAsSidecar with secret", reverseProxyWithSecret, operatorConfig, ""},
}

for _, tt := range syncCSMTests {
Expand Down Expand Up @@ -1904,6 +1920,45 @@ func getReverseProxyModule() []csmv1.Module {
}
}

func getReverseProxyModuleWithSecret() []csmv1.Module {
return []csmv1.Module{
{
Name: csmv1.ReverseProxy,
Enabled: true,
ConfigVersion: "v2.13.0",
Components: []csmv1.ContainerTemplate{
{
Name: string(csmv1.ReverseProxyServer),
Enabled: &[]bool{true}[0],
Envs: []corev1.EnvVar{
{
Name: "X_CSI_REVPROXY_TLS_SECRET",
Value: "csirevproxy-tls-secret",
},
{
Name: "X_CSI_REVPROXY_PORT",
Value: "2222",
},
{
Name: "X_CSI_CONFIG_MAP_NAME",
Value: "powermax-reverseproxy-config",
},
{
Name: "DeployAsSidecar",
Value: "true",
},
{
Name: "X_CSI_REVPROXY_USE_SECRET",
Value: "true",
},
},
},
},
ForceRemoveModule: true,
},
}
}

func (suite *CSMControllerTestSuite) TestDeleteErrorReconcile() {
suite.makeFakeCSM(csmName, suite.namespace, true, append(getAuthModule(), getObservabilityModule()...))
suite.runFakeCSMManager("", false)
Expand Down Expand Up @@ -2419,7 +2474,7 @@ func (suite *CSMControllerTestSuite) ShouldFail(method string, obj runtime.Objec
return nil
}

func (suite *CSMControllerTestSuite) makeFakeRevProxyCSM(name string, ns string, withFinalizer bool, modules []v1.Module, driverType string) {
func (suite *CSMControllerTestSuite) buildFakeRevProxyCSM(name string, ns string, withFinalizer bool, modules []v1.Module, driverType string) v1.ContainerStorageModule {
// Create secrets and config map for Reconcile
sec := shared.MakeSecret("csirevproxy-tls-secret", ns, configVersion)
err := suite.fakeClient.Create(ctx, sec)
Expand Down Expand Up @@ -2461,7 +2516,13 @@ func (suite *CSMControllerTestSuite) makeFakeRevProxyCSM(name string, ns string,
out, _ := json.Marshal(&csm)
csm.Annotations[previouslyAppliedCustomResource] = string(out)

err = suite.fakeClient.Create(ctx, &csm)
return csm
}

func (suite *CSMControllerTestSuite) makeFakeRevProxyCSM(name string, ns string, withFinalizer bool, modules []v1.Module, driverType string) {
csm := suite.buildFakeRevProxyCSM(name, ns, withFinalizer, modules, driverType)

err := suite.fakeClient.Create(ctx, &csm)
assert.Nil(suite.T(), err)
}

Expand Down
Loading

0 comments on commit f3c6c0b

Please sign in to comment.