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

Pass --volume options to creator phase #675

Merged
merged 4 commits into from
Jun 8, 2020
Merged

Conversation

simonjjones
Copy link
Member

This resolves a bug where we weren't configuring the creator phase with any binds configured with the --volume option

Resolves #674

Signed-off-by: Simon Jones [email protected]

Resolves #674

Signed-off-by: Simon Jones <[email protected]>
@simonjjones simonjjones requested a review from a team as a code owner June 5, 2020 14:54
@codecov
Copy link

codecov bot commented Jun 5, 2020

Codecov Report

Merging #675 into master will decrease coverage by 0.17%.
The diff coverage is 14.29%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #675      +/-   ##
==========================================
- Coverage   72.65%   72.49%   -0.16%     
==========================================
  Files          67       67              
  Lines        4866     4877      +11     
==========================================
  Hits         3535     3535              
- Misses       1010     1021      +11     
  Partials      321      321              
Flag Coverage Δ
#os_linux 75.14% <14.29%> (-0.20%) ⬇️
#os_macos 71.28% <14.29%> (-0.19%) ⬇️
#os_windows 71.07% <14.29%> (-0.16%) ⬇️
#unit 72.49% <14.29%> (-0.16%) ⬇️

Comment on lines +960 to +963
_ = os.Remove(buildpackTgz)
_ = h.DockerRmi(dockerCli, repoName)

h.AssertNil(t, os.RemoveAll(tempVolume))
_ = os.RemoveAll(tempVolume)
Copy link
Contributor

@yaelharel yaelharel Jun 5, 2020

Choose a reason for hiding this comment

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

Why did you remove the assertions?

Copy link
Member Author

Choose a reason for hiding this comment

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

The test is now skippable, so cleanup can reasonably expect to fail when it's skipped

Copy link
Contributor

Choose a reason for hiding this comment

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

You're right! Thanks for the clarification!

h.AssertNil(t, err)

configProvider := fakePhaseFactory.NewCalledWithProvider
h.AssertEq(t, configProvider.HostConfig().NetworkMode, container.NetworkMode(expectedNetworkMode))
})

it("configures the phase with both cache binds and custom volume mounts", func() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since you added this check, maybe we can remove the tests on lines 212 and 332

Copy link
Member Author

Choose a reason for hiding this comment

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

They still test slightly different circumstances - the difference between publish and not, as well as ensuring the cache binds will be configured regardless of whether a custom volume is configured.

Copy link
Contributor

Choose a reason for hiding this comment

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

You're right but I'm not sure if I would keep all 3 tests. I think it's a little confusing that we're testing part of it 3 times.
Maybe we change this test to test only the configuration with custom volume mounts, and to keep the other tests to test only the cache and launch-cache.
What do you think about that?

Copy link
Member Author

Choose a reason for hiding this comment

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

I opted to remove this test, and add custom volume mounts to the existing bind tests which cover both the publish=true and publish=false contexts.

Copy link
Contributor

@yaelharel yaelharel left a comment

Choose a reason for hiding this comment

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

Thanks for making these changes!

Copy link
Member

@dfreilich dfreilich left a comment

Choose a reason for hiding this comment

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

LGTM!

@jromero
Copy link
Member

jromero commented Jun 8, 2020

✔️ Accepted

./out/pack build some-app -v -B cnbs/sample-builder:alpine -p ../samples/apps/bash-script/ --volume /tmp/some-dir:/my-dir --trust-builder
Using project descriptor located at ../samples/apps/bash-script/project.toml
Pulling image index.docker.io/cnbs/sample-builder:alpine
alpine: Pulling from cnbs/sample-builder
Digest: sha256:eaf42c17a45bfa6bcf5b73fe4f1d64e36376dd91addb0872bd5911628f71fb91
Status: Image is up to date for cnbs/sample-builder:alpine
Selected run image cnbs/sample-stack-run:alpine
Pulling image cnbs/sample-stack-run:alpine
alpine: Pulling from cnbs/sample-stack-run
Digest: sha256:5832173333c36b98b3ab47b7dc97248f3d9e297973c136f47171776b2950dedd
Status: Image is up to date for cnbs/sample-stack-run:alpine
Adding buildpack samples/bash-script version 0.0.1 to builder
Setting custom order
Creating builder with the following buildpacks:
-> samples/[email protected]
-> samples/[email protected]
-> samples/[email protected]
-> samples/[email protected]
-> samples/[email protected]
-> samples/[email protected]
Using build cache volume pack-cache-891d1f8dedc9.build
---> DETECTING
======== Output: samples/[email protected] ========
---> Hello Bash Script buildpack

Here are the contents of the current working directory:
.:
total 16
drwxr-xr-x    2 cnb      cnb           4096 Jun  8 19:24 .
drwxr-xr-x    1 root     root          4096 Jun  8 19:24 ..
-rwxr-xr-x    1 cnb      cnb            738 Apr  6 23:13 app.sh
-rw-r--r--    1 cnb      cnb            202 Apr  6 23:13 project.toml
Here are the contents of /platform:
/platform:
total 12
drwxr-xr-x    1 root     root          4096 Jun  8 19:24 .
drwxr-xr-x    1 root     root          4096 Jun  8 19:24 ..
drwxr-xr-x    1 root     root          4096 Jan  1  1980 env
drwxr-xr-x    4 cnb      cnb            128 Jun  8 19:23 my-dir

/platform/env:
total 8
drwxr-xr-x    1 root     root          4096 Jan  1  1980 .
drwxr-xr-x    1 root     root          4096 Jun  8 19:24 ..

/platform/my-dir:
total 4
drwxr-xr-x    4 cnb      cnb            128 Jun  8 19:23 .
drwxr-xr-x    1 root     root          4096 Jun  8 19:24 ..
drwxr-xr-x    3 cnb      cnb             96 Jun  8 19:23 other-dir
-rw-r--r--    1 cnb      cnb              0 Jun  8 19:22 some-file

/platform/my-dir/other-dir:
total 0
drwxr-xr-x    3 cnb      cnb             96 Jun  8 19:23 .
drwxr-xr-x    4 cnb      cnb            128 Jun  8 19:23 ..
-rw-r--r--    1 cnb      cnb              0 Jun  8 19:23 other-file
======== Results ========
pass: samples/[email protected]
Resolving plan... (try #1)
samples/bash-script 0.0.1
---> ANALYZING
Analyzing image "ce0aa8dbf65c9bfa8fc47bb1a39e3bbea4635c47a8b88a3b1730a309a4ab9451"
---> RESTORING
---> BUILDING
---> Hello World buildpack
---> Hello Bash Script buildpack

Here are the contents of the current working directory:
.:
total 16
drwxr-xr-x    2 cnb      cnb           4096 Jun  8 19:24 .
drwxr-xr-x    1 root     root          4096 Jun  8 19:24 ..
-rwxr-xr-x    1 cnb      cnb            738 Apr  6 23:13 app.sh
-rw-r--r--    1 cnb      cnb            202 Apr  6 23:13 project.toml
Here are the contents of /platform:
/platform:
total 12
drwxr-xr-x    1 root     root          4096 Jun  8 19:24 .
drwxr-xr-x    1 root     root          4096 Jun  8 19:24 ..
drwxr-xr-x    1 root     root          4096 Jan  1  1980 env
drwxr-xr-x    4 cnb      cnb            128 Jun  8 19:23 my-dir

/platform/env:
total 8
drwxr-xr-x    1 root     root          4096 Jan  1  1980 .
drwxr-xr-x    1 root     root          4096 Jun  8 19:24 ..

/platform/my-dir:
total 4
drwxr-xr-x    4 cnb      cnb            128 Jun  8 19:23 .
drwxr-xr-x    1 root     root          4096 Jun  8 19:24 ..
drwxr-xr-x    3 cnb      cnb             96 Jun  8 19:23 other-dir
-rw-r--r--    1 cnb      cnb              0 Jun  8 19:22 some-file

/platform/my-dir/other-dir:
total 0
drwxr-xr-x    3 cnb      cnb             96 Jun  8 19:23 .
drwxr-xr-x    4 cnb      cnb            128 Jun  8 19:23 ..
-rw-r--r--    1 cnb      cnb              0 Jun  8 19:23 other-file
---> EXPORTING
no project metadata found at path './project-metadata.toml', project metadata will not be exported
Reusing layers from image with id 'ce0aa8dbf65c9bfa8fc47bb1a39e3bbea4635c47a8b88a3b1730a309a4ab9451'
Writing tarball for layer "launcher"
Reusing layer 'launcher'
Layer 'launcher' SHA: sha256:32608bc6d97e0193edb0360555b3e08dc6dfe1187833d8548cdd9e662213935b
Layer 'app' SHA: sha256:4c6ff16e28deaf437a1abe5c926cdfb8afcd2c31ea544f6992ed7b665965b3f4
Reusing 1/1 app layer(s)
Writing tarball for layer "config"
Reusing layer 'config'
Layer 'config' SHA: sha256:ed89d623eb7cf47a03403af0b6d3723a967ca4f73985b97056246193d29eb3b0
*** Images (ce0aa8dbf65c):
      index.docker.io/library/some-app:latest

*** Image ID: ce0aa8dbf65c9bfa8fc47bb1a39e3bbea4635c47a8b88a3b1730a309a4ab9451
Successfully built image some-app

@jromero jromero merged commit 777b1f3 into master Jun 8, 2020
@jromero jromero deleted the 674-mount-volumes-in-creator branch June 8, 2020 19:26
@jromero jromero added the type/bug Issue that reports an unexpected behaviour. label Jun 8, 2020
@jromero jromero added this to the 0.11.1 milestone Jun 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Issue that reports an unexpected behaviour.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pack doesn't mount provided volume when using creator
4 participants