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-3129 - Project can't be created without Z option #3130

Merged
merged 1 commit into from
Dec 15, 2016

Conversation

snjeza
Copy link
Contributor

@snjeza snjeza commented Nov 19, 2016

What does this PR do?

It fixes #3129

What issues does this PR fix or reference?

#3129

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

@codenvy-ci
Copy link

Can one of the admins verify this patch?

@benoitf
Copy link
Contributor

benoitf commented Nov 20, 2016

ci-build

@codenvy-ci
Copy link

Build # 1074 - FAILED

Please check console output at https://ci.codenvycorp.com/job/che-pullrequests-build/1074/ to view the results.

@tolusha
Copy link
Contributor

tolusha commented Nov 21, 2016

@garagatyi
Could you have a look pls. A think it is matter of che.docker.volumes_projects_options configuration not code changing.

@l0rd
Copy link
Contributor

l0rd commented Nov 21, 2016

@tolusha I think that #3129 needs code changing (in the default config the property is set).

@snjeza I think you need do the same check for property che.docker.volumes_agent_options and if you could flag the fields/parameters with @Nullable it would be nice.

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.

@snjeza Nice catch!
@tolusha No, code have to be changed in any case.
@l0rd Agree with you, Mario!

@snjeza Please consider comments of Mario and mine. Please also rename volumeOptions argument of constructor to projectsVolumeOptions

@@ -69,9 +71,15 @@ public void provision(Environment envConfig, CheServicesEnvironmentImpl internal
// add bind-mount volume for projects in a workspace
String projectFolderVolume;
try {
projectFolderVolume = format("%s:%s:%s",
if (Strings.isNullOrEmpty(volumesOptions)) {

Choose a reason for hiding this comment

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

Let's form suffix in constructor. Then you won't need this clause in main code.

@snjeza
Copy link
Contributor Author

snjeza commented Nov 21, 2016

I have updated the patch.

@@ -35,19 +38,23 @@
private final WorkspaceFolderPathProvider workspaceFolderPathProvider;
private final WindowsPathEscaper pathEscaper;
private final String projectFolderPath;
private final String volumesOptions;
private final String projectsVolumeOptions;

Choose a reason for hiding this comment

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

Please replace tab character with spaces. Someone put it here but it is not allowed for indentation in Che.

@@ -64,7 +67,11 @@ public String get() {
}

private String getTargetOptions(final String path) {
return path + CONTAINER_TARGET + ":" + volumeOptions;
if (!Strings.isNullOrEmpty(agentVolumeOptions)) {

Choose a reason for hiding this comment

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

Please create constructor and put this code there as you did in LocalCheInfrastructureProvisioner

@@ -68,6 +71,10 @@ public String get() {
}

private String getTargetOptions(final String path) {
return path + CONTAINER_TARGET + ":" + volumeOptions;
if (!Strings.isNullOrEmpty(agentVolumeOptions)) {

Choose a reason for hiding this comment

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

Please create constructor and put this code there as you did in LocalCheInfrastructureProvisioner

@snjeza
Copy link
Contributor Author

snjeza commented Nov 21, 2016

The patch updated.

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.

Sorry that still asking you to change your PR, but there are few minor changes to be made.

private String agentVolumeOptions;

public DockerExtConfBindingProvider() {
if (!Strings.isNullOrEmpty(agentVolumeOptions)) {

Choose a reason for hiding this comment

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

Constructor is called before field injection in Guice. So here we will have null value always. Can you replace field injection with a constructor injection.

private String agentVolumeOptions;

public TerminalVolumeProvider() {
if (!Strings.isNullOrEmpty(agentVolumeOptions)) {

Choose a reason for hiding this comment

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

Constructor is called before field injection in Guice. So here we will have null value always. Can you replace field injection with a constructor injection.

private String agentVolumeOptions;

public WsAgentVolumeProvider() {
if (!Strings.isNullOrEmpty(agentVolumeOptions)) {

Choose a reason for hiding this comment

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

Constructor is called before field injection in Guice. So here we will have null value always. Can you replace field injection with a constructor injection.

@snjeza
Copy link
Contributor Author

snjeza commented Nov 21, 2016

The patch updated.
I wasn't able to inject the che.docker.volumes_agent_options option to the DockerExtConfBindingProvider constructor because DockerExtServerModule created it with the empty constructor.
Che doesn't start when I try to bind DockerExtConfBindingProvider to DockerExtServerModule.

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, Snjezana!

@@ -43,8 +46,8 @@
private static final Logger LOG = LoggerFactory.getLogger(DockerExtConfBindingProvider.class);

@Inject
@Named("che.docker.volumes_agent_options")
private String volumeOptions;
@Nullable @Named("che.docker.volumes_agent_options")

Choose a reason for hiding this comment

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

OK, then leave it as it is now, I'll fix that in one of my next PRs.

@sleshchenko
Copy link
Member

Looks like DockerExtConfBindingProvider shouldn't work correctly because instance is created with default constructor and requestInjection method is not invoked for it. Please make sure that it works correctly

@snjeza
Copy link
Contributor Author

snjeza commented Nov 22, 2016

Looks like DockerExtConfBindingProvider shouldn't work correctly because instance is created
with default constructor and requestInjection method is not invoked for it. Please make sure
that it works correctly

That's why I haven't injected the che.docker.volumes_agent_options option to the DockerExtConfBindingProvider constructor.
I have tested the build with and without the Z option. It works properly.

@garagatyi
Copy link

If instance of class is created manually and injection is not requested it should not work if I understand how it works. Can you describe how did you test that?

@snjeza
Copy link
Contributor Author

snjeza commented Nov 22, 2016

I have created che-server, started it with different che.properies, created a project, reviewed mounted volumes using "docker inspect". Everything works as expected.

@garagatyi
Copy link

@sleshchenko correct me if I'm mistaken but looks like ws-agent configuration works in a different way.

@snjeza
Copy link
Contributor Author

snjeza commented Nov 22, 2016

When excluding the Z option, the volumes are mounted in the following way:

 "Mounts": [
            {
                "Source": "/data/workspaces/wksp-8t9p",
                "Destination": "/projects",
                "Mode": "",
                "RW": true,
                "Propagation": "rprivate"
            },
            {
                "Source": "/tmp/data/lib/linux_amd64/terminal",
                "Destination": "/mnt/che/terminal",
                "Mode": "ro",
                "RW": false,
                "Propagation": "rprivate"
            },
            {
                "Source": "/tmp/data/lib/ws-agent.tar.gz",
                "Destination": "/mnt/che/ws-agent.tar.gz",
                "Mode": "ro",
                "RW": false,
                "Propagation": "rprivate"
            }
        ],

@sleshchenko
Copy link
Member

@snjeza Please create folder plugin-conf in CHE_LOCAL_CONF_DIR. As far as I understand it can be empty. And then mounts should include extra one with "Destination": /mnt/che/conf"". Please make ensure that it is mounted with 'Z' suffix when configuration contains it. If no, please try to add requestInjection(extConfBindingProvider); in DockerExtServerModule

@snjeza
Copy link
Contributor Author

snjeza commented Nov 22, 2016

The following are the mounted volumes:

 "Mounts": [
            {
                "Source": "/data/workspaces/wksp-8t9p",
                "Destination": "/projects",
                "Mode": "",
                "RW": true,
                "Propagation": "rprivate"
            },
            {
                "Source": "/tmp/data/lib/linux_amd64/terminal",
                "Destination": "/mnt/che/terminal",
                "Mode": "ro",
                "RW": false,
                "Propagation": "rprivate"
            },
            {
                "Source": "/tmp/data/lib/ws-agent.tar.gz",
                "Destination": "/mnt/che/ws-agent.tar.gz",
                "Mode": "ro",
                "RW": false,
                "Propagation": "rprivate"
            },
            {
                "Source": "/conf/plugin-conf",
                "Destination": "/mnt/che/conf",
                "Mode": "ro",
                "RW": false,
                "Propagation": "rprivate"
            }
        ],

with the Z option

"Mounts": [
            {
                "Source": "/data/workspaces/wksp-jvuc",
                "Destination": "/projects",
                "Mode": "Z",
                "RW": true,
                "Propagation": "rprivate"
            },
            {
                "Source": "/tmp/lib/linux_amd64/terminal",
                "Destination": "/mnt/che/terminal",
                "Mode": "ro,Z",
                "RW": false,
                "Propagation": "rprivate"
            },
            {
                "Source": "/data/conf/plugin-conf",
                "Destination": "/mnt/che/conf",
                "Mode": "ro,Z",
                "RW": false,
                "Propagation": "rprivate"
            },
            {
                "Source": "/tmp/lib/ws-agent.tar.gz",
                "Destination": "/mnt/che/ws-agent.tar.gz",
                "Mode": "ro,Z",
                "RW": false,
                "Propagation": "rprivate"
            }
        ],

@garagatyi
Copy link

It is interesting. We debugged DockerExtConfBindingProvider usage and guice injected dependencies between 1st and 2nd calls of get method of this class. Sorry that we asked you to check more and more but we missed that Guice behavior with singleton classes.

@garagatyi
Copy link

ci-build

@codenvy-ci
Copy link

@garagatyi garagatyi added this to the 5.0.0-M9 milestone Nov 25, 2016
@vparfonov vparfonov merged commit 9f5a7fb into eclipse-che:master Dec 15, 2016
JPinkney pushed a commit to JPinkney/che that referenced this pull request Aug 17, 2017
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.

Project can't be created without Z option
8 participants