From 851f110311c09a8b26155915d559bf14e0f228a8 Mon Sep 17 00:00:00 2001 From: Angel Misevski Date: Wed, 18 Oct 2023 15:49:52 -0400 Subject: [PATCH] Add documentation on why proxy configuration is disabled in DWO Co-authored-by: Anatolii Bazko Signed-off-by: Angel Misevski --- controllers/usernamespace/controller_test.go | 2 +- pkg/deploy/dev-workspace-config/dev_workspace_config.go | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/controllers/usernamespace/controller_test.go b/controllers/usernamespace/controller_test.go index 30149f581..a9bac86f3 100644 --- a/controllers/usernamespace/controller_test.go +++ b/controllers/usernamespace/controller_test.go @@ -341,7 +341,7 @@ func TestCreatesDataInNamespace(t *testing.T) { assert.Equal(t, "true", proxySettings.GetLabels()[dwconstants.DevWorkspaceMountLabel], "proxy settings should be labeled as mounted") - assert.Equal(t, 2, len(proxySettings.Data), "Expecting just 1 element in the default proxy settings") + assert.Equal(t, 2, len(proxySettings.Data), "Expecting 2 elements in the default proxy settings") assert.Equal(t, ".svc", proxySettings.Data["NO_PROXY"], "Unexpected proxy settings") diff --git a/pkg/deploy/dev-workspace-config/dev_workspace_config.go b/pkg/deploy/dev-workspace-config/dev_workspace_config.go index f76c9c52c..b55688f84 100644 --- a/pkg/deploy/dev-workspace-config/dev_workspace_config.go +++ b/pkg/deploy/dev-workspace-config/dev_workspace_config.go @@ -105,11 +105,15 @@ func updateWorkspaceConfig(ctx *chetypes.DeployContext, operatorConfig *controll updateWorkspaceImagePullPolicy(devEnvironments.ImagePullPolicy, operatorConfig.Workspace) + // If the CheCluster has a configured proxy, or if the Che Operator has detected a proxy configuration, + // we need to disable automatic proxy handling in the DevWorkspace Operator as its implementation collides + // with ours -- they set environment variables the deployment spec explicitly, which overrides the proxy-settings + // automount configmap. if ctx.Proxy.HttpProxy != "" || ctx.Proxy.HttpsProxy != "" { if operatorConfig.Routing == nil { operatorConfig.Routing = &controllerv1alpha1.RoutingConfig{} } - updateProxyConfig(operatorConfig.Routing) + disableDWOProxy(operatorConfig.Routing) } operatorConfig.Workspace.DeploymentStrategy = v1.DeploymentStrategyType(utils.GetValue(string(devEnvironments.DeploymentStrategy), constants.DefaultDeploymentStrategy)) @@ -221,7 +225,7 @@ func updateProjectCloneConfig(devEnvironments *chev2.CheClusterDevEnvironments, workspaceConfig.ProjectCloneConfig.Resources = cheResourcesToCoreV1Resources(container.Resources) } -func updateProxyConfig(routingConfig *controllerv1alpha1.RoutingConfig) { +func disableDWOProxy(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.