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

fix #35843 regression on health check workingdir #35845

Merged
merged 2 commits into from
Dec 21, 2017

Conversation

ndeloof
Copy link
Contributor

@ndeloof ndeloof commented Dec 20, 2017

- What I did

Fix for #35843

- How I did it

Set recently introduced exec.WorkingDir to container's workingdir

- How to verify it

see #35843 description

- Description for the changelog
Fixed #35843

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

2013_6beb

@GordonTheTurtle GordonTheTurtle added dco/no Automatically set by a bot when one of the commits lacks proper signature status/0-triage labels Dec 20, 2017
@GordonTheTurtle GordonTheTurtle removed the dco/no Automatically set by a bot when one of the commits lacks proper signature label Dec 20, 2017
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.

change LGTM; perhaps a small test to catch regressions?

@thaJeztah
Copy link
Member

Also, thanks for the quick fix 👍

Copy link
Member

@cpuguy83 cpuguy83 left a comment

Choose a reason for hiding this comment

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

Can we get a test for this?

@ndeloof
Copy link
Contributor Author

ndeloof commented Dec 20, 2017

Sorry, won't have much time before Christmas vacations to investigate a test case (not sure how to wait for container to report Health logs)

@thaJeztah
Copy link
Member

thaJeztah commented Dec 20, 2017

Something like this should be able to test the behaviour, but yes, we'll need a short timeout / loop to test the result

docker run -dit \
  --health-cmd="if [ \"\$PWD\" = \"/foo\" ]; then exit 0; else exit 1; fi;" \
  --health-interval=0.5s \
  --health-retries=1  \
  --workdir=/foo \
  busybox

(edit: removed /bin/sh as it's the default)

@thaJeztah
Copy link
Member

Had a quick try, and I have a test; will add it here

@thaJeztah
Copy link
Member

Pushed a test; ping @dnephin @vdemeester @cpuguy83 PTAL

err = client.ContainerStart(ctx, c.ID, types.ContainerStartOptions{})
require.NoError(t, err)

time.Sleep(1 * time.Second)
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure if an integration test is necessary here. Could this be tested with a unit test of run() instead?

Sleeping in a test case should generally be avoided. If this integration test is really necessary then this should use poll.WaitOn() to wait for the state, instead of sleep and inspect.

poll.WaitOn() will also make the test more reliable on loaded systems, because the timeout can be longer than 1s.

Copy link
Member

Choose a reason for hiding this comment

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

I think an integration test is warranted here, because run and exec (used for the healthcheck) take different code paths.

Thanks for the poll.WaitOn(), I'll check that one out

@thaJeztah
Copy link
Member

Updated, PTAL 👍

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

@tiborvass
Copy link
Contributor

LGTM

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.

8 participants