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
Fix the restart of che-code based workspaces #21085
Comments
@nils-mosbach could you get as well DeWorkspaceRouting objects ? |
based on the provided devfile yaml I don't see how we can have multiple endpoints with the same name ? |
It depends on what the DevWorkspaceTemplate My hunch is that somewhere along the line, endpoints are being added a second time -- either the DWT contains them as well as the main container, or they're injected into the main container somewhere and then reinjected, causing duplicates. @nils-mosbach could you share the DevWorkspaceTemplate (i.e. |
To shortcut the discussion a little, looking at what I think is the definition of the devworkspacetemplate mentioned above here, I see that the plugin also includes the endpoints The next question would be how the |
If a workspace is started with che-code as the editor, che-code will get injected to the developer image (sidecarless-mode, #20435). I guess the operator copies endpoints, etc. defined by the che-code plugin to the developer image that has I've created a simple devfile and extracted Workspace was started with: I've dropped all information in a repo for better readability: |
@nils-mosbach thanks for the repo, that's very helpful in testing. Looking at the DevWorkspaceTemplate and DevWorkspace as applied to the cluster (from the given devfile), it looks like whatever is injecting those endpoints into the dev container is doing it every time, without checking whether they're already added. However, I don't know which component is responsible for doing this -- the DevWorkspace Operator plays no role here. |
I wasn't able to find the area where che-code gets injected to the users main devcontainer. The only difference in the editor config seems to be Since that error pops up in the devfile status I guess devworkspace-operator might at least throw the error. If I look at the devfile that's generated there's an additional plugin - name: che-code-workspace40d5c314bea044ab
plugin:
kubernetes:
name: che-code-workspace40d5c314bea044ab
namespace: dev-studio-workspace-nm-company-com-zsobsb I guess that's linking to the devworkspacetemplate che-code-workspace40d5c314bea044ab. If so, that template also contains the che-code-runtime-description which already got injected. From a devworkspace-operators view that error makes sense, since two independet plugins share the same endpoint definition. |
I'm not reproducing the issue (I'm stopping/restarting che-code workspace) all the time and I'm using che/next as well. Is it a fresh 'chectl/next' install or did you reinstall/restart che containers recently ? (else you might have old containers) Magic happens there:https://github.com/che-incubator/che-code/tree/main/tools/devworkspace-handler but magic is happening before a workspace is started. So starting a workspace or restarting it should involve the same devWorkspaceTemplate/devWorkspace objects |
@benoitf All right, thanks. I'll check the status of all tagged |
@benoitf all right. cleaned and redeployed everything with latest current chectl:next. Pull policy is Always for all images, so images should be on all next tags of today. Issue still exists. First of all, I set che-code as the default editor for all workspaces ( While all our devfiles won't work, or at least don't restart, So I looked at the devfile registry and there seems to happen a little bit of magic. It seems that
Che Dashboard seems to recognize this and adds a url parameter to the factory:
Removing this parameter leads to the issue of workspaces that can't be restarted since DevworkspaceTemplate contains che-codes' runtime description is this case.
Bottom lined: I guess DevworkspaceTemplates should not contain |
Looking at che-code / che-code-devfile-resolver-impl.ts this doesn't work in my case. At least the modified DevworkspaceTemplate is not used. This is triggered here dashboard / DevWorkspaceEditorProcessCode.ts, right? In our che-dashboard logs there's an error message |
@benoitf While digging a little deeper it seems that che-code devworkspace-handler works as expected and removes the after the command is executed, devworkspace template is the same on kubernetes with only 2 components. So this looks good. Workspace can be stopped and restarted without any issues. The issue must happen on dashboard start. If I reload the dashboard page it patches the devworkspacetemplate with the original che-code template provided by the plugin-registry. Since this is only called once, I guess there's something like an update routine, that allows keeping existing templates in line with updates in the plugin registry. I'll try to find out where this happens. It took me a while to get che-dashboard dev environment running on kubernetes. If you'd like I submit a PR that adds a command |
thanks for the heads up On the first startup of the workspace, is that DevWorkspaceTemplate contains the che-code-runtime-description or not ? maybe devWorkspaceHandler cleanup some entries but it's not the one that is sent to the DevWorkspace Operator so on the first startup, DevWorkspaceTemplate should be without "che-code-runtime-description" (the handler should have remove the entry and adds all options into the existing devContainer (first component found in the devfile)) And then, do we go into DevWorkspaceHandler on the restart ? I'll investigate next week |
The first startup is fine. As long as che-dashboard is not restarted, everything keeps working. The issue is caused in the editor update routine of the dashboard: private async updateDevWorkspaceTemplates(settings: che.WorkspaceSettings): Promise<void> {
if (!isDevworkspacesEnabled(settings)) {
return;
}
const defaultKubernetesNamespace = selectDefaultNamespace(this.store.getState());
const defaultNamespace = defaultKubernetesNamespace.name;
try {
const pluginsByUrl: { [url: string]: devfileApi.Devfile } = {};
const state = this.store.getState();
selectDwEditorsPluginsList(state.dwPlugins.defaultEditorName)(state).forEach(dwEditor => {
pluginsByUrl[dwEditor.url] = dwEditor.devfile;
});
const updates = await this.devWorkspaceClient.checkForTemplatesUpdate(
defaultNamespace,
pluginsByUrl,
);
if (Object.keys(updates).length > 0) {
await this.devWorkspaceClient.updateTemplates(defaultNamespace, updates);
}
} catch (e) {
console.error('Failed to update templates.', e);
}
} This will override all template files by their default settings as defined by the plugin registry. As far as I can see, DevworkspaceOperator is not involved. Easiest fix would be to skip conversions in case of sidecarless-editors. But that would eventually break exisiting workspaces if editor runs on next or latest tags. Based on the original devfile we could use the same routine that generate Devworkspace and DevworkspaceTemplates in case of new Workspaces, but it seems that the original Devfile isn't persisted after the creation. |
ok I think this logic was added to handle "automatic updates" of the DevWorkspace templates when upgrading to a newer che version. |
@benoitf I'm happy to submit a PR that skips updates in case of vscode and intellij idea (sidecarless). What do you think? I would add a check, somewhere in here, where templates that have changed are identified: https://github.com/eclipse-che/che-dashboard/blob/f9c2a7c087871c6095b033729c51729f779f252c/packages/dashboard-frontend/src/services/workspace-client/devworkspace/devWorkspaceClient.ts#L906 |
@nils-mosbach yes it may work to skip other editors for now |
Solved by PR. Closing. |
sync'd to Red Hat JIRA https://issues.redhat.com/browse/CRW-2771 |
Describe the bug
Starting a devworkspace with che-code enabled fails to restart or start (if stopped).
Code was enabled with url parameter. e.g.
https://company.dev/dashboard/#/load-factory?url=https%3A%2F%2Fgit.company.dev%2FMosbachN%2Fdevfile-test-vscode.git&che-editor=che-incubator/che-code/insiders&policies.create=perclick
Che version
next (development version)
Steps to reproduce
Expected behavior
Should not throw an error.
Runtime
Kubernetes (vanilla)
Screenshots
No response
Installation method
chectl/next
Environment
Linux
Eclipse Che Logs
Additional context
Restarting theia workspaces don't throw errors.
Release Notes Text
Workspaces that use che-code as an editor failed to restart or start (if stopped). This has been fixed in this release.
The text was updated successfully, but these errors were encountered: