Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Che-Theia with DevWorkspaces sometimes overwrites the DevWorkspace in-cluster object #21244

Closed
Tracked by #21351
amisevsk opened this issue Mar 9, 2022 · 4 comments · May be fixed by eclipse-che/che-theia#1344
Closed
Tracked by #21351
Assignees
Labels
area/editor/theia Issues related to the che-theia IDE of Che engine/devworkspace Issues related to Che configured to use the devworkspace controller as workspace engine. kind/bug Outline of a bug - must adhere to the bug report template. severity/P1 Has a major impact to usage or development of the system.
Milestone

Comments

@amisevsk
Copy link
Contributor

amisevsk commented Mar 9, 2022

Describe the bug

Theia sometimes applies the contents of $DEVWORKSPACE_FLATTENED_DEVFILE to the cluster, overwriting the cluster object with its flattened equivalent. This breaks the connection between the workspace and any plugins defined in DevWorkspaceTemplates.

This has the further issue that it's harder to e.g. change the editor in the DevWorkspace as the contents of e.g. the Theia plugin are included among the original components.

Che version

next (development version)

Steps to reproduce

  1. Start a workspace via factory link che-url/#https://github.com/che-samples/golang-example/tree/devfilev2
  2. Note DevWorkspace on cluster created from this factory (e.g. golang-example-xxxx)
  3. From within Theia, use ctrl+shift+p to Git: Add Remote... and enter e.g. https://github.com/golang/example.git
  4. Check the DevWorkspace from step 2 and see that it is changed

Expected behavior

If Theia modifies the Devfile, it should use $DEVWORKSPACE_ORIGINAL_DEVFILE as a base.

Runtime

OpenShift

Screenshots

No response

Installation method

chectl/next

Environment

Linux

Eclipse Che Logs

No response

Additional context

Sample diff from following the reproducer above
--- old.spec.yaml	2022-03-09 15:13:45.637133730 -0500
+++ new.spec.yaml	2022-03-09 15:15:42.155462404 -0500
@@ -1,4 +1,9 @@
 commands:
+  - apply:
+      component: remote-runtime-injector
+    attributes:
+      controller.devfile.io/imported-by: theia-ide-workspace14549e4b9643420f
+    id: init-container-command
   - exec:
       commandLine: go get -d && go run main.go
       component: tools
@@ -32,6 +37,184 @@
     id: run-current-file
 components:
   - attributes:
+      app.kubernetes.io/component: che-theia
+      app.kubernetes.io/part-of: che-theia.eclipse.org
+      controller.devfile.io/imported-by: theia-ide-workspace14549e4b9643420f
+    container:
+      cpuLimit: 1500m
+      cpuRequest: 100m
+      endpoints:
+        - attributes:
+            controller.devfile.io/endpoint-url: https://che-eclipse-che.apps.cluster-jc4kr.jc4kr.sandbox1192.opentlc.com/workspace14549e4b9643420f/theia-ide/3100/
+            cookiesAuthEnabled: true
+            discoverable: false
+            type: main
+            urlRewriteSupported: true
+          exposure: public
+          name: theia
+          protocol: https
+          secure: false
+          targetPort: 3100
+        - attributes:
+            controller.devfile.io/endpoint-url: https://che-eclipse-che.apps.cluster-jc4kr.jc4kr.sandbox1192.opentlc.com/workspace14549e4b9643420f/theia-ide/webviews/
+            cookiesAuthEnabled: true
+            discoverable: false
+            type: webview
+            unique: true
+            urlRewriteSupported: true
+          exposure: public
+          name: webviews
+          protocol: https
+          secure: false
+          targetPort: 3100
+        - attributes:
+            controller.devfile.io/endpoint-url: https://che-eclipse-che.apps.cluster-jc4kr.jc4kr.sandbox1192.opentlc.com/workspace14549e4b9643420f/theia-ide/mini-browser/
+            cookiesAuthEnabled: true
+            discoverable: false
+            type: mini-browser
+            unique: true
+            urlRewriteSupported: true
+          exposure: public
+          name: mini-browser
+          protocol: https
+          secure: false
+          targetPort: 3100
+        - attributes:
+            controller.devfile.io/endpoint-url: https://che-eclipse-che.apps.cluster-jc4kr.jc4kr.sandbox1192.opentlc.com/workspace14549e4b9643420f/theia-ide/3130/
+            discoverable: false
+            type: ide-dev
+            urlRewriteSupported: true
+          exposure: public
+          name: theia-dev
+          protocol: http
+          targetPort: 3130
+        - attributes:
+            controller.devfile.io/endpoint-url: https://che-eclipse-che.apps.cluster-jc4kr.jc4kr.sandbox1192.opentlc.com/workspace14549e4b9643420f/theia-ide/13131/
+            discoverable: false
+            urlRewriteSupported: true
+          exposure: public
+          name: theia-redirect-1
+          protocol: http
+          targetPort: 13131
+        - attributes:
+            controller.devfile.io/endpoint-url: https://che-eclipse-che.apps.cluster-jc4kr.jc4kr.sandbox1192.opentlc.com/workspace14549e4b9643420f/theia-ide/13132/
+            discoverable: false
+            urlRewriteSupported: true
+          exposure: public
+          name: theia-redirect-2
+          protocol: http
+          targetPort: 13132
+        - attributes:
+            controller.devfile.io/endpoint-url: https://che-eclipse-che.apps.cluster-jc4kr.jc4kr.sandbox1192.opentlc.com/workspace14549e4b9643420f/theia-ide/13133/
+            discoverable: false
+            urlRewriteSupported: true
+          exposure: public
+          name: theia-redirect-3
+          protocol: http
+          targetPort: 13133
+        - attributes:
+            controller.devfile.io/endpoint-url: wss://che-eclipse-che.apps.cluster-jc4kr.jc4kr.sandbox1192.opentlc.com/workspace14549e4b9643420f/theia-ide/3333/
+            cookiesAuthEnabled: true
+            discoverable: false
+            type: collocated-terminal
+            urlRewriteSupported: true
+          exposure: public
+          name: terminal
+          protocol: wss
+          secure: false
+          targetPort: 3333
+      env:
+        - name: THEIA_PLUGINS
+          value: local-dir:///plugins
+        - name: HOSTED_PLUGIN_HOSTNAME
+          value: 0.0.0.0
+        - name: HOSTED_PLUGIN_PORT
+          value: '3130'
+        - name: THEIA_HOST
+          value: 127.0.0.1
+        - name: CHE_DASHBOARD_URL
+          value: https://che-eclipse-che.apps.cluster-jc4kr.jc4kr.sandbox1192.opentlc.com
+        - name: CHE_PLUGIN_REGISTRY_URL
+          value: https://che-eclipse-che.apps.cluster-jc4kr.jc4kr.sandbox1192.opentlc.com/plugin-registry/v3
+        - name: CHE_PLUGIN_REGISTRY_INTERNAL_URL
+          value: http://plugin-registry.eclipse-che.svc:8080/v3
+      image: quay.io/eclipse/che-theia:next
+      memoryLimit: 512M
+      mountSources: true
+      sourceMapping: /projects
+      volumeMounts:
+        - name: plugins
+          path: /plugins
+        - name: theia-local
+          path: /home/theia/.theia
+    name: theia-ide
+  - attributes:
+      controller.devfile.io/imported-by: theia-ide-workspace14549e4b9643420f
+    name: plugins
+    volume: {}
+  - attributes:
+      controller.devfile.io/imported-by: theia-ide-workspace14549e4b9643420f
+    name: theia-local
+    volume: {}
+  - attributes:
+      app.kubernetes.io/component: machine-exec
+      app.kubernetes.io/part-of: che-theia.eclipse.org
+      controller.devfile.io/imported-by: theia-ide-workspace14549e4b9643420f
+    container:
+      command:
+        - /go/bin/che-machine-exec
+        - --url
+        - 127.0.0.1:3333
+        - --idle-timeout
+        - 15m
+      cpuLimit: 500m
+      cpuRequest: 30m
+      env:
+        - name: CHE_DASHBOARD_URL
+          value: https://che-eclipse-che.apps.cluster-jc4kr.jc4kr.sandbox1192.opentlc.com
+        - name: CHE_PLUGIN_REGISTRY_URL
+          value: https://che-eclipse-che.apps.cluster-jc4kr.jc4kr.sandbox1192.opentlc.com/plugin-registry/v3
+        - name: CHE_PLUGIN_REGISTRY_INTERNAL_URL
+          value: http://plugin-registry.eclipse-che.svc:8080/v3
+      image: quay.io/eclipse/che-machine-exec:next
+      memoryLimit: 128Mi
+      memoryRequest: 32Mi
+      sourceMapping: /projects
+    name: che-machine-exec
+  - attributes:
+      app.kubernetes.io/component: remote-runtime-injector
+      app.kubernetes.io/part-of: che-theia.eclipse.org
+      controller.devfile.io/imported-by: theia-ide-workspace14549e4b9643420f
+    container:
+      cpuLimit: 500m
+      cpuRequest: 30m
+      env:
+        - name: PLUGIN_REMOTE_ENDPOINT_EXECUTABLE
+          value: /remote-endpoint/plugin-remote-endpoint
+        - name: REMOTE_ENDPOINT_VOLUME_NAME
+          value: remote-endpoint
+        - name: CHE_DASHBOARD_URL
+          value: https://che-eclipse-che.apps.cluster-jc4kr.jc4kr.sandbox1192.opentlc.com
+        - name: CHE_PLUGIN_REGISTRY_URL
+          value: https://che-eclipse-che.apps.cluster-jc4kr.jc4kr.sandbox1192.opentlc.com/plugin-registry/v3
+        - name: CHE_PLUGIN_REGISTRY_INTERNAL_URL
+          value: http://plugin-registry.eclipse-che.svc:8080/v3
+      image: quay.io/eclipse/che-theia-endpoint-runtime-binary:next
+      memoryLimit: 128Mi
+      memoryRequest: 32Mi
+      sourceMapping: /projects
+      volumeMounts:
+        - name: plugins
+          path: /plugins
+        - name: remote-endpoint
+          path: /remote-endpoint
+    name: remote-runtime-injector
+  - attributes:
+      controller.devfile.io/imported-by: theia-ide-workspace14549e4b9643420f
+    name: remote-endpoint
+    volume:
+      ephemeral: true
+  - attributes:
       app.kubernetes.io/name: tools
       che-theia.eclipse.org/vscode-extensions:
         - https://github.com/golang/vscode-go/releases/download/v0.23.0/go-0.23.0.vsix
@@ -41,7 +224,9 @@
         - -c
         - ${PLUGIN_REMOTE_ENDPOINT_EXECUTABLE}
       endpoints:
-        - exposure: public
+        - attributes:
+            controller.devfile.io/endpoint-url: http://workspace14549e4b9643420f-1.apps.cluster-jc4kr.jc4kr.sandbox1192.opentlc.com/
+          exposure: public
           name: 8080-tcp
           protocol: http
           targetPort: 8080
@@ -64,11 +249,9 @@
         - name: plugins
           path: /plugins
     name: tools
-  - name: theia-ide-workspace14549e4b9643420f
-    plugin:
-      kubernetes:
-        name: theia-ide-workspace14549e4b9643420f
-        namespace: user20-che
+events:
+  preStart:
+    - init-container-command
 projects:
   - git:
       checkoutFrom:
@amisevsk amisevsk added kind/bug Outline of a bug - must adhere to the bug report template. area/editor/theia Issues related to the che-theia IDE of Che engine/devworkspace Issues related to Che configured to use the devworkspace controller as workspace engine. labels Mar 9, 2022
@che-bot che-bot added the status/need-triage An issue that needs to be prioritized by the curator responsible for the triage. See https://github. label Mar 9, 2022
@Kasturi1820 Kasturi1820 added severity/P2 Has a minor but important impact to the usage or development of the system. and removed status/need-triage An issue that needs to be prioritized by the curator responsible for the triage. See https://github. labels Mar 14, 2022
@dkwon17
Copy link
Contributor

dkwon17 commented Mar 25, 2022

I notice that I cannot restart the devworkspace after adding a new remote from the editor. After running these steps:

Steps to reproduce

  1. Start a workspace via factory link che-url/#https://github.com/che-samples/golang-example/tree/devfilev2
  2. Note DevWorkspace on cluster created from this factory (e.g. golang-example-xxxx)
  3. From within Theia, use ctrl+shift+p to Git: Add Remote... and enter e.g. https://github.com/golang/example.git
  4. Check the DevWorkspace from step 2 and see that it is changed

I'm not able to start the devworkspace again:
image

To add remotes, a workaround can be to add remotes in the spec.template.projects section.

Example:

To add remote my-remote:

spec:
  template:
    ...
    projects:
      - git:
          checkoutFrom:
            remote: origin
            revision: devfilev2
          remotes:
            my-remote: 'https://github.com/user/golang-example.git'
            origin: 'https://github.com/che-samples/golang-example.git'
        name: golang-example

@amisevsk amisevsk added severity/P1 Has a major impact to usage or development of the system. and removed severity/P2 Has a minor but important impact to the usage or development of the system. labels Mar 25, 2022
@amisevsk
Copy link
Contributor Author

Moving to P1 as it seems this can occur whenever Theia updates the DevWorkspace, and if it occurs the workspace ends up in a confusingly broken state that is hard to repair manually.

@amisevsk
Copy link
Contributor Author

amisevsk commented Apr 6, 2022

I continue to encounter this issue randomly; fixing it is complicated as the flattened DevWorkspace is not intended for manual editing and in some cases results in my workspace failing to start consistently.

@azatsarynnyy
Copy link
Member

To make it clear:

@azatsarynnyy azatsarynnyy added this to the 7.48 milestone May 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/editor/theia Issues related to the che-theia IDE of Che engine/devworkspace Issues related to Che configured to use the devworkspace controller as workspace engine. kind/bug Outline of a bug - must adhere to the bug report template. severity/P1 Has a major impact to usage or development of the system.
Projects
None yet
7 participants