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

Check FS mounting lazily #875

Merged
merged 4 commits into from
Sep 23, 2018
Merged

Check FS mounting lazily #875

merged 4 commits into from
Sep 23, 2018

Conversation

bsideup
Copy link
Member

@bsideup bsideup commented Sep 23, 2018

No description provided.

@bsideup bsideup added this to the next milestone Sep 23, 2018
Copy link
Member

@kiview kiview left a comment

Choose a reason for hiding this comment

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

Nice one, consider my comments as you see fit 😉

} catch (Exception e) {
VisibleAssertions.fail("File should be mountable but fails with " + e.getMessage());
log.debug("Failed to check mountable file", e);
Copy link
Member

Choose a reason for hiding this comment

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

Probably better to rephrase the message: Failure while checking for mountable file support

Copy link
Member

Choose a reason for hiding this comment

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

So you want to keep the message? 😆

Copy link
Member Author

Choose a reason for hiding this comment

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

missed this one :)

@@ -455,6 +456,12 @@ private void applyConfiguration(CreateContainerCmd createCommand) {
.toArray(String[]::new);
createCommand.withEnv(envArray);

if (binds.size() > 0 && !TestcontainersConfiguration.getInstance().isDisableChecks()) {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe extract to boolean variable shouldCheckFileMountingSupport

List<Bind> binds = new ArrayList<>();
binds.add(new Bind("//var/run/docker.sock", new Volume("/var/run/docker.sock")));
if (withDummyMount) {
// Not needed for Ryuk, but we perform pre-flight checks with it (micro optimization)
binds.add(new Bind(mountableFile.getResolvedPath(), new Volume("/dummy"), AccessMode.ro));
Copy link
Member

Choose a reason for hiding this comment

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

Very nice, that we can remove this!

@@ -455,6 +456,12 @@ private void applyConfiguration(CreateContainerCmd createCommand) {
.toArray(String[]::new);
createCommand.withEnv(envArray);

if (binds.size() > 0 && !TestcontainersConfiguration.getInstance().isDisableChecks()) {
if (!DockerClientFactory.instance().isSupportsFileMounting()) {
VisibleAssertions.warn("Misconfigured file mounting. Some features might not work.");
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we could be very specific in the warning; something like: Unable to mount a file from test host into a running container. This may be a misconfiguration or limitation of your Docker environment. Some features might not work.

Additionally, is it right for this to be a warning, or should we throw an exception? If we're here, it's because the user has tried to do something that will not work, right? Or is it possible for this check to fail but the user's requested FS binds to work?

Copy link
Member Author

Choose a reason for hiding this comment

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

If user is mounting /var/run/docker.sock, it will still work, this is why I decided to use warn :)

@rnorth
Copy link
Member

rnorth commented Sep 23, 2018

Sorry I didn't manage to review earlier today :(

Same as @kiview; please treat my comments as you see fit and merge when you want - no need for a lot of back-and-forth comments on this 😄

@bsideup bsideup merged commit 8acee4d into master Sep 23, 2018
@bsideup bsideup deleted the lazy_fs_check branch September 23, 2018 17:03
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.

None yet

3 participants