Disable DWO's workspace proxy handling when proxy configuration is detected

If we allow the DevWorkspace Operator to handle proxy settings for workspaces,
it will add proxy environment variables to workspace containers with the
values it detects on the cluster (or through its own
DevWorkspaceOperatorConfig)

Since these environment variables are defined in the deployment yaml,
their values override values for proxy environment variables defined by
the automount 'proxy-config' configmap.

To avoid this, we configure DWO to not set any proxy settings for
workspaces we manage.

Signed-off-by: Angel Misevski <amisevsk@redhat.com>
pull/1770/head
Angel Misevski 2023-08-10 14:37:25 -04:00
parent fb972f93e7
commit 387f676773
1 changed files with 20 additions and 2 deletions

View File

@ -63,7 +63,7 @@ func (d *DevWorkspaceConfigReconciler) Reconcile(ctx *chetypes.DeployContext) (r
dwoc.Config = &controllerv1alpha1.OperatorConfiguration{}
}
if err := updateWorkspaceConfig(ctx.CheCluster, dwoc.Config); err != nil {
if err := updateWorkspaceConfig(ctx, dwoc.Config); err != nil {
return reconcile.Result{}, false, err
}
@ -78,7 +78,8 @@ func (d *DevWorkspaceConfigReconciler) Finalize(ctx *chetypes.DeployContext) boo
return true
}
func updateWorkspaceConfig(cheCluster *chev2.CheCluster, operatorConfig *controllerv1alpha1.OperatorConfiguration) error {
func updateWorkspaceConfig(ctx *chetypes.DeployContext, operatorConfig *controllerv1alpha1.OperatorConfiguration) error {
cheCluster := ctx.CheCluster
devEnvironments := &cheCluster.Spec.DevEnvironments
if operatorConfig.Workspace == nil {
operatorConfig.Workspace = &controllerv1alpha1.WorkspaceConfig{}
@ -104,6 +105,13 @@ func updateWorkspaceConfig(cheCluster *chev2.CheCluster, operatorConfig *control
updateWorkspaceImagePullPolicy(devEnvironments.ImagePullPolicy, operatorConfig.Workspace)
if ctx.Proxy.HttpProxy != "" || ctx.Proxy.HttpsProxy != "" {
if operatorConfig.Routing == nil {
operatorConfig.Routing = &controllerv1alpha1.RoutingConfig{}
}
updateProxyConfig(operatorConfig.Routing)
}
operatorConfig.Workspace.DeploymentStrategy = v1.DeploymentStrategyType(utils.GetValue(string(devEnvironments.DeploymentStrategy), constants.DefaultDeploymentStrategy))
return nil
}
@ -213,6 +221,16 @@ func updateProjectCloneConfig(devEnvironments *chev2.CheClusterDevEnvironments,
workspaceConfig.ProjectCloneConfig.Resources = cheResourcesToCoreV1Resources(container.Resources)
}
func updateProxyConfig(routingConfig *controllerv1alpha1.RoutingConfig) {
// Since we create proxy configmaps to mount proxy settings, we want to disable
// proxy handling in DWO; otherwise the env vars added by DWO will override the env
// vars we intend to mount via configmap.
routingConfig.ProxyConfig = &controllerv1alpha1.Proxy{}
routingConfig.ProxyConfig.HttpProxy = pointer.String("")
routingConfig.ProxyConfig.HttpsProxy = pointer.String("")
routingConfig.ProxyConfig.NoProxy = pointer.String("")
}
// Returns the default container security context required for container builds.
// Returns an error if the default container security context could not be retrieved.
func getDefaultContainerSecurityContext() (*corev1.SecurityContext, error) {