Skip to content
Closed
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
21 changes: 21 additions & 0 deletions pkg/operator/csidriveroperator/hypershift_deployment_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,27 @@ func (c *HyperShiftDeploymentController) Sync(ctx context.Context, syncCtx facto
return fmt.Errorf("failed to inject proxy data into deployment: %w", err)
}

// The existence of the environment variable, ARO_HCP_SECRET_PROVIDER_CLASS_FOR_FILE, means this is an ARO HCP
// deployment. We need to pass along additional environment variables for ARO HCP in order to mount the backing
// certificates, related to the client IDs, in a volume on the azure-disk-csi-controller and
// azure-file-csi-controller deployments.
var envVars []corev1.EnvVar
if os.Getenv("ARO_HCP_SECRET_PROVIDER_CLASS_FOR_DISK") != "" && requiredCopy.Name == "azure-disk-csi-driver-operator" {
envVars = []corev1.EnvVar{
{Name: "ARO_HCP_SECRET_PROVIDER_CLASS_FOR_DISK", Value: os.Getenv("ARO_HCP_SECRET_PROVIDER_CLASS_FOR_DISK")},
}
}

if os.Getenv("ARO_HCP_SECRET_PROVIDER_CLASS_FOR_FILE") != "" && requiredCopy.Name == "azure-file-csi-driver-operator" {
envVars = []corev1.EnvVar{
{Name: "ARO_HCP_SECRET_PROVIDER_CLASS_FOR_FILE", Value: os.Getenv("ARO_HCP_SECRET_PROVIDER_CLASS_FOR_FILE")},
}
}
Comment on lines +135 to +150
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would prefer a generic function like InjectPassThroughEnvVars with a list (map with operator name?) of env. vars to pass from the upper layer (CVO / hypershift) down to the CSI driver operators. Having a specific code for each env. var looks error prone to me - now it's just two env. vars for ARO, but who knows what comes next.

And you can unit test that function nicely 3:-).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

heh, too late, I missed it's a cherry pick

/lgtm
/approve
/label backport-risk-assessed


if len(envVars) > 0 {
requiredCopy.Spec.Template.Spec.Containers[0].Env = append(requiredCopy.Spec.Template.Spec.Containers[0].Env, envVars...)
}

lastGeneration := resourcemerge.ExpectedDeploymentGeneration(requiredCopy, opStatus.Generations)
deployment, _, err := resourceapply.ApplyDeployment(ctx, c.mgmtClient.KubeClient.AppsV1(), c.eventRecorder, requiredCopy, lastGeneration)
if err != nil {
Expand Down