If a Che 7 workspace is running and I try to start a new one I get the following error:
Message: services "theia" already exists

One possible solution to address this problem would be to suffix the name of services with the workspace id:
It is caused by the issue: service discovery of APIs running in tooling containers of Workspace.Next https://github.com/eclipse/che/issues/9913
@sleshchenko I have added some notes about a possible solution. That's something we discussed with @benoitf last week. cc @evidolob
Linking original PR made by @garagatyi https://github.com/eclipse/che/pull/10528
@l0rd is this issue a priority for the next sprint ?
@ibuziuk no
@l0rd
suffixing services with workspaceid would not be a problem for theia remote plugins as of today because they don't use the hostname but localhost (since everything run in the same pod)
I wonder why you think that they use localhost?
prefixing the name of the services with the workspace id when starting a che 7 workspace: that make it easy to start workspaces
Do you mean prefixing only services created by plugins or also those that are in the user recipe of a workspace?
extending the API of the che plugin that @evidolob and IDE 2 are working on to retrieve the real endpoint of a service: that make it easy for plugins developers to consume other plugins APIs
For the start we might be OK with just having an env var with workspace ID and knowing that we need to prefix service name with it prefix.
I wonder why you think that they use localhost?
Because if you started an HTTP service on port 80 of container A, you can reach it as http://localhost:80 from container B (assumed that A and B are in the same pod). That's how Theia plugin adapter talk with the original Theia container right now (@benoitf can correct me if I am wrong)
Do you mean prefixing only services created by plugins or also those that are in the user recipe of a workspace?
That's a good question. But no we should not prefix services defined in the user runtime. It will be the user responsibility not make them collide with other services and that it's perfectly fine because he should complete control of the services running in the namespace.
For the start we might be OK with just having an env var with workspace ID and knowing that we need to prefix service name with it prefix.
That's a hack that plugin developer should apply in their plugins and we don't want because their plugins may be broken as soon as we fix it in the right way. We want to go with the clean solution right away.
@l0rd actually our plugins don't use localhost. They use k8s Service. And this is a PITA. I have a POC for this but it leads to:
port4321 and insert environment variable to theia container with a value "ws://workspace123456789port4321:4321"This solution makes us split the knowledge about prefixing k8s services with workspace ID among different components with different lifecycles. You mentioned that we want to go with a clean solution and I believe that this solution is not clean solution at all.
extending the API of the che plugin that @evidolob and IDE 2 are working on to retrieve the real endpoint of a service: that make it easy for plugins developers to consume other plugins APIs
We do not show internal plugin endpoints in Che workspace API at the moment.
Hello world plugin doesn't work as it was expected.
Here is another way to implement this:
Brokers would add workspace ID to endpoint names, while Che master would behave as it is now. This would isolate changes in brokers only.
Theia and VS Code brokers actually don't care what is the name of the endpoint since they just put it into the env var needed by Theia.
Common che plugin would have to use API to get server it needs. As far as I understand exec which is the only plugin of that type already does it.
So such changes would not break existing plugins because of above-described reasons.
I'm going to provide PR with this solution. If somebody has any thought why should we go to another direction, please, comment.
@l0rd @sleshchenko FYI
Just discussed this idea with @sleshchenko and he pointed out that Theia editor server name would be changed. Which is not OK. So, can't proceed with this solution
One problem with the solution suggested in the issue description is that since service discovery would be dependent on the workspace ID we can't just cache brokering results without modifying on each request with a certain workspace ID.
A quick win could be:
And here is a wider explanation of options we have and what are the pros and cons:
What we do now:
What options we have to allow running several workspaces in a single k8s namespace:
Pros:
Pros:
Pros:
I would go with option 3 and here is how to do it in an iterable way:
DONE!
After a discussion with @l0rd and @ibuziuk, we agreed to disable creation of services for Theia and exec sidecars since it is not used at the moment and make Theia, VS Code brokers generate random names for services to avoid collisions.
I recalled that we had Fortune and Hello world plugins that are using sidecars and rely on predictable sidecar URLs. They need to be adapted to fetch endpoint URL from Che master API.
When one of these plugins are used by the same user in more than one workspace in the same kubernetes namespace workspaces started after the first one would fail to start.
It seems that plugins like these can make UX worse, but since we do not expect heavy usage of plugins other than Theia and VS Code type this should not be a problem for the time being.
Most helpful comment
A quick win could be:
And here is a wider explanation of options we have and what are the pros and cons:
What we do now:
What options we have to allow running several workspaces in a single k8s namespace:
Pros:
Cons:
Pros:
Cons:
Pros:
Cons:
I would go with option 3 and here is how to do it in an iterable way:
DONE!