Devfile endpoints does not work when exposed on single-host #20593
Labels
area/che-server
kind/bug
Outline of a bug - must adhere to the bug report template.
severity/P1
Has a major impact to usage or development of the system.
Describe the bug
che-workspace endpoints does not work with CheCluster patch ^. Sometimes user can't get into the workspace.
Analysis
In single-host, by default we expose devfile endpoints on subdomain by adding requireSubdomain attribute to the endpoint: https://github.com/eclipse-che/che-server/blob/main/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/devfile/DockerimageComponentToWorkspaceApplier.java#L145 -> https://github.com/eclipse-che/che-server/blob/47ebe7c372ea0d405a4bdb707a7166808c8d6240/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/ServerConfigImpl.java#L199
This behavior can be changed with
CHE_INFRA_KUBERNETES_SINGLEHOST_WORKSPACE_DEVFILE__ENDPOINT__EXPOSURE
, but the issue is we don't check it here. So we set this to every devfile endpoint everytime. This will cause issue later, when we're constructing the endpoint URL https://github.com/eclipse-che/che-server/blob/main/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/server/resolver/ConfigMapServerResolver.java#L76. See that we don't append the endpoint origin to the url if endpoint has requiresSubdomain parameter. That's the reason, why opening endpoint from theia does open just che-host, without any subpath to the endpoint.For the cases when workspace is not accessible, the issue pops up in this filter in workspace loader https://github.com/eclipse-che/che-server/blob/main/assembly/assembly-root-war/src/main/webapp/_app/loader.js#L140. We're finding here the url to use for authentication (which suppose to be jwt-proxy endpoint), but we're doing it only by checking the prefix (
redirectUrl.startsWith(_server.url)
). Now our wrong endpoint url has just host-url, without any subdomain or subpath, so in cases when this endpoint is in the list before the jwt-endpoint, it is matched and we try to do the keycloak machinetoken auth with this endpoint, which of course does not work.Che version
next (development version)
Steps to reproduce
chectl server:deploy --platform openshift --che-operator-cr-patch-yaml=patch.yml
where patch.yml is:Expected behavior
Workspace must be accessible and endpoint urls correct
Runtime
OpenShift
Screenshots
No response
Installation method
chectl/next
Environment
other (please specify in additional context)
Eclipse Che Logs
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: