diff --git a/assembly/assembly-wsmaster-war/src/main/webapp/WEB-INF/classes/codenvy/che.properties b/assembly/assembly-wsmaster-war/src/main/webapp/WEB-INF/classes/codenvy/che.properties index 612c12f2f29..57e902a632b 100644 --- a/assembly/assembly-wsmaster-war/src/main/webapp/WEB-INF/classes/codenvy/che.properties +++ b/assembly/assembly-wsmaster-war/src/main/webapp/WEB-INF/classes/codenvy/che.properties @@ -324,6 +324,14 @@ che.openshift.secure.routes=false che.openshift.jobs.image=centos:centos7 che.openshift.jobs.memorylimit=250Mi +# Run job to create workspace subpath directories in persistent volume before launching workspace. +# Necessary in some versions of OpenShift/Kubernetes as workspace subpath volumemounts are created +# with root permissions, and thus cannot be modified by workspaces running as user (presents as error +# importing projects into workspace in Che). Default is "true", but should be set to false if version +# of Openshift/Kubernetes creates subdirectories with user permissions. +# Relevant issue: https://github.com/kubernetes/kubernetes/issues/41638 +che.openshift.precreate.workspace.dirs=true + # Specifications of compute resources that can be consumed # by the workspace container: # diff --git a/plugins/plugin-docker/che-plugin-openshift-client/src/main/java/org/eclipse/che/plugin/openshift/client/OpenShiftConnector.java b/plugins/plugin-docker/che-plugin-openshift-client/src/main/java/org/eclipse/che/plugin/openshift/client/OpenShiftConnector.java index 0de5824afe9..ef5ffbedce3 100644 --- a/plugins/plugin-docker/che-plugin-openshift-client/src/main/java/org/eclipse/che/plugin/openshift/client/OpenShiftConnector.java +++ b/plugins/plugin-docker/che-plugin-openshift-client/src/main/java/org/eclipse/che/plugin/openshift/client/OpenShiftConnector.java @@ -174,6 +174,7 @@ public class OpenShiftConnector extends DockerConnector { private final String cheWorkspaceMemoryLimit; private final String cheWorkspaceMemoryRequest; private final boolean secureRoutes; + private final boolean createWorkspaceDirs; private final OpenShiftPvcHelper openShiftPvcHelper; @Inject @@ -192,7 +193,8 @@ public OpenShiftConnector(DockerConnectorConfiguration connectorConfiguration, @Named("che.workspace.projects.storage") String cheWorkspaceProjectsStorage, @Nullable @Named("che.openshift.workspace.memory.request") String cheWorkspaceMemoryRequest, @Nullable @Named("che.openshift.workspace.memory.override") String cheWorkspaceMemoryLimit, - @Named("che.openshift.secure.routes") boolean secureRoutes) { + @Named("che.openshift.secure.routes") boolean secureRoutes, + @Named("che.openshift.precreate.workspace.dirs") boolean createWorkspaceDirs) { super(connectorConfiguration, connectionFactory, authResolver, dockerApiVersionPathPrefixProvider); this.cheServerExternalAddress = cheServerExternalAddress; @@ -206,6 +208,7 @@ public OpenShiftConnector(DockerConnectorConfiguration connectorConfiguration, this.cheWorkspaceMemoryRequest = cheWorkspaceMemoryRequest; this.cheWorkspaceMemoryLimit = cheWorkspaceMemoryLimit; this.secureRoutes = secureRoutes; + this.createWorkspaceDirs = createWorkspaceDirs; this.openShiftPvcHelper = openShiftPvcHelper; } @@ -1067,7 +1070,9 @@ private String createOpenShiftDeployment(String workspaceID, LOG.info("Adding container {} to OpenShift deployment {}", sanitizedContainerName, deploymentName); - createWorkspaceDir(volumes); + if (createWorkspaceDirs) { + createWorkspaceDir(volumes); + } Container container = new ContainerBuilder() .withName(sanitizedContainerName) diff --git a/plugins/plugin-docker/che-plugin-openshift-client/src/test/java/org/eclipse/che/plugin/openshift/client/OpenShiftConnectorTest.java b/plugins/plugin-docker/che-plugin-openshift-client/src/test/java/org/eclipse/che/plugin/openshift/client/OpenShiftConnectorTest.java index 8caa9a72dd2..c0e507f915a 100644 --- a/plugins/plugin-docker/che-plugin-openshift-client/src/test/java/org/eclipse/che/plugin/openshift/client/OpenShiftConnectorTest.java +++ b/plugins/plugin-docker/che-plugin-openshift-client/src/test/java/org/eclipse/che/plugin/openshift/client/OpenShiftConnectorTest.java @@ -40,6 +40,7 @@ public class OpenShiftConnectorTest { private static final String CHE_DEFAULT_SERVER_EXTERNAL_ADDRESS = "che.openshift.mini"; private static final String CHE_WORKSPACE_CPU_LIMIT = "1"; private static final boolean SECURE_ROUTES = false; + private static final boolean CREATE_WORKSPACE_DIRS = true; @Mock @@ -82,7 +83,8 @@ public void shouldGetWorkspaceIDWhenAValidOneIsProvidedInCreateContainerParams() OPENSHIFT_DEFAULT_WORKSPACE_PROJECTS_STORAGE, CHE_WORKSPACE_CPU_LIMIT, null, - SECURE_ROUTES); + SECURE_ROUTES, + CREATE_WORKSPACE_DIRS); String workspaceID = openShiftConnector.getCheWorkspaceId(createContainerParams); //Then