Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Use component for task configuration instead of container name #512

Merged
merged 1 commit into from
Oct 28, 2019

Conversation

RomanNikitenko
Copy link
Member

@RomanNikitenko RomanNikitenko commented Oct 24, 2019

What does this PR do?

Use component field for task configuration instead of containerName one.

containerName is used to indicate which container should be used for running task configuration.
The problem is: some container names are dynamic and are changed at restarting workspace.

The PR changes suggest to use component instead of containerName for this goal. So, the new behavior is:

  • devfile and tasks.json files keep component field
  • component is used to identify the target container at running a configuration
  • dropdown menu is displayed to provide ability to select target container if component contains few containers

Backward compatibility for containerName field of task configuration is provided for existing workspaces.

So, the following configuration:

          {
                "type": "che",
                "label": "theia:build",
                "command": "yarn",
                "target": {
                    "workingDir": "/projects/theia",
                    "containerName": "che-dev"
                }
          }

at starting workspace is replaced by:

          {
                "type": "che",
                "label": "theia:build",
                "command": "yarn",
                "target": {
                    "workingDir": "/projects/theia",
                    "component": "che-dev"
                }
          }

Note: containerName is replaced by empty component field if the corresponding component is not found (dynamic container name case). List of containers is displayed at running task for this case and user has opportunity to select a container for running.

What issues does this PR fix or reference?

eclipse-che/che#13993

How to test

  1. Use the following devfile, which contains the reference for docker image: maxura/che-theia:512 related to the current PR.
Devfile
apiVersion: 1.0.0
metadata:
 name: component-test
projects:
  - name: dummy-http-server
    source:
      type: git
      location: "https://github.com/sparkoo/dummy-http-server.git"
  - name: che-theia
    source:
      type: git
      location: 'https://github.com/eclipse/che-theia.git'
components:

  - 
    alias: che-dev
    type: dockerimage
    image: eclipse/che-theia-dev:next
    mountSources: true
    endpoints:
      - name: "theia-dev"
        port: 3130
        attributes:
          protocol: tcp
          public: 'true'
    memoryLimit: 2048M

  - 
    alias: theia-editor
    reference: >-
      https://raw.githubusercontent.com/RomanNikitenko/che-plugin-registry/master/v3/plugins/eclipse/che-theia/custom/meta.yaml
    type: cheEditor

  - 
    id: che-incubator/typescript/1.30.2
    alias: tsc
    type: chePlugin
    memoryLimit: 2048M
  
  -
    type: kubernetes
    alias: go-k8s
    mountSources: true
    referenceContent: |
          kind: List
          items:
          - kind: Pod
            apiVersion: v1
            metadata:
              name: go-runner
            spec:
              containers:
                - name: go-110-server
                  image: quay.io/eclipse/che-golang-1.10:nightly
                - name: go-112-server
                  image: quay.io/eclipse/che-golang-1.12:nightly

commands:

- name: test theia component
  actions:
  - type: exec
    component: theia-editor
    command: >
              yarn
    workdir: /projects/che-theia

- name: test tsc component
  actions:
  - type: exec
    component: tsc
    command: >
              sleep 2 && echo hello! 
    workdir: /projects/che-theia

- name: test che-dev component
  actions:
  - type: exec
    component: che-dev
    command: >
              yarn
    workdir: /projects/che-theia

- name: test k8s component
  actions:
      -
        type: exec
        component: go-k8s
        command: "go run main.go 8080 /hello"
        workdir: ${CHE_PROJECTS_ROOT}/dummy-http-server

- name: run
  actions:
  - type: vscode-task
    referenceContent: |
            {
                    "version": "2.0.0",
                    "tasks": 
                    [
                     {
                      "label": "shell:build",
                       "type": "shell",
                       "options": {"cwd": "/projects/che-theia"},
                       "command": "yarn",
                       "args": []
                     }
                    ]
            }

- name: debug
  actions:
  - type: vscode-launch
    referenceContent: |
            {
             "version": "0.2.0",
             "configurations": [
              {
               "type": "node",
               "request": "attach",
               "name": "Attach by Process ID",
               "processId": "${command:PickProcess}"
              }
             ]
            }

  1. Check that tasks.json file contains che task configurations with component field instead of containerName filed.

  2. Try to run tasks, try to stop workspace, start workspace and run tasks again: components theia-editor and tsc have dynamic names for containers, so pay attention on running test theia component and test tsc component tasks after restarting workspace.

  3. Component go-k8s has go-110-server and go-112-server containers, so at running of test k8s component task dropdown list should display only these containers instead of all containers.

  4. You can check backward compatibility for containerName field of task configuration:

  • for task test che-dev component replace component field by containerName in tasks.json file and refresh the page. Expected behavior - containerName is replaced by component field and task can be run.
  • for case when the corresponding component can not be found expected behavior: containerName is replaced by component field with empty value, at running the task dopdown list is displayed and user has opportunity to select a container for running.

Signed-off-by: Roman Nikitenko rnikiten@redhat.com

@che-bot
Copy link
Contributor

che-bot commented Oct 24, 2019

E2E Happy path tests of Eclipse Che Single User on K8S (minikube v1.1.1) has been successful:

  • build details
  • logs and configs
  • "che-theia" docker image: maxura/che-theia:512
  • "che-theia-endpoint-runtime" docker image: maxura/che-theia-endpoint-runtime:512
  • "che-remote-plugin-runner-java8" docker image: maxura/che-remote-plugin-runner-java8:512
  • "che-remote-plugin-kubernetes-tooling-1.0.0" docker image: maxura/che-remote-plugin-kubernetes-tooling-1.0.0:512
  • Happy path tests DevFile

Signed-off-by: Roman Nikitenko <rnikiten@redhat.com>
@che-bot
Copy link
Contributor

che-bot commented Oct 24, 2019

E2E Happy path tests of Eclipse Che Single User on K8S (minikube v1.1.1) has failed:

@RomanNikitenko
Copy link
Member Author

crw-ci-test

@che-bot
Copy link
Contributor

che-bot commented Oct 24, 2019

E2E Happy path tests of Eclipse Che Single User on K8S (minikube v1.1.1) has failed:

@che-bot
Copy link
Contributor

che-bot commented Oct 24, 2019

E2E Happy path tests of Eclipse Che Single User on K8S (minikube v1.1.1) has failed:

@dmytro-ndp
Copy link
Contributor

crw-ci-test

@che-bot
Copy link
Contributor

che-bot commented Oct 25, 2019

E2E Happy path tests of Eclipse Che Single User on K8S (minikube v1.1.1) has been successful:

  • build details
  • logs and configs
  • "che-theia" docker image: maxura/che-theia:512
  • "che-theia-endpoint-runtime" docker image: maxura/che-theia-endpoint-runtime:512
  • "che-remote-plugin-runner-java8" docker image: maxura/che-remote-plugin-runner-java8:512
  • "che-remote-plugin-kubernetes-tooling-1.0.0" docker image: maxura/che-remote-plugin-kubernetes-tooling-1.0.0:512
  • Happy path tests DevFile

Copy link
Member

@azatsarynnyy azatsarynnyy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested it on minikube according to the proposed scenario. Works as advertised ) 👍
Backward compatibility is handled very well.

@azatsarynnyy
Copy link
Member

Note for anyone who wants to test it: 8 Gb is insufficient for running minikube to test the PR with the proposed DevFile. I successfully run it with 16 Gb.

@RomanNikitenko RomanNikitenko merged commit 58c25b7 into master Oct 28, 2019
@RomanNikitenko RomanNikitenko deleted the fixContainerName branch October 28, 2019 11:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants