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

[JENKINS-47178] Replace Windows path separator with Unix path separator #308

Merged
merged 1 commit into from Jun 26, 2018
Merged

[JENKINS-47178] Replace Windows path separator with Unix path separator #308

merged 1 commit into from Jun 26, 2018

Conversation

ghost
Copy link

@ghost ghost commented Apr 10, 2018

Use Unix path separator in volume mount paths

Signed-off-by: Alex Johnson ajohnson@bombora.com

@carlossg carlossg requested a review from Vlatombe April 12, 2018 15:16
@Vlatombe
Copy link
Member

What issue is this fixing? Would be great to add a test as well.

@ghost
Copy link
Author

ghost commented Apr 12, 2018

@Vlatombe: If the Jenkins master is running on a Windows machine, the Path.toString function uses the Windows path separator in volume mount paths.

@ghost
Copy link
Author

ghost commented Apr 12, 2018

volumeMounts:
    - mountPath: \usr\bin\docker
      name: volume-2
    - mountPath: \root\workspace
      name: volume-0
    - mountPath: \var\run\docker.sock
      name: volume-1

@ghost
Copy link
Author

ghost commented Apr 12, 2018

@Vlatombe: And regarding tests, are there any tests that are currently testing volume creation?

@Vlatombe
Copy link
Member

@TheOriginalAlex Thanks for providing the context.
If I understand the issue correctly, it means that the existing test class org.csanchez.jenkins.plugins.kubernetes.PodTemplateBuilderTest fails on windows and should be fixed by this PR. Could you confirm?

@carlossg I guess the best way to handle such problems would be to have a tests running on windows.

@carlossg
Copy link
Contributor

@Vlatombe
Copy link
Member

@carlossg ah right, it's loading definition from yaml files, so it doesn't go through the path getting changed here.

Probably just a matter of creating a new test case that is declaring a volume mount using the PodTemplateBuilder methods directly.

@ghost
Copy link
Author

ghost commented Apr 16, 2018

@Vlatombe, @carlossg: Should I go ahead and add that test?

@Vlatombe
Copy link
Member

@TheOriginalAlex yes, it would be great to avoid regressions.

@ghost
Copy link
Author

ghost commented Apr 16, 2018

Wouldn't making this setYaml function in org.csanchez.jenkins.plugins.kubernetes.PodTemplate load contents of the yaml into the object properties (i.e. this.volumes) ensure that the existing tests catch these errors?

@DataBoundSetter
public void setYaml(String yaml) {
    this.yaml = yaml;
}

@ghost
Copy link
Author

ghost commented Apr 16, 2018

Or is there a specific reason why only the string version of the yaml is stored in the object?

@Vlatombe
Copy link
Member

The yaml allows to support any kind of field supported by kubernetes that may not be implemented by the plugin.

@ghost
Copy link
Author

ghost commented Apr 16, 2018

@Vlatombe: Got it! Thanks for the clarification!

import static org.csanchez.jenkins.plugins.kubernetes.volumes.HostPathVolume.*;
import static org.csanchez.jenkins.plugins.kubernetes.volumes.EmptyDirVolume.*;
import static org.csanchez.jenkins.plugins.kubernetes.volumes.PodVolume.*;
import static org.csanchez.jenkins.plugins.kubernetes.volumes.ContainerTemplate.*;
Copy link
Contributor

Choose a reason for hiding this comment

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

wrong package name

@carlossg
Copy link
Contributor

the test is failing with

ERROR] testBuildFromTemplate(org.csanchez.jenkins.plugins.kubernetes.PodTemplateBuilderTest)  Time elapsed: 0.005 s  <<< FAILURE!

java.lang.AssertionError

	at org.junit.Assert.fail(Assert.java:86)

	at org.junit.Assert.assertTrue(Assert.java:41)

	at org.junit.Assert.assertNotNull(Assert.java:712)

	at org.junit.Assert.assertNotNull(Assert.java:722)

	at org.csanchez.jenkins.plugins.kubernetes.PodTemplateBuilderTest.validatePod(PodTemplateBuilderTest.java:155)

	at org.csanchez.jenkins.plugins.kubernetes.PodTemplateBuilderTest.testBuildFromTemplate(PodTemplateBuilderTest.java:128)

@carlossg carlossg changed the title Replace Windows path separator with Unix path separator [JENKINS-47178] Replace Windows path separator with Unix path separator May 25, 2018
mount paths

Signed-off-by: Alex Johnson <ajohnson@bombora.com>
@ghost
Copy link
Author

ghost commented Jun 22, 2018

@carlossg: Finally got around to fixing the tests... sorry about the delay!

@carlossg carlossg merged commit 7aec2f4 into jenkinsci:master Jun 26, 2018
@carlossg
Copy link
Contributor

thanks!

@ghost ghost deleted the path-normalize branch June 26, 2018 20:22
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.

2 participants