Skip to content

fix #35843 regression on health check workingdir#35845

Merged
AkihiroSuda merged 2 commits into
moby:masterfrom
ndeloof:FIX35843
Dec 21, 2017
Merged

fix #35843 regression on health check workingdir#35845
AkihiroSuda merged 2 commits into
moby:masterfrom
ndeloof:FIX35843

Conversation

@ndeloof
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

Also, thanks for the quick fix 👍

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

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

@thaJeztah
Copy link
Copy Markdown
Member

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

Comment thread integration/container/health_test.go Outdated
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

Updated, PTAL 👍

Copy link
Copy Markdown
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
Copy Markdown
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