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 fails to properly create a workspace if controller.devfile.io/merge-contribution: true is set on a container component. #22155

Closed
cgruver opened this issue Apr 15, 2023 · 7 comments
Assignees
Labels
area/dashboard area/factory/dashboard Issues related to factories frontend (che user dashboard side) 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. team/A This team is responsible for the Che Operator and all its operands as well as chectl and Hosted Che

Comments

@cgruver
Copy link

cgruver commented Apr 15, 2023

Describe the bug

I am trying to explicitly tell Che which container component to use for injecting the IDE at workspace startup.

To accomplish this I am adding the following attribute to the desired container component in the devfile:

  attributes:
    controller.devfile.io/merge-contribution: true

If I modify an existing workspace and remove the attribute from the first container component and move it to the desired component, the workspace starts and runs as expected.

However, if I create a new workspace with a devfile containing that attribute, the workspace starts, but is created with an empty array of components, much like the error here: #22145

Che version

7.63@latest

Steps to reproduce

Create a workspace with the following devfile:

schemaVersion: 2.2.0
attributes:
  controller.devfile.io/storage-type: per-workspace
metadata:
  name: che-demo-app
projects:
- name: che-demo-app
  git:
    checkoutFrom:
      remote: origin
      revision: main
    remotes:
      origin: https://github.com/eclipse-che-demo-app/che-demo-app.git
- name: che-demo-app-ui
  git:
    checkoutFrom:
      remote: origin
      revision: main
    remotes:
      origin: https://github.com/eclipse-che-demo-app/che-demo-app-ui.git
- name: che-demo-app-service
  git:
    checkoutFrom:
      remote: origin
      revision: main
    remotes:
      origin: https://github.com/eclipse-che-demo-app/che-demo-app-service.git
components:
- name: quarkus-runner
  container: 
    image: quay.io/cgruver0/che/che-demo-app:latest
    memoryLimit: 1Gi
    mountSources: true
    sourceMapping: /projects
    volumeMounts:
      - name: m2
        path: /home/user/.m2
    endpoints:
      - name: https-quarkus
        targetPort: 8080
        exposure: public
        protocol: https
      - name: debug
        exposure: none
        targetPort: 5858
      - name: dt-socket
        exposure: none
        targetPort: 5005
    env:
      - name: DEBUG_PORT
        value: '5858'
      - name: JAVA_HOME 
        value: /etc/alternatives/jre_17
      - name: API_PORT
        value: '8080'
      - name: DB_USER
        value: postgres
      - name: DB_PWD
        value: postgres
      - name: DB_HOST
        value: localhost
      - name: DB_SCHEMA
        value: postgres
      - name: CORS_ORIGINS
        value: "/.*/"
      - name: CORS_METHODS
        value: "GET,POST,DELETE"
    args:
      - '-f'
      - /dev/null
    command:
      - tail
- name: node-runner
  container: 
    image: quay.io/cgruver0/che/che-demo-app:latest
    memoryLimit: 1Gi
    mountSources: true
    sourceMapping: /projects
    volumeMounts:
      - name: npm
        path: /home/user/.npm
    endpoints:
      - name: node
        targetPort: 4200
        exposure: public
        protocol: https
    args:
      - '-f'
      - /dev/null
    command:
      - tail
- name: postgres
  container:
    image: quay.io/sclorg/postgresql-15-c9s:c9s
    memoryLimit: 512M
    sourceMapping: /projects
    mountSources: true
    env:
    - name: POSTGRESQL_USER
      value: postgres
    - name: POSTGRESQL_PASSWORD
      value: postgres
    - name: POSTGRESQL_DATABASE
      value: postgres
    volumeMounts:
    - name: pgdata
      path: /var/lib/pgsql/data
    endpoints:
      - name: postgres
        targetPort: 5432
- name: oc-cli
  container:
    args:
      - '-f'
      - /dev/null
    command:
      - tail
    image: image-registry.openshift-image-registry.svc:5000/openshift/cli:latest
    sourceMapping: /projects
    mountSources: true
    memoryLimit: 64M
    env:
    - name: KUBECONFIG
      value: /projects/config
- name: dev-tools
  attributes:
    controller.devfile.io/merge-contribution: true
  container: 
    image: quay.io/cgruver0/che/che-demo-app:latest
    memoryRequest: 1Gi
    memoryLimit: 6Gi
    cpuRequest: 500m
    cpuLimit: 2000m
    mountSources: true
    sourceMapping: /projects
    args:
      - '-f'
      - /dev/null
    command:
      - tail
    env:
    - name: SHELL
      value: "/bin/zsh"
    - name: TESTCONTAINERS_RYUK_DISABLED
      value: "true"
    - name: TESTCONTAINERS_CHECKS_DISABLE
      value: "true"
    - name: DOCKER_HOST
      value: "tcp://127.0.0.1:2475"
    volumeMounts:
    - name: m2
      path: /home/user/.m2
    - name: npm
      path: /home/user/.npm
    endpoints:
      - name: kubedock
        targetPort: 2475
        exposure: none
- volume:
    size: 4Gi
  name: projects
- volume:
    size: 2Gi
  name: m2
- volume:
    size: 2Gi
  name: npm
- volume:
    size: 2Gi
  name: pgdata
commands:
- exec:
    commandLine: mvn package
    component: dev-tools
    group:
      isDefault: true
      kind: build
    workingDir: '/projects/che-demo-app-service'
  id: package
- exec:
    commandLine: mvn package -Dnative -Dmaven.test.skip -Dquarkus.native.native-image-xmx=2G
    component: dev-tools
    group:
      kind: build
    label: Package Native
    workingDir: '/projects/che-demo-app-service'
  id: package-native
- exec:
    commandLine: 'quarkus dev -Dmaven.repo.local=/home/user/.m2/repository -Dquarkus.http.host=0.0.0.0'
    component: quarkus-runner
    hotReloadCapable: true
    group:
      isDefault: true
      kind: run
    label: Start Quarkus Development mode (Hot reload)
    workingDir: '/projects/che-demo-app-service'
  id: quarkus-dev-mode
- exec:
    commandLine: 'ng serve --disable-host-check --host 0.0.0.0'
    component: node-runner
    hotReloadCapable: true
    group:
      isDefault: true
      kind: run
    label: Start NodeJS Development mode (Hot reload)
    workingDir: '/projects/che-demo-app-ui'
  id: node-dev-mode
- exec:
    commandLine: "POD=$(oc get pod --selector controller.devfile.io/devworkspace_name=che-demo-app -o name) ; oc rsh -c node-runner ${POD}"
    component: oc-cli
    group:
      kind: run
    label: Terminal - App UI
    workingDir: '/'
  id: demo-app-ui-shell
- exec:
    commandLine: "POD=$(oc get pod --selector controller.devfile.io/devworkspace_name=che-demo-app -o name) ; oc rsh -c quarkus-runner ${POD}"
    component: oc-cli
    group:
      kind: run
    label: Terminal - App Service
    workingDir: '/'
  id: ubi-shell
- exec:
    commandLine: "POD=$(oc get pod --selector controller.devfile.io/devworkspace_name=che-demo-app -o name) ; oc rsh -c postgres ${POD}"
    component: oc-cli
    group:
      kind: run
    label: Terminal - PostgreSQL
    workingDir: '/'
  id: postgres-shell
- exec:
    commandLine: "POD=$(oc get pod --selector controller.devfile.io/devworkspace_name=che-demo-app -o name) ; oc rsh -c oc-cli ${POD}"
    component: oc-cli
    group:
      kind: run
    label: Terminal - OC CLI
    workingDir: '/'
  id: oc-cli-shell
- exec:
    commandLine: "kubedock server --port-forward"
    component: dev-tools
    group:
      kind: run
    label: Kubedock
    workingDir: '/'
  id: kubedock
- exec:
    commandLine: "cp /home/user/.kube/config /projects/config"
    component: dev-tools
    group:
      kind: run
    label: Copy Kubeconfig
    workingDir: '/'
  id: copy-kubeconfig
- exec:
    commandLine: "/projects/che-demo-app/setUiEnv.sh -f=/projects/che-demo-app-ui/src/environments/environment.development.ts -s=/projects/che-demo-app-ui/env.dev -c=quarkus-runner -w=che-demo-app -p=8080 -e=https-quarkus -v=backendApiUrl"
    component: oc-cli
    group:
      kind: run
    label: Set Angular Environment
    workingDir: '/'
  id: set-ui-env

Expected behavior

A running workspace with the IDE injected into the attributed component.

Runtime

OpenShift

Screenshots

No response

Installation method

OperatorHub

Environment

macOS

Eclipse Che Logs

No response

Additional context

No response

@cgruver cgruver added the kind/bug Outline of a bug - must adhere to the bug report template. label Apr 15, 2023
@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 Apr 15, 2023
@ibuziuk ibuziuk added engine/devworkspace Issues related to Che configured to use the devworkspace controller as workspace engine. severity/P1 Has a major impact to 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 Apr 18, 2023
@ibuziuk
Copy link
Member

ibuziuk commented Apr 18, 2023

@amisevsk could you please take a look?

@amisevsk amisevsk added area/dashboard area/factory/dashboard Issues related to factories frontend (che user dashboard side) and removed engine/devworkspace Issues related to Che configured to use the devworkspace controller as workspace engine. labels Apr 18, 2023
@amisevsk
Copy link
Contributor

This looks to be an issue in the dashboard that is hidden by #22145

During start, the dashboard is creating a DevWorkspace with no components, and then patching it to use the devfile content. This patch request gets a 403 Forbidden response, which is ignored by the dashboard.

The response includes the message:

Unable to patch devworkspace: admission webhook "mutate.devworkspace-controller.svc"
denied the request: only a single component may have the controller.devfile.io/merge-contribution
attribute set to true. The following 2 components have the controller.devfile.io/merge-contribution
attribute set to true: quarkus-runner, dev-tools

This is because the dashboard is injecting the merge-contribution attribute onto the first component in the devfile (this was required prior to devfile/devworkspace-operator#993) even if another component already has the attribute.

As a workaround for now, this issue can be avoided by placing the component we want merge-contribution: true to be attached to first in the list of components, though this is not ideal.

@l0rd
Copy link
Contributor

l0rd commented May 23, 2023

I just reproduced this issue and I suspect it's related to the fact that the devworkspace-generator always add the attribute in the generated DevWorkspace but it should never do it (c.f. this issue). cc @svor

@svor
Copy link
Contributor

svor commented May 24, 2023

As Mario added, It's devWorkspace generator tool that injects attribute into the first component and this tool is used by the dashboard.

If the attribute should be add by devworkspace-operator, we can remove this logic from the generator tool.

@svor svor added the team/A This team is responsible for the Che Operator and all its operands as well as chectl and Hosted Che label May 24, 2023
@svor svor self-assigned this May 24, 2023
@l0rd
Copy link
Contributor

l0rd commented May 24, 2023

@svor the attribute should not be set anymore (it was required a few releases ago, prior to prior to devfile/devworkspace-operator#993 as mentioned by @amisevsk).

@amisevsk
Copy link
Contributor

The logic currently used by DWO is

  • If any component has the attribute, merge contributions into that component (multiple components with the attribute is an error)
  • If no component has the attribute, merge contributions into the first component (not considering contributions)

@svor
Copy link
Contributor

svor commented Jul 5, 2023

All related PRs to devworkspace generator were merged, now the generator tool doesn't inject merge-contribution: true attribute

@svor svor closed this as completed Jul 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/dashboard area/factory/dashboard Issues related to factories frontend (che user dashboard side) 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. team/A This team is responsible for the Che Operator and all its operands as well as chectl and Hosted Che
Projects
None yet
Development

No branches or pull requests

6 participants