diff --git a/DEPENDENCIES.md b/DEPENDENCIES.md index 21cf7feab..4091fcd58 100644 --- a/DEPENDENCIES.md +++ b/DEPENDENCIES.md @@ -448,7 +448,7 @@ | [golang.org/x/mobile@d3739f865fa66d07c1f506505c18aac71a8ead6e](https://cs.opensource.google/go) | BSD-3-Clause | N/A | | [github.com/devfile/api/v2@0d163445376d4d28898f3fbac4f2ff62863b944b](https://github.com/devfile/api.git) | Apache-2.0 | [clearlydefined](https://clearlydefined.io/definitions/git/github/devfile/api/0d163445376d4d28898f3fbac4f2ff62863b944b) | | [github.com/che-incubator/kubernetes-image-puller-operator@0128446f5af78587c0427a35d693bbb8d24036bc](https://github.com/che-incubator/kubernetes-image-puller-operator.git) | EPL-2.0 | todo | -| [github.com/devfile/devworkspace-operator@v0.21.0](https://github.com/devfile/devworkspace-operator.git) | Apache-2.0 | [clearlydefined](https://clearlydefined.io/definitions/git/github/devfile/devworkspace-operator/21edf4373322c228ed54a5d4747b0451435a8f08) | +| [github.com/devfile/devworkspace-operator@v0.23.0](https://github.com/devfile/devworkspace-operator.git) | Apache-2.0 | [clearlydefined](https://clearlydefined.io/definitions/git/github/devfile/devworkspace-operator/2d9aa0fa7ba6296c51dd44269bf5c872f5dd41b7) | | [github.com/gophercloud/gophercloud@v0.1.0](https://github.com/gophercloud/gophercloud) | Apache-2.0 | [clearlydefined](https://clearlydefined.io/definitions/go/golang/github.com%2Fgophercloud/gophercloud/v0.1.0) | | [gopkg.in/imdario/mergo.v0@v0.3.7](https://github.com/imdario/mergo/) | BSD-3-Clause | [clearlydefined](https://clearlydefined.io/definitions/go/golang/github.com%2Fimdario/mergo/v0.3.7) | | [github.com/mikefarah/yq/v2@v2.4.1](https://github.com/mikefarah/yq) | MIT | [clearlydefined](https://clearlydefined.io/definitions/git/github/mikefarah/yq/b8b2c9de6189471c0cdbd459b5b0b49a57844bd4) | diff --git a/bundle/next/eclipse-che/manifests/che-operator.clusterserviceversion.yaml b/bundle/next/eclipse-che/manifests/che-operator.clusterserviceversion.yaml index 786b73e7b..3eef1bc49 100644 --- a/bundle/next/eclipse-che/manifests/che-operator.clusterserviceversion.yaml +++ b/bundle/next/eclipse-che/manifests/che-operator.clusterserviceversion.yaml @@ -77,7 +77,7 @@ metadata: operators.operatorframework.io/project_layout: go.kubebuilder.io/v3 repository: https://github.com/eclipse-che/che-operator support: Eclipse Foundation - name: eclipse-che.v7.76.0-811.next + name: eclipse-che.v7.76.0-812.next namespace: placeholder spec: apiservicedefinitions: {} @@ -1234,7 +1234,7 @@ spec: minKubeVersion: 1.19.0 provider: name: Eclipse Foundation - version: 7.76.0-811.next + version: 7.76.0-812.next webhookdefinitions: - admissionReviewVersions: - v1 diff --git a/controllers/usernamespace/controller.go b/controllers/usernamespace/controller.go index 1af7c158a..e032e9040 100644 --- a/controllers/usernamespace/controller.go +++ b/controllers/usernamespace/controller.go @@ -405,12 +405,15 @@ func (r *CheUserNamespaceReconciler) reconcileProxySettings(ctx context.Context, proxySettings := map[string]string{} if proxyConfig.HttpProxy != "" { proxySettings["HTTP_PROXY"] = proxyConfig.HttpProxy + proxySettings["http_proxy"] = proxyConfig.HttpProxy } if proxyConfig.HttpsProxy != "" { proxySettings["HTTPS_PROXY"] = proxyConfig.HttpsProxy + proxySettings["https_proxy"] = proxyConfig.HttpsProxy } if proxyConfig.NoProxy != "" { proxySettings["NO_PROXY"] = proxyConfig.NoProxy + proxySettings["no_proxy"] = proxyConfig.NoProxy } key := client.ObjectKey{Name: prefixedName("proxy-settings"), Namespace: targetNs} diff --git a/controllers/usernamespace/controller_test.go b/controllers/usernamespace/controller_test.go index 0d1f3d532..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, 1, 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/go.mod b/go.mod index 942e35398..a60cde3db 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.18 require ( github.com/che-incubator/kubernetes-image-puller-operator v0.0.0-20210929175054-0128446f5af7 github.com/devfile/api/v2 v2.2.1-alpha.0.20230413012049-a6c32fca0dbd - github.com/devfile/devworkspace-operator v0.22.0 + github.com/devfile/devworkspace-operator v0.23.0 github.com/go-logr/logr v1.2.3 github.com/golang/mock v1.5.0 github.com/google/go-cmp v0.5.9 diff --git a/go.sum b/go.sum index 18b632f3b..29d03ace5 100644 --- a/go.sum +++ b/go.sum @@ -102,8 +102,8 @@ github.com/deislabs/oras v0.8.1/go.mod h1:Mx0rMSbBNaNfY9hjpccEnxkOqJL6KGjtxNHPLC github.com/denisenkom/go-mssqldb v0.0.0-20190204142019-df6d76eb9289/go.mod h1:xN/JuLBIz4bjkxNmByTiV1IbhfnYb6oo99phBn4Eqhc= github.com/devfile/api/v2 v2.2.1-alpha.0.20230413012049-a6c32fca0dbd h1:HpGR728CfB6BB9ZuFtQb0UeTIYNFgpuGsuoMOJNMUTM= github.com/devfile/api/v2 v2.2.1-alpha.0.20230413012049-a6c32fca0dbd/go.mod h1:qp8jcw12y1JdCsxjK/7LJ7uWaJOxcY1s2LUk5PhbkbM= -github.com/devfile/devworkspace-operator v0.22.0 h1:Q2w419Y4E5yOYxIY6LI4u4fHi5YewKQsRIN1J4Jlh3Q= -github.com/devfile/devworkspace-operator v0.22.0/go.mod h1:42cQKSbE+Zdqez8X5IqlEfdeeA0a/LkOTe2kkekJX6c= +github.com/devfile/devworkspace-operator v0.23.0 h1:QUJXt6OtKILTuQUbSE2r6zyIysxhqx9sgZeMo1l7yJs= +github.com/devfile/devworkspace-operator v0.23.0/go.mod h1:42cQKSbE+Zdqez8X5IqlEfdeeA0a/LkOTe2kkekJX6c= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dhui/dktest v0.3.2/go.mod h1:l1/ib23a/CmxAe7yixtrYPc8Iy90Zy2udyaHINM5p58= github.com/docker/cli v0.0.0-20200130152716-5d0cf8839492 h1:FwssHbCDJD025h+BchanCwE1Q8fyMgqDr2mOQAWOLGw= diff --git a/pkg/deploy/dev-workspace-config/dev_workspace_config.go b/pkg/deploy/dev-workspace-config/dev_workspace_config.go index 3a5c27ebb..b55688f84 100644 --- a/pkg/deploy/dev-workspace-config/dev_workspace_config.go +++ b/pkg/deploy/dev-workspace-config/dev_workspace_config.go @@ -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,17 @@ func updateWorkspaceConfig(cheCluster *chev2.CheCluster, operatorConfig *control 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{} + } + disableDWOProxy(operatorConfig.Routing) + } + operatorConfig.Workspace.DeploymentStrategy = v1.DeploymentStrategyType(utils.GetValue(string(devEnvironments.DeploymentStrategy), constants.DefaultDeploymentStrategy)) return nil } @@ -213,6 +225,16 @@ func updateProjectCloneConfig(devEnvironments *chev2.CheClusterDevEnvironments, workspaceConfig.ProjectCloneConfig.Resources = cheResourcesToCoreV1Resources(container.Resources) } +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. + 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) { diff --git a/vendor/github.com/devfile/devworkspace-operator/apis/controller/v1alpha1/devworkspaceoperatorconfig_types.go b/vendor/github.com/devfile/devworkspace-operator/apis/controller/v1alpha1/devworkspaceoperatorconfig_types.go index e8ee5a15f..e1bd62eee 100644 --- a/vendor/github.com/devfile/devworkspace-operator/apis/controller/v1alpha1/devworkspaceoperatorconfig_types.go +++ b/vendor/github.com/devfile/devworkspace-operator/apis/controller/v1alpha1/devworkspaceoperatorconfig_types.go @@ -54,7 +54,8 @@ type RoutingConfig struct { // On OpenShift, the operator automatically reads values from the "cluster" proxies.config.openshift.io // object and this value only needs to be set to override those defaults. Values for httpProxy // and httpsProxy override the cluster configuration directly. Entries for noProxy are merged - // with the noProxy values in the cluster configuration. + // with the noProxy values in the cluster configuration. To ignore automatically read values from the cluster, + // set values in fields to the empty string ("") // // Changes to the proxy configuration are detected by the DevWorkspace Operator and propagated to // DevWorkspaces. However, changing the proxy configuration for the DevWorkspace Operator itself @@ -154,13 +155,16 @@ type PersistentHomeConfig struct { } type Proxy struct { - // HttpProxy is the URL of the proxy for HTTP requests, in the format http://USERNAME:PASSWORD@SERVER:PORT/ - HttpProxy string `json:"httpProxy,omitempty"` - // HttpsProxy is the URL of the proxy for HTTPS requests, in the format http://USERNAME:PASSWORD@SERVER:PORT/ - HttpsProxy string `json:"httpsProxy,omitempty"` + // HttpProxy is the URL of the proxy for HTTP requests, in the format http://USERNAME:PASSWORD@SERVER:PORT/. To ignore + // automatically detected proxy settings for the cluster, set this field to an empty string ("") + HttpProxy *string `json:"httpProxy,omitempty"` + // HttpsProxy is the URL of the proxy for HTTPS requests, in the format http://USERNAME:PASSWORD@SERVER:PORT/. To ignore + // automatically detected proxy settings for the cluster, set this field to an empty string ("") + HttpsProxy *string `json:"httpsProxy,omitempty"` // NoProxy is a comma-separated list of hostnames and/or CIDRs for which the proxy should not be used. Ignored - // when HttpProxy and HttpsProxy are unset - NoProxy string `json:"noProxy,omitempty"` + // when HttpProxy and HttpsProxy are unset. To ignore automatically detected proxy settings for the cluster, set this + // field to an empty string ("") + NoProxy *string `json:"noProxy,omitempty"` } type StorageSizes struct { diff --git a/vendor/github.com/devfile/devworkspace-operator/apis/controller/v1alpha1/devworkspacerouting_types.go b/vendor/github.com/devfile/devworkspace-operator/apis/controller/v1alpha1/devworkspacerouting_types.go index 80aa98806..f400ca8b3 100644 --- a/vendor/github.com/devfile/devworkspace-operator/apis/controller/v1alpha1/devworkspacerouting_types.go +++ b/vendor/github.com/devfile/devworkspace-operator/apis/controller/v1alpha1/devworkspacerouting_types.go @@ -62,6 +62,7 @@ const ( RoutingReady DevWorkspaceRoutingPhase = "Ready" RoutingPreparing DevWorkspaceRoutingPhase = "Preparing" RoutingFailed DevWorkspaceRoutingPhase = "Failed" + RoutingStopped DevWorkspaceRoutingPhase = "Stopped" ) type ExposedEndpoint struct { diff --git a/vendor/github.com/devfile/devworkspace-operator/apis/controller/v1alpha1/zz_generated.deepcopy.go b/vendor/github.com/devfile/devworkspace-operator/apis/controller/v1alpha1/zz_generated.deepcopy.go index b5e4489f9..7f94e19c6 100644 --- a/vendor/github.com/devfile/devworkspace-operator/apis/controller/v1alpha1/zz_generated.deepcopy.go +++ b/vendor/github.com/devfile/devworkspace-operator/apis/controller/v1alpha1/zz_generated.deepcopy.go @@ -494,6 +494,21 @@ func (in *ProjectCloneConfig) DeepCopy() *ProjectCloneConfig { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Proxy) DeepCopyInto(out *Proxy) { *out = *in + if in.HttpProxy != nil { + in, out := &in.HttpProxy, &out.HttpProxy + *out = new(string) + **out = **in + } + if in.HttpsProxy != nil { + in, out := &in.HttpsProxy, &out.HttpsProxy + *out = new(string) + **out = **in + } + if in.NoProxy != nil { + in, out := &in.NoProxy, &out.NoProxy + *out = new(string) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Proxy. @@ -512,7 +527,7 @@ func (in *RoutingConfig) DeepCopyInto(out *RoutingConfig) { if in.ProxyConfig != nil { in, out := &in.ProxyConfig, &out.ProxyConfig *out = new(Proxy) - **out = **in + (*in).DeepCopyInto(*out) } } diff --git a/vendor/github.com/devfile/devworkspace-operator/controllers/controller/devworkspacerouting/devworkspacerouting_controller.go b/vendor/github.com/devfile/devworkspace-operator/controllers/controller/devworkspacerouting/devworkspacerouting_controller.go index 9d2c9cab3..6e93eb17e 100644 --- a/vendor/github.com/devfile/devworkspace-operator/controllers/controller/devworkspacerouting/devworkspacerouting_controller.go +++ b/vendor/github.com/devfile/devworkspace-operator/controllers/controller/devworkspacerouting/devworkspacerouting_controller.go @@ -108,6 +108,9 @@ func (r *DevWorkspaceRoutingReconciler) Reconcile(ctx context.Context, req ctrl. } if instance.Annotations != nil && instance.Annotations[constants.DevWorkspaceStartedStatusAnnotation] == "false" { + if err := r.setStatusStopped(instance); err != nil { + return reconcile.Result{}, err + } return reconcile.Result{}, nil } @@ -291,6 +294,14 @@ func (r *DevWorkspaceRoutingReconciler) reconcileStatus( return r.Status().Update(context.TODO(), instance) } +func (r *DevWorkspaceRoutingReconciler) setStatusStopped(instance *controllerv1alpha1.DevWorkspaceRouting) error { + instance.Status.Phase = controllerv1alpha1.RoutingStopped + instance.Status.Message = "DevWorkspace is not started" + instance.Status.PodAdditions = nil + instance.Status.ExposedEndpoints = nil + return r.Status().Update(context.TODO(), instance) +} + func contains(list []string, s string) bool { for _, v := range list { if v == s { diff --git a/vendor/github.com/devfile/devworkspace-operator/pkg/config/proxy/openshift.go b/vendor/github.com/devfile/devworkspace-operator/pkg/config/proxy/openshift.go index 434ec069b..4c4d720ae 100644 --- a/vendor/github.com/devfile/devworkspace-operator/pkg/config/proxy/openshift.go +++ b/vendor/github.com/devfile/devworkspace-operator/pkg/config/proxy/openshift.go @@ -51,9 +51,9 @@ func GetClusterProxyConfig(nonCachedClient crclient.Client) (*controller.Proxy, } proxyConfig := &controller.Proxy{ - HttpProxy: proxy.Status.HTTPProxy, - HttpsProxy: proxy.Status.HTTPSProxy, - NoProxy: proxy.Status.NoProxy, + HttpProxy: &proxy.Status.HTTPProxy, + HttpsProxy: &proxy.Status.HTTPSProxy, + NoProxy: &proxy.Status.NoProxy, } return proxyConfig, nil @@ -63,31 +63,53 @@ func GetClusterProxyConfig(nonCachedClient crclient.Client) (*controller.Proxy, // operator configuration taking precedence. Accepts nil arguments. If both arguments are nil, returns nil. func MergeProxyConfigs(operatorConfig, clusterConfig *controller.Proxy) *controller.Proxy { if clusterConfig == nil { - return operatorConfig + return removeEmptyStrings(operatorConfig) } if operatorConfig == nil { - return clusterConfig + return removeEmptyStrings(clusterConfig) } + mergedProxy := &controller.Proxy{ HttpProxy: operatorConfig.HttpProxy, HttpsProxy: operatorConfig.HttpsProxy, NoProxy: operatorConfig.NoProxy, } - if mergedProxy.HttpProxy == "" { + if mergedProxy.HttpProxy == nil { mergedProxy.HttpProxy = clusterConfig.HttpProxy } - if mergedProxy.HttpsProxy == "" { + if mergedProxy.HttpsProxy == nil { mergedProxy.HttpsProxy = clusterConfig.HttpsProxy } - if mergedProxy.NoProxy == "" { + if mergedProxy.NoProxy == nil { mergedProxy.NoProxy = clusterConfig.NoProxy - } else { + } else if *mergedProxy.NoProxy != "" { // Merge noProxy fields, joining with a comma - if clusterConfig.NoProxy != "" { - mergedProxy.NoProxy = fmt.Sprintf("%s,%s", clusterConfig.NoProxy, operatorConfig.NoProxy) + if clusterConfig.NoProxy != nil { + noProxy := fmt.Sprintf("%s,%s", *clusterConfig.NoProxy, *operatorConfig.NoProxy) + mergedProxy.NoProxy = &noProxy } } - return mergedProxy + return removeEmptyStrings(mergedProxy) +} + +// removeEmptyStrings is a utility function for removing empty fields from a proxy configuration. This is required +// to allow overriding +func removeEmptyStrings(proxyConfig *controller.Proxy) *controller.Proxy { + if proxyConfig == nil { + return nil + } + + updated := &controller.Proxy{} + if proxyConfig.HttpProxy != nil && *proxyConfig.HttpProxy != "" { + updated.HttpProxy = proxyConfig.HttpProxy + } + if proxyConfig.HttpsProxy != nil && *proxyConfig.HttpsProxy != "" { + updated.HttpsProxy = proxyConfig.HttpsProxy + } + if proxyConfig.NoProxy != nil && *proxyConfig.NoProxy != "" { + updated.NoProxy = proxyConfig.NoProxy + } + return updated } diff --git a/vendor/modules.txt b/vendor/modules.txt index 450cf248b..7ee262749 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -32,7 +32,7 @@ github.com/davecgh/go-spew/spew github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2 github.com/devfile/api/v2/pkg/attributes github.com/devfile/api/v2/pkg/devfile -# github.com/devfile/devworkspace-operator v0.22.0 +# github.com/devfile/devworkspace-operator v0.23.0 ## explicit; go 1.18 github.com/devfile/devworkspace-operator/apis/controller/v1alpha1 github.com/devfile/devworkspace-operator/controllers/controller/devworkspacerouting