Skip to content

Remove error return on !exists in validateMountConfigReg#35159

Closed
cdhunt wants to merge 1 commit intomoby:masterfrom
cdhunt:master
Closed

Remove error return on !exists in validateMountConfigReg#35159
cdhunt wants to merge 1 commit intomoby:masterfrom
cdhunt:master

Conversation

@cdhunt
Copy link
Copy Markdown

@cdhunt cdhunt commented Oct 10, 2017

We found while developing Docker Executor for Windows support for GitLab CI that the CI Runner code takes advantage of the docker daemon behavior to create directories on the host when mounting volumes. With Windows Containers, this throws an error, however, the logic to create the missing directory is platform agnostic.

- What I did
Removed the hard check if the directory exists on the host in mount config validation.
- How I did it
Changed the condition logic.
- How to verify it
Mount a volume to a directory that does not exist on the host. It should be created and not throw an error.
- Description for the changelog

Fix the inconsistent behavior between Linux and Windows containers when mounting to a directory that does not already exist.

@cdhunt cdhunt changed the title Remove error return on !exists in validateMountConfigReg [WIP] Remove error return on !exists in validateMountConfigReg Oct 10, 2017
@cdhunt cdhunt changed the title [WIP] Remove error return on !exists in validateMountConfigReg Remove error return on !exists in validateMountConfigReg Oct 11, 2017
@thaJeztah
Copy link
Copy Markdown
Member

I seem to recall auto-creation was only kept around on Linux for backward compatibility (it was deprecated for a long time, but was too much of a breaking change to remove), however, on Windows it never worked, and because of that (at least at the time) it was decided to not enable it.

Some background in #19953, #21666, #16349

/cc @cpuguy83

@cdhunt
Copy link
Copy Markdown
Author

cdhunt commented Oct 11, 2017

Thanks, @thaJeztah. I think I concur with a lot of the sentiment in #21666 (for both sides). Specifically, we're trying to avoid interacting with the host directly and only use the Docker API. I'm pretty sure the GitLab CI Runner is already largely dependent on this feature for Linux hosts. I have validated the create logic does work on Server 2016 build 14393.1358.amd64fre.rs1_release.170602-2252.

@thecloudtaylor
Copy link
Copy Markdown

It seems like this behavior is here to stay on the Linux side (for good/for bad/for otherwise) for me parity across platforms is a really valuable principal especially as we roll out LCOW. The original PR (Moby: 19953) on listed the motivation for the change as "it is not reasonable.in fact,we can skip non-existant volume host path and remove "MkdirAll" from Setup.". Which doesn't give me much to go on as to why auto-creation is the wrong policy.

It seems this also tied into a change was made in runC (runc: 493). I can see a very reasonable position that runC fail in this case vs auto creation but that Docker or even ContainerD could support the auto creation of the directory as a management policy in effect.

All that to say without an good reason to depart from parity with Linux I would be in favor of accepting this (or a similar) change.

cc: @jhowardmsft @darrenstahlmsft

@cpuguy83
Copy link
Copy Markdown
Member

I agree parity would be good here so long as it works.

@PatrickLang
Copy link
Copy Markdown

pinging myself

@thaJeztah
Copy link
Copy Markdown
Member

We discussed this in the maintainers meeting, and we're okay with lifting this restriction for Windows

ping @cdhunt can you update the PR (remove the commented-out code), so that we can move this forward?

@GordonTheTurtle GordonTheTurtle added the dco/no Automatically set by a bot when one of the commits lacks proper signature label Dec 14, 2017
@GordonTheTurtle
Copy link
Copy Markdown

Please sign your commits following these rules:
https://github.com/moby/moby/blob/master/CONTRIBUTING.md#sign-your-work
The easiest way to do this is to amend the last commit:

$ git clone -b "master" [email protected]:cdhunt/moby.git somewhere
$ cd somewhere
$ git rebase -i HEAD~842353698296
editor opens
change each 'pick' to 'edit'
save the file and quit
$ git commit --amend -s --no-edit
$ git rebase --continue # and repeat the amend for each commit
$ git push -f

Amending updates the existing PR. You DO NOT need to open a new one.

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

Do we have a "positive" test for this? (i.e. this test-case should now pass, correct?)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Code wise, there's nothing new to test. The coverage is the same either way. I did change the functional test to validate no error is thrown. Do you still think we should include the positive tests?

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.

Well, we previously tested that this should fail, but I couldn't find a test in the Windows valid list that now verifies that the test passes with a non-existing path (but I may have overlooked)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I've added valid tests for Windows and LCOW.

@GordonTheTurtle GordonTheTurtle added the dco/no Automatically set by a bot when one of the commits lacks proper signature label Dec 20, 2017
@lowenna
Copy link
Copy Markdown
Member

lowenna commented Jan 5, 2018

Sorry, trying to catch up with my backlog. I guess my only concern with this is that docker users can now arbitrarily create folders on the host through the docker API which they can't necessarily clean up. Is that not a concern?

@cpuguy83
Copy link
Copy Markdown
Member

cpuguy83 commented Jan 5, 2018

This is pretty consistent with linux.

@thaJeztah
Copy link
Copy Markdown
Member

users can now arbitrarily create folders on the host through the docker API

Correct; it's not ideal, but it's what a lot of people use. We are recommending the --mount option, which doesn't have this behavior.

which they can't necessarily clean up

Can they be removed from a privileged/elevated session?

@cdhunt looks like this needs a rebase; also looks like there's a commit that isn't signed off

@GordonTheTurtle GordonTheTurtle removed the dco/no Automatically set by a bot when one of the commits lacks proper signature label Jan 8, 2018
@cdhunt
Copy link
Copy Markdown
Author

cdhunt commented Jan 8, 2018

@thaJeztah I've rebased and it looks like all commits are signed.

@lowenna
Copy link
Copy Markdown
Member

lowenna commented Jan 19, 2018

This is pretty consistent with linux.

@cpuguy83 Right, but that wasn't what I was asking. I was asking if it's the right thing to be doing.

@cpuguy83
Copy link
Copy Markdown
Member

@cdhunt Can you squash your commits?

@cdhunt
Copy link
Copy Markdown
Author

cdhunt commented Aug 16, 2018

@cpuguy83 Could you provide some guidance for that? When I try to squash 2 commits I end up with thousands of changes. I'm struggling to tame my messy branch history.

@cpuguy83
Copy link
Copy Markdown
Member

git rebase -i HEAD~5 and squash all down to the first commit.

@thaJeztah
Copy link
Copy Markdown
Member

@codecov
Copy link
Copy Markdown

codecov bot commented Aug 16, 2018

Codecov Report

Merging #35159 into master will decrease coverage by 0.23%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master   #35159      +/-   ##
==========================================
- Coverage   35.85%   35.61%   -0.24%     
==========================================
  Files         606      611       +5     
  Lines       44704    44960     +256     
==========================================
- Hits        16027    16014      -13     
- Misses      26469    26733     +264     
- Partials     2208     2213       +5

@thaJeztah
Copy link
Copy Markdown
Member

@cdhunt thanks for squashing! Looks like there's two failures; looks related to this change;

18:34:26 --- FAIL: TestParseMountRawSplit (0.00s)
...
18:34:26 	parser_test.go:389: Expected error, was nil, for spec c:\foo\bar:\\.\pipe\foo
18:34:26 --- FAIL: TestValidateMount (0.00s)
18:34:26 	validate_test.go:58: expected "bind mount source path does not exist: c:\\foo", got %!q(<nil>), case: 8

On Linux, volume binding creates the directory on the host. This conditional check on Windows was preventing Windows Containers from creating the directory producing inconsistent behavior between platforms.

Signed-off-by:  Chris Hunt <[email protected]>
@cdhunt
Copy link
Copy Markdown
Author

cdhunt commented Aug 17, 2018

@thaJeztah Sorry about that.

@thaJeztah
Copy link
Copy Markdown
Member

no worries! Just noted that it was failing (github likely won't send a notification if that's happening).

Looks like one was fixed, but one is still failing; one down; one to go! 🎉

14:40:23 --- FAIL: TestValidateMount (0.00s)
14:40:23 	validate_test.go:58: expected %!q(<nil>), got "invalid mount config for type \"bind\": bind mount source path does not exist: /foo", case: 8

@cdhunt
Copy link
Copy Markdown
Author

cdhunt commented Aug 17, 2018

@thaJeztah Can you point me to that result? Or maybe more specifically the test automation. I'm pretty sure this is coming from the LCOW side and I'm not sure exactly how to run those tests.

@thaJeztah
Copy link
Copy Markdown
Member

I'm pretty sure this is coming from the LCOW side and I'm not sure exactly how to run those tests.

CI in this repository currently doesn't run on Windows RS3 and up (so doesn't run LCOW), so likely not related to LCOW (perhaps there's a test-case that shouldn't be run on Linux though)

You can click the links next to the failing CI runs;

Windows RS1 actually showed a panic in TestContainersAPICreateMountsValidation

17:28:48 PANIC: docker_api_containers_test.go:1706: DockerSuite.TestContainersAPICreateMountsValidation
17:28:48 
17:28:48 case 0
17:28:48 case 1
17:28:48 case 2
17:28:48 case 3
17:28:48 ... Panic: runtime error: invalid memory address or nil pointer dereference (PC=0x458341)
17:28:48 
17:28:48 d:/CI/CI-3285a6745/go/src/runtime/asm_amd64.s:573
17:28:48   in call32
17:28:48 d:/CI/CI-3285a6745/go/src/runtime/panic.go:502
17:28:48   in gopanic
17:28:48 d:/CI/CI-3285a6745/go/src/runtime/panic.go:63
17:28:48   in panicmem
17:28:48 d:/CI/CI-3285a6745/go/src/runtime/signal_windows.go:167
17:28:48   in sigpanic
17:28:48 docker_api_containers_test.go:1895
17:28:48   in DockerSuite.TestContainersAPICreateMountsValidation
17:28:48 d:/CI/CI-3285a6745/go/src/runtime/asm_amd64.s:573
17:28:48   in call32
17:28:48 d:/CI/CI-3285a6745/go/src/reflect/value.go:447
17:28:48   in Value.call
17:28:48 d:/CI/CI-3285a6745/go/src/reflect/value.go:308
17:28:48   in Value.Call
17:28:48 c:/gopath/src/github.com/docker/docker/vendor/github.com/go-check/check/check.go:816
17:28:48   in suiteRunner.forkTest.func1
17:28:48 c:/gopath/src/github.com/docker/docker/vendor/github.com/go-check/check/check.go:672
17:28:48   in suiteRunner.forkCall.func1
17:28:48 d:/CI/CI-3285a6745/go/src/runtime/asm_amd64.s:2361
17:28:48   in goexit

@BMOD89
Copy link
Copy Markdown

BMOD89 commented Sep 9, 2018

Any news regarding this topic?

@thaJeztah
Copy link
Copy Markdown
Member

@cdhunt were you still working on the test failures?

@cdhunt
Copy link
Copy Markdown
Author

cdhunt commented Nov 6, 2018

@thaJeztah No, I'm not set up to develop and test the affected variations. Thank you for your help over the last 13 months.

@cdhunt cdhunt closed this Nov 6, 2018
@thaJeztah
Copy link
Copy Markdown
Member

No worries, thanks @cdhunt !

I'll have a look around as well if there's possibly someone that has time to carry this PR

@thaJeztah
Copy link
Copy Markdown
Member

@simonferquel @silvin-lubecki - perhaps of interest to you?

@jasonyavorsky
Copy link
Copy Markdown

This is interesting to me. If I was to get the PR in a mergeable state would it be accepted?

@thaJeztah
Copy link
Copy Markdown
Member

@fastloris yes, definitely. I think the PR was almost done, but there were some complications to get the tests working correctly; if you're interested in carrying this, that would be appreciated 👍

@thaJeztah
Copy link
Copy Markdown
Member

Feel free to "ping" me if you need help (e.g. to restore/copy the branch in this PR; you can download the patch if needed using this URL; https://patch-diff.githubusercontent.com/raw/moby/moby/pull/35159.patch

@steve-mt
Copy link
Copy Markdown

I've picked this up and opened a new PR #38465 I have questions about that original fix though to help me fix that failing tests!

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.