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-39748] provide Image.exec() to avoid disabling ENTRYPOINT in the image #78

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hogarthj
Copy link

@hogarthj hogarthj commented Nov 14, 2016

There were comments on JENKINS-37987 that the change to overriding ENTRYPOINT on Image.inside() (#63) broke workflows.

On the way to JENKINS-26179 this was a fairly simple change whilst heading towards a Container.exec()

This adds a new Image.exec() {} which behaves identically to Image.inside() {} with the one exception that it does not override ENTRYPOINT so images that rely on ENTRYPOINT not being messed with can still be used.

@hogarthj hogarthj changed the title [JENKINS-37987] provide Image.exec() to avoid disabling ENTRYPOINT in the image [JENKINS-39748] provide Image.exec() to avoid disabling ENTRYPOINT in the image Nov 15, 2016
@mskutin
Copy link

mskutin commented Nov 24, 2016

Any chance this could be reviewed and merged?

Copy link
Member

@jglick jglick left a comment

Choose a reason for hiding this comment

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

Idea seems reasonable; step design could be cleaned up.

@@ -53,7 +53,7 @@

/**
* Simple docker client for Pipeline.
*
*
Copy link
Member

Choose a reason for hiding this comment

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

Please avoid making extraneous diff hunks, particular whitespace changes. You should be able to configure popular editors to not touch lines of code unless and until you edit them.

@@ -125,6 +125,17 @@ class Docker implements Serializable {
}
}

public <V> V exec(String args = '', Closure<V> body) {
docker.node {
if (docker.script.sh(script: "docker inspect -f . ${id}", returnStatus: true) != 0) {
Copy link
Member

Choose a reason for hiding this comment

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

Going to clash with #84

WorkflowRun b = story.j.assertBuildStatusSuccess(p.scheduleBuild2(0));
}
});
story.addStep(new Statement() {
Copy link
Member

Choose a reason for hiding this comment

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

Gratuitous Jenkins restarts.

@@ -116,7 +116,11 @@ public String run(@Nonnull EnvVars launchEnv, @Nonnull String image, @CheckForNu
argb.add("-e");
argb.addMasked(variable.getKey()+"="+variable.getValue());
}
argb.add("--entrypoint").add(entrypoint).add(image);
if (!entrypoint.equals("--")) {
Copy link
Member

Choose a reason for hiding this comment

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

Better to make entrypoint be @CheckForNull.


container = dockerClient.run(env, step.image, step.args, ws, volumes, volumesFromContainers, envReduced, dockerClient.whoAmI(), /* expected to hang until killed */ "cat");
if (step.entrypoint == null) {
step.entrypoint = "cat";
Copy link
Member

Choose a reason for hiding this comment

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

See the developer guide: better to initialize the field with the "cat" value, have the setter call Util.fixEmpty, and have Image.exec specify entrypoint: ''. Also be sure to adjust WithContainerStep/config.jelly to specify

<f:entry field="entrypoint" title="">
    <f:textbox default="cat"/> <!-- or ${descriptor.defaultEntrypoint}, if defined -->
<f:entry>

and add help-entrypoint.html.

But anyway better would probably be to change this to a boolean field, since

  • there is no use case for doing anything other than leaving the image along, or overriding its entrypoint to go to sleep
  • there is a good reason to consider replacing cat with something like sleep infinity (except with a more POSIX-compliant argument)

The special techniques for step default values are the same for boolean parameters, but if you pick the semantics so that the default is in fact false, it is somewhat easier to write:

<f:checkbox/>

rather than

<f:checkbox default="true"/>

and a simpler form in the Java class.

@jglick
Copy link
Member

jglick commented Feb 13, 2017

Alternately, JENKINS-40170.

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