Skip to content

introduce workingdir option for docker exec #35661

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

Merged
merged 2 commits into from
Dec 6, 2017
Merged

Conversation

ndeloof
Copy link
Contributor

@ndeloof ndeloof commented Dec 1, 2017

Signed-off-by: Nicolas De Loof nicolas.deloof@gmail.com

- What I did

Implemented WorkingDir support for execs, as discussed on #8917

- How I did it

introduced WorkingDir in API and used for new process to be ran, falling back to container's WorkingDir if not set.

- How to verify it

Need to forge API call or use client package

- Description for the changelog

Introduce option to configure woking directory to run additional process in a container with exec

- A picture of a cute animal (not mandatory but encouraged)

9788d27ee39ea4f56dcc3f784a8deede

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
@ndeloof
Copy link
Contributor Author

ndeloof commented Dec 1, 2017

I've ran make swagger-gen but don't get api/types/container/container_wait.go updated (which I do not expect) as reported by CI

@tonistiigi
Copy link
Member

Design LGTM

Copy link
Member

@yongtang yongtang left a comment

Choose a reason for hiding this comment

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

looks good to me, though can you add a test for it?

@ndeloof ndeloof force-pushed the 8917 branch 10 times, most recently from c259609 to 0ef331f Compare December 3, 2017 15:22
Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

Design LGTM
/cc @thaJeztah @dnephin

Copy link
Member

@dnephin dnephin left a comment

Choose a reason for hiding this comment

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

Thanks, couple comments about the test.

@@ -0,0 +1,33 @@
package exec
Copy link
Member

Choose a reason for hiding this comment

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

exec is not a component (see https://github.com/moby/moby/tree/master/api/server/router). The component is container so this should go in integration/container.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, I can move this to container.

"github.com/stretchr/testify/require"
)

func TestExecWithWorkingDir(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

We shouldn't write an integration test for option. How about just making this TestExec() and we can add a bunch of fields to this single test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean you prefer a single, huge test to check all options and their correct behaviour ? Won't this make it harder to diagnose a build failure with a clear cause ?

Copy link
Member

@dnephin dnephin Dec 4, 2017

Choose a reason for hiding this comment

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

It shouldn't be any harder if the failure messages are written correctly.

If there are options that conflict with each other, or that significantly change the behaviour of other options then multiple tests might be necessary, but I don't think that's the case here. Most of the options are independent, and we don't need to run multiple extremely slow tests to check each independent option.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right, but testing workdir require to set a custom command executed, while testing other options like env will require to run /bin/env, etc...

Copy link
Member

Choose a reason for hiding this comment

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

fair point. For those two cases I think env works for both, since PWD should be set. Is that right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

implemented as 57c5631

@thaJeztah
Copy link
Member

@dnephin PR was updated 👍

@GordonTheTurtle GordonTheTurtle added the dco/no Automatically set by a bot when one of the commits lacks proper signature label Dec 4, 2017
@GordonTheTurtle GordonTheTurtle removed the dco/no Automatically set by a bot when one of the commits lacks proper signature label Dec 4, 2017
@moby moby deleted a comment from GordonTheTurtle Dec 4, 2017
Copy link
Member

@boaz0 boaz0 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@dnephin dnephin left a comment

Choose a reason for hiding this comment

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

LGTM

Thanks!

"foo",
)
require.NoError(t, err)
defer client.ContainerRemove(ctx, container.ID,
Copy link
Member

Choose a reason for hiding this comment

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

This cleanup is automatically handled by defer setupTest(t)() but I guess it doesn't hurt to have it, other than it might encourage others to add unnecessary cleanup to new tests.

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

changes LGTM, but can you squash your commits (where needed)? Also while doing so, perhaps you can address @dnephin's nit https://github.com/moby/moby/pull/35661/files#r155046183

Then we can merge; if you can prepare a PR for the docker/cli it may just make it for 17.12

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
@ndeloof
Copy link
Contributor Author

ndeloof commented Dec 6, 2017

commits squashed

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@thaJeztah
Copy link
Member

oh! looks like there's an issue with the Swagger definition;

06:46:44 The result of hack/generate-swagger-api.sh differs
06:46:44 
06:46:44  M api/types/container/container_wait.go
06:46:44 
06:46:44 Please update api/swagger.yaml with any api changes, then 

@ndeloof
Copy link
Contributor Author

ndeloof commented Dec 6, 2017

@thaJeztah yes, this happened on a regular basis on this PR, I can't explain why. Used to re-run janky build with rebuild/janky tag.
(it would help if this check also dump a diff, not just modified status)

@thaJeztah
Copy link
Member

it would help if this check also dump a diff, not just modified status

Yes, definitely! I actually started building from this PR to check what the diff was, but I'm currently on super-slow-hotel-wifi, and just emptied my image cache before I left the office 😂

Let me trigger CI again to see if it resolves itself 👍

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

Successfully merging this pull request may close these issues.

10 participants