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-2874 Let users configure the 'Z' flag when mouting a volume #2921

Merged
merged 1 commit into from
Nov 17, 2016

Conversation

snjeza
Copy link
Contributor

@snjeza snjeza commented Oct 27, 2016

What does this PR do?

It adds the following two properties:

che.machine.docker.volumes.projects.options (Z by default)

that is used when che mounts the /projects volume

che.machine.docker.volumes.workspace.options (ro,Z by default)

used when mounting the following volumes:

/mnt/che/terminal
/mnt/che/ws-agent.tar.gz
/mnt/che/conf

Notice:
che-launcher also uses the Z option. I haven't changed it.

What issues does this PR fix or reference?

#2874

Signed-off-by: Snjezana Peco [email protected]

@codenvy-ci
Copy link

Can one of the admins verify this patch?

@TylerJewell TylerJewell added the kind/enhancement A feature request - must adhere to the feature request template. label Oct 27, 2016
@TylerJewell
Copy link

TylerJewell commented Oct 27, 2016

@snjeza - thanks for this contribution. You may not have seen it, but there was a major merge this morning where we renamed all of the che.properties so that they all start with che. and we simplified them to make them clearer for users to understand. Let me dig up the new che.properties and the merge, and perhaps you can propose a new name and location for these properties?

#2707

@snjeza snjeza force-pushed the issue2874 branch 3 times, most recently from bcb6efa to 6b354f9 Compare October 27, 2016 20:11
@l0rd
Copy link
Contributor

l0rd commented Oct 31, 2016

LGTM @garagatyi @benoitf can you please have a look at this PR that fixes #2874

workspaceFolderPathProvider.getPath(workspaceId),
projectFolderPath);
if (volumeOptions != null && !volumeOptions.isEmpty()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

you should use guava helper isNullOrEmpty / com.google.common.base.Strings.isNullOrEmpty;

workspaceFolderPathProvider.getPath(workspaceId),
projectFolderPath);
if (volumeOptions != null && !volumeOptions.isEmpty()) {
projectFolderVolume = projectFolderVolume + ":" + volumeOptions;
Copy link
Contributor

Choose a reason for hiding this comment

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

use of += to add to current ?

@@ -55,18 +61,22 @@ public String get() {
return null;
}

if (volumeOptions == null) {
volumeOptions="ro,Z";
Copy link
Contributor

Choose a reason for hiding this comment

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

IMHO default options should be in properties file or to be a constant

} catch (IOException e) {
LOG.warn(e.getMessage());
throw new RuntimeException(e);
}
} else {
return extConfDir.getAbsolutePath() + CONTAINER_TARGET;
return extConfDir.getAbsolutePath() + CONTAINER_TARGET + ":" + volumeOptions;
Copy link
Contributor

Choose a reason for hiding this comment

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

small concern : maybe to have a getTargetOptions() helper method as there are some duplicates between unix and windows

if (SystemInfo.isWindows()) {
if (volumeOptions == null) {
volumeOptions="ro,Z";
Copy link
Contributor

Choose a reason for hiding this comment

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

constants or directly as default properties ?

@snjeza
Copy link
Contributor Author

snjeza commented Oct 31, 2016

I have updated the patch.

public static final String EXT_CHE_LOCAL_CONF_DIR = "/mnt/che/conf";
private static final String RO_Z = "ro,Z";

public static final String EXT_CHE_LOCAL_CONF_DIR = "/mnt/che/conf";
Copy link
Contributor

Choose a reason for hiding this comment

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

indent is not correct

@@ -55,18 +63,27 @@ public String get() {
return null;
}

if (volumeOptions == null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

as @Inject on volumeOptions is not optional, I think that we could get rid of default value from the code as it becomes a mandatory parameter

@Override
public String get() {
if (volumeOptions == null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

same here, as it's a required parameter it needs to be provided so we don't have to handle this

@benoitf
Copy link
Contributor

benoitf commented Oct 31, 2016

ci-build

@snjeza
Copy link
Contributor Author

snjeza commented Oct 31, 2016

The patch has been updated.

Copy link
Contributor

@benoitf benoitf left a comment

Choose a reason for hiding this comment

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

need to sync before merging this property for codenvy properties

@benoitf benoitf added the status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. label Oct 31, 2016
@codenvy-ci
Copy link

@TylerJewell
Copy link

Nicely done @snjeza - @l0rd - will you be managing the merge process + milestone selection + QA communications?

@l0rd l0rd added this to the 5.0.0-M7 milestone Nov 1, 2016
@l0rd
Copy link
Contributor

l0rd commented Nov 1, 2016

@TylerJewell can you be more explicit on the QA communications? I would like to help but I'm not sure to understand what is expected.
@benoitf in what repository are codenvy properties? Should @snjeza update them?

@TylerJewell
Copy link

Yes, sure thing. When you merge the issue that is targeted for a particular milestone, please talk to @vkuznyetsov about whether there should be any additional QA or integration tests added into the CI system that can be run regularly to test this behavior.

All of the "base" che.properties are in assembly/assembly-wsmaster-war/src/main/webapp/WEB-INF/classes.

Note that there is a new che.properties that has a new naming scheme. They are all designed to be user friendly. There is an alias file which maps the new names to the old names so that if you still use the old properties then they will still work for awhile.

Copy link

@garagatyi garagatyi left a comment

Choose a reason for hiding this comment

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

Overall PR is good. Please address my comments

che.machine.docker.volumes.projects.options=Z

# Adds options when mounting the /mnt/che/terminal, /mnt/che/ws-agent.tar.gz, /mnt/che/conf volume
che.machine.docker.volumes.workspace.options=ro,Z

Choose a reason for hiding this comment

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

According to a comment it related to agents rather to workspace. Probably property name should be aligned with the comment.

@@ -41,6 +41,7 @@
private String pidMode;
private boolean readonlyRootfs;
private Ulimit[] ulimits;
private String volumeOptions;

Choose a reason for hiding this comment

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

I don't see such field in Docker Create container API. Can you point me out where it is?

@@ -146,7 +147,8 @@ public MachineProviderImpl(DockerConnector docker,
@Named("machine.docker.machine_env") Set<String> allMachinesEnvVariables,
@Named("che.docker.registry_for_snapshots") boolean snapshotUseRegistry,
@Named("che.docker.swap") double memorySwapMultiplier,
@Named("machine.docker.networks") Set<Set<String>> additionalNetworks)
@Named("machine.docker.networks") Set<Set<String>> additionalNetworks,
@Nullable @Named("che.machine.docker.volumes.projects.options") String volumeOptions)

Choose a reason for hiding this comment

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

We use dots to separate categories of implementation. We use underscores to separate words of single term. Please ensure that you are following that policy

private static final Logger LOG = LoggerFactory.getLogger(DockerExtConfBindingProvider.class);

@Inject
@Named("che.machine.docker.volumes.workspace.options")

Choose a reason for hiding this comment

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

Please ensure that you are following properties naming policy described above

@snjeza
Copy link
Contributor Author

snjeza commented Nov 1, 2016

I have changed the names of the properties and added the volumeOptions field to the Docker Create container API.

@garagatyi
Copy link

Probably we misunderstand each other. I meant that I can't find volumeOptions in Docker API documentation. So I don't understand why you added such a field in HostConfig object which is our representation of Docker API model.

Can you elaborate?

@snjeza
Copy link
Contributor Author

snjeza commented Nov 2, 2016

I have reviewed the che.docker.privilege property and implemented the che.docker.volumes_projects_options property in a similar way.

@garagatyi
Copy link

che.docker.privilege property represents a flag from Docker API documentation, whereas volumeOptions is not present in HostConfig representation.

@snjeza
Copy link
Contributor Author

snjeza commented Nov 3, 2016

I will try to move the volumeOptions property to another class.

@snjeza
Copy link
Contributor Author

snjeza commented Nov 3, 2016

I have removed the volumeOptions property from Docker API documentation.

@bmicklea
Copy link

bmicklea commented Nov 8, 2016

M7 needs to be complete by tomorrow (Nov 8) pushing to M8 but if it's merged tomorrow it can be reassigned to M7.

@l0rd
Copy link
Contributor

l0rd commented Nov 11, 2016

@snjeza please let me know when you have confirmed that this PR will fix the issue when running Che on CentOS 7 with RH packaged Docker.

@garagatyi
Copy link

Sorry for delay, @snjeza. I've refactored code around container bootstrapping for simplifying code for environment SPI implementation. Please rework your PR because of that.

Now volume for projects is bound in LocalCheInfrastructureProvisioner. Other changes in this PR looks good to me

@snjeza
Copy link
Contributor Author

snjeza commented Nov 15, 2016

I have updated the patch.
@l0rd
I will test the new patch with centos 7. Currently, I can't start the workspace when using the master branch with or without my patch.

Copy link

@garagatyi garagatyi left a comment

Choose a reason for hiding this comment

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

Good job!

@snjeza
Copy link
Contributor Author

snjeza commented Nov 17, 2016

@l0rd,
I have tested the patch with centos 7. It works. I have had to use the overlay driver to start che with and without the patch.

@l0rd
Copy link
Contributor

l0rd commented Nov 17, 2016

Thank you @snjeza 🎉 LGTM

@l0rd l0rd merged commit b7682dd into eclipse-che:master Nov 17, 2016
@TylerJewell
Copy link

@benoitf - very important that we capture these changes and merge them as part of the CLI consolidation.

@l0rd l0rd removed the status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. label Nov 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement A feature request - must adhere to the feature request template.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants