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

Make Theia respect Devfile of a field of Workspace #13112

Closed
sleshchenko opened this issue Apr 10, 2019 · 1 comment
Closed

Make Theia respect Devfile of a field of Workspace #13112

sleshchenko opened this issue Apr 10, 2019 · 1 comment
Assignees
Labels
kind/enhancement A feature request - must adhere to the feature request template.

Comments

@sleshchenko
Copy link
Member

sleshchenko commented Apr 10, 2019

Description

We're working on improving Che Server and add an ability to use Devfile as a new way to configure workspace. It will be implemented in the following way: user is able to create a workspace from WorkspaceConfig or Devfile but both at the same can not be defined.
Then user is able to start such workspace with Devfile (WorkspaceConfig is missing) and classical runtime will appear in workspace.
We did not make and merge final needed changes for Che Server but we already have some dirty(in meaning of code) POC.

This issue is to make Theia respect Projects defined in Devfile as a field of Workspace. Below is present a workspace config and detailed instruction on how to get POC working.
Note that workspace with WorkspaceConfig should be supported as well to provide backward compatibility.

Workspace JSON with WorkspaceConfig
{
    "links": {
        "self": "http://che-eclipse-che.192.168.99.100.nip.io/api/workspace/workspace9zpi19rlgx75zp7p",
        "ide": "http://che-eclipse-che.192.168.99.100.nip.io/che/che7",
        "environment/statusChannel": "ws://che-eclipse-che.192.168.99.100.nip.io/api/websocket",
        "environment/outputChannel": "ws://che-eclipse-che.192.168.99.100.nip.io/api/websocket"
    },
    "attributes": {
        "org.eclipse.che.runtimes_id": "runtimesjg8c2jxm6jauipt0",
        "updated": "1554911265498",
        "created": "1554910917322",
        "stackId": "che7-preview"
    },
    "namespace": "che",
    "temporary": false,
    "id": "workspace9zpi19rlgx75zp7p",
    "status": "RUNNING",
    "config": {
        "defaultEnv": "default",
        "environments": {
            "default": {
                "machines": {
                    "ws/dev": {
                        "attributes": {
                            "memoryLimitBytes": "536870912"
                        },
                        "servers": {},
                        "volumes": {
                            "projects": {
                                "path": "/projects"
                            }
                        },
                        "installers": [],
                        "env": {}
                    }
                },
                "recipe": {
                    "type": "kubernetes",
                    "content": "kind: List\nitems:\n - \n  apiVersion: v1\n  kind: Pod\n  metadata:\n   name: ws\n  spec:\n   containers:\n    - \n     image: 'eclipse/che-dev:nightly'\n     name: dev\n     resources:\n      limits:\n       memory: 512Mi\n",
                    "contentType": "application/x-yaml"
                }
            }
        },
        "projects": [
            {
                "links": [],
                "name": "nodejs-hello-world",
                "attributes": {
                    "language": [
                        "javascript"
                    ]
                },
                "type": "node-js",
                "source": {
                    "location": "https://github.com/che-samples/web-nodejs-sample.git",
                    "type": "git",
                    "parameters": {}
                },
                "path": "/nodejs-hello-world",
                "description": "Simple NodeJS Project.",
                "problems": [],
                "mixins": []
            }
        ],
        "name": "che7",
        "attributes": {
            "editor": "org.eclipse.che.editor.theia:1.0.0",
            "plugins": "che-machine-exec-plugin:0.0.1"
        },
        "commands": [
            {
                "commandLine": "cd ${current.project.path} \n node .",
                "name": "nodejs-hello-world:run",
                "attributes": {
                    "goal": "Run",
                    "previewUrl": "${server.3000/tcp}"
                },
                "type": "custom"
            }
        ],
        "links": []
    },
    "runtime": {
        "machines": {
            "ws/theia-ide": {
                "attributes": {
                    "memoryLimitBytes": "1536000000",
                    "memoryRequestBytes": "1536000000",
                    "source": "tool",
                    "plugin": "org.eclipse.che.editor.theia"
                },
                "servers": {
                    "theia-dev": {
                        "url": "http://routemozmkpft-eclipse-che.192.168.99.100.nip.io",
                        "attributes": {
                            "internal": "false",
                            "type": "ide-dev",
                            "port": "3130",
                            "discoverable": "false"
                        },
                        "status": "UNKNOWN"
                    },
                    "theia": {
                        "url": "http://routepo7p6saj-eclipse-che.192.168.99.100.nip.io",
                        "attributes": {
                            "internal": "false",
                            "port": "3100",
                            "discoverable": "false",
                            "cookiesAuthEnabled": "true",
                            "type": "ide",
                            "secure": "true"
                        },
                        "status": "RUNNING"
                    }
                },
                "status": "RUNNING"
            },
            "ws/che-machine-exec": {
                "attributes": {
                    "memoryLimitBytes": "134217728",
                    "memoryRequestBytes": "134217728",
                    "source": "tool",
                    "plugin": "che-machine-exec-plugin"
                },
                "servers": {
                    "che-machine-exec": {
                        "url": "ws://route6npjo2z8-eclipse-che.192.168.99.100.nip.io",
                        "attributes": {
                            "internal": "false",
                            "type": "terminal",
                            "port": "4444",
                            "discoverable": "false"
                        },
                        "status": "UNKNOWN"
                    }
                },
                "status": "RUNNING"
            },
            "ws/dev": {
                "attributes": {
                    "memoryLimitBytes": "536870912",
                    "memoryRequestBytes": "536870912",
                    "source": "recipe"
                },
                "servers": {},
                "status": "RUNNING"
            }
        },
        "warnings": [],
        "activeEnv": "default",
        "commands": [
            {
                "commandLine": "cd ${current.project.path} \n node .",
                "name": "nodejs-hello-world:run",
                "attributes": {
                    "goal": "Run",
                    "previewUrl": "${server.3000/tcp}"
                },
                "type": "custom"
            }
        ],
        "machineToken": "",
        "links": []
    }
}
Workspace JSON with Devfile
{
    "links": {
        "self": "http://che-eclipse-che.192.168.99.100.nip.io/api/workspace/workspaceoz991q670gk2753y",
        "ide": "http://che-eclipse-che.192.168.99.100.nip.io/che/multiple-dockerimages",
        "environment/statusChannel": "ws://che-eclipse-che.192.168.99.100.nip.io/api/websocket",
        "environment/outputChannel": "ws://che-eclipse-che.192.168.99.100.nip.io/api/websocket"
    },
    "attributes": {
        "org.eclipse.che.runtimes_id": "runtimesjg8c2jxm6jauipt0",
        "updated": "1554908576698",
        "created": "1554906190701"
    },
    "namespace": "che",
    "temporary": false,
    "id": "workspaceoz991q670gk2753y",
    "status": "RUNNING",
    "devfile": {
        "specVersion": "0.0.1",
        "projects": [
            {
                "name": "nodejs-mongo-app",
                "source": {
                    "location": "https://github.com/ijason/NodeJS-Sample-App.git",
                    "type": "git"
                }
            }
        ],
        "name": "multiple-dockerimages",
        "attributes": {},
        "components": [
            {
                "mountSources": false,
                "endpoints": [],
                "name": "theia-editor",
                "command": [],
                "id": "org.eclipse.che.editor.theia:1.0.0",
                "args": [],
                "selector": {},
                "type": "cheEditor",
                "entrypoints": [],
                "volumes": [],
                "env": []
            },
            {
                "mountSources": false,
                "endpoints": [],
                "name": "exec-plugin",
                "command": [],
                "id": "che-machine-exec-plugin:0.0.1",
                "args": [],
                "selector": {},
                "type": "chePlugin",
                "entrypoints": [],
                "volumes": [],
                "env": []
            },
            {
                "mountSources": false,
                "endpoints": [],
                "name": "mongodb",
                "command": [],
                "args": [],
                "selector": {},
                "type": "dockerimage",
                "entrypoints": [],
                "volumes": [],
                "env": []
            },
            {
                "mountSources": false,
                "endpoints": [],
                "name": "nodejs-app",
                "command": [],
                "args": [],
                "selector": {},
                "type": "openshift",
                "entrypoints": [],
                "volumes": [],
                "env": []
            }
        ],
        "commands": [
            {
                "name": "run",
                "attributes": {},
                "actions": [
                    {
                        "type": "exec",
                        "command": "cd ${CHE_PROJECTS_ROOT}/nodejs-mongo-app/EmployeeDB/ && npm install && node app.jsspecVersion: 0.0.1",
                        "component": "nodejs-app"
                    }
                ]
            }
        ]
    },
   "runtime": {
        "machines": {
            "web-controller/web": {
                "attributes": {
                    "memoryLimitBytes": "1073741824",
                    "memoryRequestBytes": "536870912",
                    "source": "recipe"
                },
                "servers": {},
                "status": "RUNNING"
            },
            "workspace/theia-ide": {
                "attributes": {
                    "memoryLimitBytes": "1536000000",
                    "memoryRequestBytes": "1536000000",
                    "source": "tool",
                    "plugin": "org.eclipse.che.editor.theia"
                },
                "servers": {
                    "theia-dev": {
                        "url": "http://routeihfqgdur-eclipse-che.192.168.99.100.nip.io",
                        "attributes": {
                            "internal": "false",
                            "type": "ide-dev",
                            "port": "3130",
                            "discoverable": "false"
                        },
                        "status": "UNKNOWN"
                    },
                    "theia": {
                        "url": "http://route1hkgccgx-eclipse-che.192.168.99.100.nip.io",
                        "attributes": {
                            "internal": "false",
                            "port": "3100",
                            "discoverable": "false",
                            "cookiesAuthEnabled": "true",
                            "type": "ide",
                            "secure": "true"
                        },
                        "status": "RUNNING"
                    }
                },
                "status": "RUNNING"
            },
            "workspace/che-machine-exec": {
                "attributes": {
                    "memoryLimitBytes": "134217728",
                    "memoryRequestBytes": "134217728",
                    "source": "tool",
                    "plugin": "che-machine-exec-plugin"
                },
                "servers": {
                    "che-machine-exec": {
                        "url": "ws://routepsx2bn62-eclipse-che.192.168.99.100.nip.io",
                        "attributes": {
                            "internal": "false",
                            "type": "terminal",
                            "port": "4444",
                            "discoverable": "false"
                        },
                        "status": "UNKNOWN"
                    }
                },
                "status": "RUNNING"
            },
            "mongodb": {
                "attributes": {
                    "memoryLimitBytes": "262144000",
                    "memoryRequestBytes": "262144000",
                    "source": "recipe"
                },
                "servers": {},
                "status": "RUNNING"
            }
        },
        "warnings": [],
        "activeEnv": "default",
        "commands": [
            {
                "commandLine": "cd ${CHE_PROJECTS_ROOT}/nodejs-mongo-app/EmployeeDB/ && npm install && node app.jsspecVersion: 0.0.1",
                "name": "run",
                "attributes": {
                    "machineName": "web-controller/web",
                    "componentName": "nodejs-app"
                },
                "type": "exec"
            }
        ],
        "machineToken": "",
        "links": []
    }
}

In scope of this issue the actual difference that makes sense is that in one case projects configuration are located at .config.projects and in another with Devfile .devfile.projects. Note that the project configuration format is a bit different: for WorkspaceConfig -> ProjectConfig , and for Devfile -> Project.

Reproduction Steps

  1. Start a Che Server using the image with POC where devfile is a part of workspace -> sleshchenko/che-server:devfile.
  2. Use the new BETA method to create a workspace from Devfile {CHE_HOST}/swagger/#!/workspace/createFromDevfile
Workspace Recipe to start
{
	"specVersion": "0.0.1",
	"name": "multiple-dockerimages",
	"projects": [
		{
			"name": "nodejs-mongo-app",
			"source": {
				"type": "git",
				"location": "https://github.com/ijason/NodeJS-Sample-App.git"
			}
		}
	],
	"components": [
		{
			"name": "theia-editor",
			"type": "cheEditor",
			"id": "org.eclipse.che.editor.theia:1.0.0"
		},
		{
			"name": "exec-plugin",
			"type": "chePlugin",
			"id": "che-machine-exec-plugin:0.0.1"
		},
		{
			"name": "mongodb",
			"type": "dockerimage",
			"image": "mongo",
			"endpoints": [
				{
					"name": "mongo",
					"port": 27017,
					"attributes": {
						"public": "false",
						"discoverable": "true"
					}
				}
			],
			"mountSources": false,
			"volumes": [
				{
					"name": "mongo-storage",
					"containerPath": "/data/db"
				}
			],
			"memoryLimit": "250Mi"
		},
		{
			"name": "nodejs-app",
			"type": "openshift",
			"reference": "node-js.yaml",
			"referenceContent": "apiVersion: v1\nkind: List\nitems:\n-\n  apiVersion: apps/v1\n  kind: Deployment\n  metadata:\n    name: web\n    labels:\n      app: nodejs\n  spec:\n    replicas: 2\n    selector:\n      name: web\n    template:\n      metadata:\n        labels:\n          app: nodejs\n        name: web-controller\n      spec:\n        containers:\n        - image: node:0.10.40\n          command: ['tail', '-f', '/dev/null']\n          args: []\n          name: web\n          ports:\n          - containerPort: 3000\n            name: http-server\n          volumeMounts:\n           - mountPath: /projects\n             name: projects\n        volumes:\n         - name: projects\n           persistentVolumeClaim:\n             claimName: projects\n- apiVersion: v1\n  kind: PersistentVolumeClaim\n  metadata:\n    name: projects\n  spec:\n    accessModes:\n     - ReadWriteOnce\n    resources:\n      requests:\n        storage: 2Gi\n-\n  apiVersion: v1\n  kind: Service\n  metadata:\n    name: web\n    labels:\n      name: web\n  spec:\n    type: LoadBalancer\n    ports:\n      - name: web\n        port: 80\n        targetPort: 3000\n        protocol: TCP\n    selector:\n      app: nodejs\n- apiVersion: v1\n  kind: Route\n  metadata:\n    name: che\n  spec:\n    to:\n      kind: Service\n      name: web\n    port:\n      targetPort: web\n"
		}
	],
	"commands": [
		{
			"name": "run",
			"actions": [
				{
					"type": "exec",
					"component": "nodejs-app",
					"command": "cd ${CHE_PROJECTS_ROOT}/nodejs-mongo-app/EmployeeDB/ && npm install && node app.jsspecVersion: 0.0.1"
				}
			]
		}
	]
}
3. Start a workspace.

Expected: Projects defined in Devfile are imported
Actual: Theia does not clone projects sources since workspace config is missing.

@sleshchenko sleshchenko added the kind/enhancement A feature request - must adhere to the feature request template. label Apr 10, 2019
@sleshchenko sleshchenko changed the title Make Theia respecting Devfile of a field of Workspace Make Theia respect Devfile of a field of Workspace Apr 11, 2019
@mmorhun mmorhun self-assigned this Apr 23, 2019
@l0rd l0rd mentioned this issue May 7, 2019
@mmorhun
Copy link
Contributor

mmorhun commented May 17, 2019

Done for projects synchronization and workspace panel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement A feature request - must adhere to the feature request template.
Projects
None yet
Development

No branches or pull requests

2 participants