Skip to content
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

CHE-1489: rework workspaces folder usage to fix Che on some configs #1733

Merged
merged 7 commits into from
Jul 18, 2016

Conversation

garagatyi
Copy link

What does this PR do?

Fixes storing FS of workspaces between Che runs in case Che runs in the container.
Removes unneeded provider.

What issues does this PR fix or reference?

Fixes #1711

Previous Behavior

Che tried to create folders of projects roots of workspace on start of new workspace.
So path of projects root of workspace has to match in Che container and on docker host.

New Behavior

It is possible to define property or environment variable to disable creation of workspace folder by Che.
In that case docker will create folders mounted to workspace container on host. This folder will have root permissions.

Tests written?

Old tests were fixed. No new tests are added yet.

Docs requirements?

Include the content for all the docs changes required.
New instructions on how to run Che in container would be useful.

@garagatyi
Copy link
Author

@eivantsov @TylerJewell @evoevodin @sleshchenko @mmorhun Please review

@TylerJewell
Copy link

@garagatyi - please document the property name & how it can be configured.

@TylerJewell
Copy link

@eivantsov - FYI, I am unable to build a docker image for this on a windows box right now. There seems to be some problems with docker for windows and CRLF for newlines. Can you build an image that has this change and put it on docker hub for testing?

@codenvy-ci
Copy link

@mmorhun
Copy link
Contributor

mmorhun commented Jul 15, 2016

+1

@ghost
Copy link

ghost commented Jul 15, 2016

@TylerJewell here's how you may try the fix:

docker run --net=host -v /var/run/docker.sock:/var/run/docker.sock -v /c/Users/Tyler/che-storage:/c/Users/Tyler/che-storage -v $(pwd):/home/user/.che -e "CHE_LOCAL_CONF_DIR=/home/user/.che" -e "CHE_ALLOW_CREATION_WORKSPACE_FOLDERS=false" eivantsov/che1

In the current directory, create che.properties file with che.user.workspaces.storage=/c/Users/Tyler/che-storage

final Path cheHome = WindowsHostUtils.ensureCheHomeExist(createFolders);
final Path vfs = cheHome.resolve("vfs");
if (createFolders) {
if (!vfs.toFile().mkdir()) {
Copy link
Contributor

@voievodin voievodin Jul 15, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to use nested if statement

@voievodin
Copy link
Contributor

LGTM

@garagatyi
Copy link
Author

@TylerJewell Are you OK with that PR? Can I merge it?

@TylerJewell
Copy link

@garagatyi:

  1. What is the che.props entry for the same env variable?
  2. Please change CHE_ALLOW_CREATION_WORKSPACE_FOLDERS to CHE_CREATE_WS_FOLDERS.

@ghost
Copy link

ghost commented Jul 15, 2016

che.user.workspaces.storage.create_folders

…Che on some configs Signed-off-by: Alexander Garagatyi <[email protected]>
@garagatyi
Copy link
Author

garagatyi commented Jul 15, 2016

Renamed CHE_ALLOW_CREATION_WORKSPACE_FOLDERS to CHE_CREATE_WS_FOLDERS

@TylerJewell
Copy link

@garagatyi @eivantsov - it failed for me. Server was unable to boot and gave an error message in the console below.

docker run --net=host --rm --name=che^
 -v /c/users/tyler/che:/c/users/tyler/che^
 -v /c/codenvy:/home/user/.che^
 -e "CHE_LOCAL_CONF_DIR=/home/user/.che"^
 -e "CHE_ALLOW_CREATION_WORKSPACE_FOLDERS=false"^
 -e "DOCKER_HOST=tcp://10.0.75.2:2375"^
 eivantsov/che1
2016-07-15 11:51:05,075[ost-startStop-1]  [INFO ] [o.a.c.startup.HostConfig 910]        - Deploying web application archive /home/user/che/tomcat/webapps/wsmaster.war
2016-07-15 11:51:08,157[ost-startStop-1]  [WARN ] [p.DockerExtConfBindingProvider 51]   - DockerExtConfBindingProvider
2016-07-at org.eclipse.che.plugin.docker.client.InitialAuthConfig.getRegistryPrefix(InitialAuthConfig.java:99)ntext initialized event
 to listat org.eclipse.che.plugin.docker.client.InitialAuthConfig.lambda$new$0(InitialAuthConfig.java:73)
com.googat java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)rors:
        at java.util.HashMap$EntrySpliterator.forEachRemaining(HashMap.java:1691)
1) Errorat java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)rty 'docker.registry.auth.password' is missing '.'. V
alid creat java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
  at orgat java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)java:68)
  at orgat java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)fig.java:48)
  while at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
    for at org.eclipse.che.plugin.docker.client.InitialAuthConfig.<init>(InitialAuthConfig.java:74)t>(DockerConnectorConfiguration.ja
va:123) at org.eclipse.che.plugin.docker.client.InitialAuthConfig$$FastClassByGuice$$6c93a19d.newInstance(<generated>)
  while at com.google.inject.internal.DefaultConstructionProxyFactory$FastClassProxy.newInstance(DefaultConstructionProxyFactory.java:89)for the 1st parameter of org.eclipse.che.plugin.docker.client.DockerConnector.<init>(DockerConnector.java:143)
  at orgat com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:111)

@garagatyi
Copy link
Author

Please send me privately your external conf file

@TylerJewell
Copy link

@garagatyi @eivantsov - Ok, got things to work after some reconfiguration. We will have to make it really clear for users that they may have to reset their docker for windows credentials to gain access otherwise they may get exception failures.

Can we please change the default che.properties file that ships to have the following comment modified.

# This property works for Docker for Windows, Mac, and Linux.
# On windows with virtualbox, this property is ignored.
che.user.workspaces.storage=/c/users/tyler/che/workspaces
che.user.workspaces.storage.create_folders=false

Can we also rename these two properties to:

che.workspace.storage
che.workspace.storage.create_folders

The run syntax that finally worked:

docker run --net=host --rm --name=che^
 -v /home/user/che/lib:/home/user/che/lib-copy^
 -v /c/users/tyler/che/workspaces:/c/users/tyler/che/workspaces^
 -v /c/users/tyler/che/storage:/home/user/che/storage^
 -v /c/codenvy:/home/user/.che^
 -e "CHE_LOCAL_CONF_DIR=/home/user/.che"^
 -e "CHE_ALLOW_CREATION_WORKSPACE_FOLDERS=false"^
 -e "DOCKER_HOST=tcp://10.0.75.2:2375"^
 eivantsov/che1

@garagatyi
Copy link
Author

@TylerJewell here is current comment

### Storage and user configuration
# The location where your workspaces (and their projects) are stored.
# This property is ignored on Windows due to limitations with VirtualBox
# On Windows, all workspaces stored in c:\%userprofile%\AppData\Local\Eclipse Che\
che.user.workspaces.storage=${che.home}/workspaces

Do you want to have next comment instead?

### Storage and user configuration
# The location where your workspaces (and their projects) are stored.
# This property works for Docker for Windows, Mac, and Linux.
# On windows with virtualbox, this property is ignored. Instead of that all workspaces stored in c:\%userprofile%\AppData\Local\Eclipse Che\

@garagatyi
Copy link
Author

If we rename property che.user.workspaces.storage then users with configured external property files will miss the projects after upgrade. Are you OK with that?

@TylerJewell
Copy link

@garagatyi

### Storage and user configuration
# The location where your workspaces (and their projects) are stored.
# This property works for Docker for Windows, Mac, and Linux.
# On virtualbox for windows, this property is ignored. Instead, they are stored at:
# c:\%userprofile%\AppData\Local\Eclipse Che\

@TylerJewell
Copy link

@garagatyi - yes, ok with the breaking change. Is there anyway we can quietly support the old configuration in our code? So that there are two properties for the same value? We will only document and show the new one but quietly honor the old?

@garagatyi
Copy link
Author

garagatyi commented Jul 15, 2016

We will only document and show the new one but quietly honor the old?

Yes, it is possible

@TylerJewell
Copy link

@garagatyi - ok, after changes of comments and property names, +1 from me - ok to merge.

@garagatyi
Copy link
Author

@TylerJewell What then do if both old and new properties are set?

@TylerJewell
Copy link

@garagatyi - accept new one, I think.

@garagatyi
Copy link
Author

Looks like we will have to accept the old one because it will be the case when user overrided old property and then upgraded Che.

@codenvy-ci
Copy link

…to fix Che on some configs Signed-off-by: Alexander Garagatyi <[email protected]>
checkProps(workspacesMountPoint, hostProjectsFolder);
this.isWindows = SystemInfo.isWindows();
String allowFoldersCreationEnvVar = System.getenv(ALLOW_FOLDERS_CREATION_ENV_VARIABLE);
if (allowFoldersCreationEnvVar != null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove this check. Or merge with next by &&
I prefer first variant

@sleshchenko
Copy link
Member

LGTM

@TylerJewell
Copy link

@garagatyi - did this improvement remove the need for the volume mount? If so, once eugene creates a new image, I can test. Otherwise LGTM.

… usage to fix Che on some configs Signed-off-by: Alexander Garagatyi <[email protected]>
@garagatyi
Copy link
Author

Yes. You don't have to mount workspaces folder into Che container if folders creation is disabled (e.g. in your case).

@TylerJewell
Copy link

@garagatyi - can we add an environment variable for che.workspace.storage property named CHE_WORKSPACE_STORAGE? By having both properties available as environment variables, we can configure both of these with -e commands without the user having to create a custom che.properties file. So right now, Windows users will always have to create a custom properties file and we should give them environment variables only.

Also, to start the process of more consistency - I updated the name of the properties and the environment variables that match. Sorry for moving this around. I had to write some docs on this and get a feel before I could settle in on a standard.

che.workspace.storage
che.workspace.storage.create_folders
CHE_WORKSPACE_STORAGE
CHE_WORKSPACE_STORAGE_CREATE_FOLDERS

@TylerJewell
Copy link

@codenvy-ci
Copy link

Build # 1227 - FAILED

Please check console output at http://ci.codenvy-dev.com/jenkins/job/che-pullrequests-build/1227/ to view the results.

… folder usage to fix Che on some configs Signed-off-by: Alexander Garagatyi <[email protected]>
@codenvy-ci
Copy link

Build # 1228 - FAILED

Please check console output at http://ci.codenvy-dev.com/jenkins/job/che-pullrequests-build/1228/ to view the results.

@garagatyi garagatyi merged commit 3eb38cd into master Jul 18, 2016
@garagatyi garagatyi deleted the CHE-1489 branch July 18, 2016 10:03
@garagatyi
Copy link
Author

Now mounting /workspaces folder into Che container is not needed. storage path can be set with env variable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Docker for Windows Beta does not write workspaces and storage files to mounted drives
6 participants