che
che copied to clipboard
Projects are not cloned after restarting the workspace using `Eclipse Che: Restart Workspace from Local Devfile` command
Describe the bug
I created a workpsace with following devfile
schemaVersion: 2.2.0
metadata:
name: java-spring-petclinic
# projects:
# - name: nodejs-devfile-test
# git:
# remotes:
# origin: https://github.com/vitaliy-guliy/nodejs-devfile-test.git
# - name: lombok-project-sample
# git:
# remotes:
# origin: https://github.com/vitaliy-guliy/lombok-project-sample.git
components:
- name: tools
container:
image: quay.io/devfile/universal-developer-image:ubi8-latest
memoryLimit: 1G
mountSources: true
Then I opened the devfile in the editor, uncommented the projects section and launched Eclipse Che: Restart Workspace from Local Devfile.
After restarting the workspace, it appeared that projects were not being cloned to the file system, despite they are properly described in flattened devworkspace yaml file.
Che version
7.78@latest
Steps to reproduce
- create a workspace with https://github.com/vitaliy-guliy/java-spring-petclinic/tree/test-che-22630
- open the devfile, add few projects, run
Eclipse Che: Restart Workspace from Local Devfilecommand
Expected behavior
Projects must be cloned to the file system
I just tested this on Che nightly: projects are indeed not being cloned after restart from local devfile; however, I don't see the additional projects in either the DevWorkspace CR, or the $DEVWORKSPACE_ORIGINAL_YAML nor $DEVWORKSPACE_FLATTENED_YAML.
It looks like the restart from local devfile action is ignoring projects in the local devfile.
Che Code explicitly overwrites the projects in the devfile after generating here:
const currentDevfile = await devfileService.get();
const projects = currentDevfile.projects || [];
const pluginRegistryUrl = process.env.CHE_PLUGIN_REGISTRY_INTERNAL_URL;
console.info(`Using ${pluginRegistryUrl} to generate a new Devfile Context`);
const newContent = await devWorkspaceGenerator.generateDevfileContext({ devfilePath, editorContent: EDITOR_CONTENT_STUB, pluginRegistryUrl, projects: [] }, axiosInstance);
if (newContent) {
newContent.devWorkspace.spec!.template!.projects = projects;
await devfileService.updateDevfile(newContent.devWorkspace.spec?.template);
} else {
throw new Error('An error occurred while generating new devfile context');
}
I would be careful about fixing this bug: is it a user / customer issue? or is just us trying to make perfect something is works fine for user? Because that's a complicated subject and to address it we need to consider a lot of cases:
- user add
projectssection: should we remove the existing project if it's not explicitly mentioned in newprojects? - user completely remove
projectssection: should we start an empty workspace or should we keep an "implicit" project? - user removed one project from
projectssection: should we remove it from thecode-workspace.jsonat restart if it's not in the devfileprojects? - user has manually cloned a git repository in
/projects/and it was added tocode-workspace.jsonbut not in devfile.yaml: what should we do at restart? - what about
starterProjects?
An simpler approach would be to ignore projects and starterProjects when starting from local devfile and support dependentProjects.