Commit Graph

283 Commits

Author SHA1 Message Date
Yoan Blanc 908025b6d3
integration: removing test on docker
Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
2019-12-22 11:18:34 +01:00
Yoan Blanc 3678b70239
Merge remote-tracking branch 'origin/master' into registry-mirror 2019-12-22 11:10:15 +01:00
Cole Wippern bdabd774fc Update linter and fix errors
* disable linters that are now enabled by default in new version
* fix linter errors
2019-12-21 12:27:14 -08:00
Cole Wippern 05447f1eaa clean up unused code 2019-12-09 13:57:59 -08:00
Yoan Blanc 980c87ac17
Merge remote-tracking branch 'origin/master' into registry-mirror 2019-12-05 19:12:47 +01:00
Cole Wippern c2645b2207 Fix #897 - only build required docker images
Only build the docker images required for the integration tests which
will be executed rather than building all docker images every time.
2019-12-02 13:19:43 -08:00
Cole Wippern b057776849
Merge pull request #857 from cvgw/u/cgwippern/symlink-bug
Resolve symlink targets to abs path before copying
2019-11-22 10:02:58 -08:00
Cole Wippern 1ec2387940 Add integration test for add url with arg 2019-11-15 14:44:39 -08:00
Cole Wippern 8f66e8613f Add new test for copy to symlink which should fail 2019-11-15 11:23:04 -08:00
Yoan Blanc 6e2287c969
readme: add --registry-mirror
Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
2019-11-10 12:55:31 +01:00
Cole Wippern 006b4996cb Fix quote strip behavior for ARG values
* fixes issue 847
* previous implementation did not properly parse blank
values which were enclosed in quotes
2019-11-08 14:28:31 -08:00
Yoan Blanc 73f7ea0d2c
fixup! integration: build using registry-mirror
Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
2019-11-08 16:17:00 +01:00
Yoan Blanc dd9758cccc
integration: build using registry-mirror
Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
2019-11-08 15:39:43 +01:00
Tejal Desai 5bbb40e4f0
Merge pull request #834 from cvgw/u/cgwippern/ISSUE_439_strip_arg_quotes
Issue #439 Strip out double quotes in ARG value
2019-11-07 10:54:17 -08:00
Don McCasland ab7b210ac1
Adding missing integration test file 2019-11-04 09:30:58 -08:00
Don McCasland 5716c44ab8
Merge branch 'master' into bug-742-2 2019-11-04 09:25:25 -08:00
Cole Wippern ec2e7705c8 Issue #439 add additional tests for quotes
Add additional tests to ensure that ARG values with quotes
are handled properly
2019-10-25 16:08:57 -07:00
Cole Wippern 79649a1614 Issue #439 double quotes in ARG value
* Strip out double quotes enclosing ARG value after parsing
dockerfile
2019-10-24 16:30:25 -07:00
Don McCasland e5da55d4cd
Adding integration test 2019-10-08 07:42:09 -07:00
Tejal Desai 9eb4a1c1ff
Merge pull request #801 from victornoel/776-dockerignore-relative
Support Dockerfile.dockerignore
2019-10-04 01:56:40 -07:00
Victor Noel ff7abba47b Fix integration tests for #776 2019-10-04 10:31:40 +02:00
Tejal Desai 22188595f0
Merge pull request #768 from N4rm0/fix-envar-replacement-for-url
Fix #691 - ADD does not understand ENV variables
2019-10-04 01:17:22 -07:00
Victor Noel db12a77e6c Fix #776 2019-10-03 17:53:14 +02:00
Monard Vong a63a809e98 fix tests 2019-09-22 00:26:35 +02:00
Monard Vong dfbe9cf7f8 Add integration test 2019-09-22 00:12:54 +02:00
Hugues Alary 4327e9ba24 Resolve relative paths to absolute paths in command line arguments
The executor accepts a few arguments dockerfile, context, cache-dir and
digest-file that all represent paths. This commits allows those paths to
be relative to the working directory of the executor.

Fixes #732 #731 #675
2019-08-27 21:06:26 +00:00
Tejal Desai 4b422ee5dd
Merge pull request #677 from priyawadhwa/git
Improve git buildcontext integration test
2019-08-23 15:03:27 -07:00
Carlos Alexandro Becker 46a738f2b2
fix: integration tests
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
2019-06-22 12:18:42 -03:00
Carlos Alexandro Becker f0b9ad3a57
feat: support specifying branch for cloning
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
2019-06-22 11:45:07 -03:00
Priya Wadhwa e2a4098b8e fixed dockerfile path 2019-06-19 11:06:59 -07:00
Priya Wadhwa 317d1b7017 Improve git buildcontext integration test
Build a dockerfile that will copy the LICENSE from the kaniko github repository into the image to make sure the git buildcontext works as expected.
2019-05-23 16:12:20 +02:00
Kartik Verma f137f81884
Resolved Merge Conflicts
Signed-off-by: Kartik Verma <vkartik97@gmail.com>
2019-05-21 01:52:14 +05:30
Johannes 'fish' Ziemke 8c732f6f52 Fix kaniko caching (#639)
* Revert "Change cache key calculation to be more reproducible. (#525)"

This reverts commit 1ffae47fdd.

* Add logging of composition key back

* Do not include build args in cache key

This should be save, given that the commands will have the args included
when the cache key gets built.
2019-05-10 09:57:03 -05:00
Kartik Verma fa2a2c803b
Updated PR Branch with master 2019-04-09 02:18:28 +05:30
dlorenc c8fabdf6e4
Fix arg handling for multi-stage images in COPY instructions. (#621) 2019-03-22 12:24:43 -05:00
Daisuke Taniwaki 1bf4421047 Fix parent directory permissions (#619)
* Add parent directories of adding files

* Add integration Dockerfile to test parent directory permissions

* Remove unnecessary helper method

* Use a file on the internet for integration Dockerfile
2019-03-19 12:40:15 -05:00
Daisuke Taniwaki 28bfb75a31 Fix file mode bug (#618)
* Fix file mode

* Add Dockerfile for special file permission test
2019-03-18 13:28:24 -05:00
dlorenc 9912ccbf8d
Fix USER handling. There were two issues: (#600)
- We were validating usernames/groupnames existed in etc/passwd. Docker does not do this
- We were incorrectly caching USER commands. This was fixed automatically by fixing the first part.
2019-03-07 07:05:24 -08:00
dlorenc 2abe109eb2
Environment variables should be replaced in URLs in ADD commands. (#580)
We were previously explicitly skipping this for some reason, but Docker
seems to expand these in URLs so we should too.
2019-02-25 10:42:34 -06:00
Priya Wadhwa 8b459b57aa Test git buildcontext 2019-02-21 13:03:02 -08:00
Priya Wadhwa 3da2fdf2d0 Merge branch 'issue#269' of https://github.com/vkartik97/kaniko into vkartik97-issue#269 2019-02-21 11:55:51 -08:00
dlorenc 9047ccf7cc
This fixes a bug in the interaction between volumes in base images (#555)
and our snapshot optimizations.

If a previous base image has a volume, the directory is added to the
list of files to snapshot. That directory may not actually exist in the image.
2019-02-08 14:40:37 -06:00
dlorenc e14b660947
Fix a bug in volume handling for multi-stage images. (#554)
We were previously not resetting the whitelist between stages, this caused issues with volumes.
2019-02-07 09:01:49 -06:00
dlorenc 9f65174cb8
Generate the config.json from gcloud rather than relying on a hardcoded one. (#551)
marketplace.gcr.io now requires auth, but our credential helper doesn't know that.
2019-02-04 16:53:59 -06:00
Kartik Verma 2f8bdd99b7
Resolved Merge Conflicts 2019-02-02 11:28:40 +05:30
Kartik Verma 785691ecc2
Made changes as per review 2019-02-02 11:18:54 +05:30
dlorenc c2514305ef
Fix a bug in snapshotting with multi-stage images. (#546)
We previously had an optimization that would skip snapshotting mutli-stage images
when in an intermediate stage, until the very end.

This conflicted with another optimization to avoid snapshotting when no files had changed.
2019-01-30 13:57:02 -06:00
dlorenc e3bf9fb062
Only log the hour of the benchmark run. (#544)
Also combine all files into one directory.
2019-01-28 15:53:13 -06:00
dlorenc 4c960709df
Actually fix the paths for benchmark uploading during integration test runs. (#543) 2019-01-28 12:52:27 -06:00
dlorenc 1ffae47fdd
Change cache key calculation to be more reproducible. (#525)
Before we were using the full image digest, but that contains a timestamp. Now
we only use the layers themselves and the image config (env vars, etc.).

Also fix a bug in unpacking the layers themselves. mtimes can change during unpacking,
so set them all once at the end.
2019-01-23 13:46:12 -06:00
dlorenc a493035287
Log the output from uploading files to GCS. (#541) 2019-01-23 12:08:04 -06:00
dlorenc a4b47a4992
Fix the time format we use to upload to GCS. (#538) 2019-01-22 14:23:28 -06:00
dlorenc b0e7c0e8cd
Upload benchmarks to GCS. (#523) 2019-01-17 16:10:14 -05:00
dlorenc 6e7c91a1cb
Deflake the daemon test (#532)
There's a race condition here where sometimes we get a layer and othertimes we don't.
2019-01-17 15:30:08 -05:00
dlorenc 48f9968e5b
Move the benchmark files from /workspace to their own mounted volume in tests. (#527)
If we don't do this, they can end up in the built images causing test failures.
2019-01-11 16:04:16 -07:00
dlorenc ddeef6d224
Refactor tests and make them run in parallel. (#499) 2018-12-21 12:17:57 -06:00
dlorenc ec1f78a5c4
Deflake the meta_arg_test by setting a specific timestamp in touch. (#498)
This works around mtime-precision issues that cause us to differ from docker-built images
when the touch command executes too quickly to modify the mtime.

Also one fix in the .travis.yml beacuse something appears to have changed in their default
go installation.
2018-12-20 12:33:12 -06:00
Sharif Elgamal 29b7c3e879
Adding TTL to caching (#488)
* Adding TTL to caching

* uncomment added lines

* cache TTL works for layers now

* remove debugging

* parse booleans correctly

* parse booleans correctly everywhere

* fix boolean parsing condition

* refactor benchmarking calls

* defer file properly
2018-12-13 14:20:25 -08:00
Priya Wadhwa a34ba5c233 Fixed merge conflict 2018-12-11 13:53:19 -08:00
Priya Wadhwa b0b36ed85a Re-add support for .dockerignore file
This PR adds support for the dockerignore file. Previously when kaniko
had support for the dockerignore file, kaniko first went through the
build context and deleted files that were meant to be ignored. This
resulted in a really bad bug where files in user mounted volumes would
be deleted (my bad).

This time around, instead of modifying the build context at all, kaniko
will check if a file should be excluded when executing ADD/COPY
commands. If a file should be excluded (based on the .dockerignore) it
won't be copied over from the buildcontext and shouldn't end up in the
final image.

I also added a .dockerignore file and Dockerfile as an integration test,
which should fail if the dockerignore is not being processed correctly or if files aren't being excluded correctly.
Also, I removed all the integration testing from the previous version of the
dockerignore support.
2018-12-10 15:20:25 -08:00
dlorenc 7611ea7a1d
Add support for COPY --from=<an unrelated image>. (#479)
Right now kaniko only supports COPY --from=<another stage>.
This commit adds support for the case where the referenced image is a remote image
in a registry that has not been used as a stage yet in the build.
2018-12-06 12:44:03 -06:00
Sharif Elgamal 7cde036f44
Add benchmarking code (#448)
* adding benchmarking code

* enable writing to file

* fix build

* time more stuff

* adding benchmarking to integration tests

* compare docker and kaniko times in integration tests

* Switch to setting benchmark file with an env var

* close file at the right time

* fix integration test with environment variables

* fix integration tests

* Adding benchmarking documentation to DEVELOPEMENT.md

* human readable benchmarking steps
2018-11-28 11:54:12 -08:00
Priya Wadhwa e7faec5f0a Skip .dockerignore test 2018-11-26 11:50:57 -08:00
Priya Wadhwa 313250f321 Remove support for .dockerignore
Remove support for .dockerignore file until I can change it to ignore
files in memory instead of deleting them

Refer to #466
2018-11-26 11:11:30 -08:00
priyawadhwa ade42d9105
Merge pull request #461 from priyawadhwa/etc-bug
Only return filepath.SkipDir for directories
2018-11-19 22:15:26 -08:00
Priya Wadhwa 2a359f547c Only return filepath.SkipDir for directories
From the docs on filepath.SkipDir:

> If the function returns SkipDir when invoked on a non-directory file, Walk skips the remaining files in the containing directory

This was causing the bug in #457. Since the file `/etc/hosts` was in the whitelist, when filepath.SkipDir was called the entire etc directory was skipped.

This change only returns filepath.SkipDir on directories.
2018-11-19 15:56:11 -05:00
Priya Wadhwa acd45dc894 fixed digests for integration test 2018-11-19 15:26:02 -05:00
Priya Wadhwa 9d67953ed3 Fix bug in extracting hardlinks
When we execute multistage builds, we store the fs of each intermediate
stage at /kaniko/<stage number> if it's used later in the build. This
created a bug when extracting hardlinks, because we weren't appending
the new directory to the link path.

So, if `/tmp/file1` and `/tmp/file2` were hardlinked, kaniko was trying
to link `/kaniko/0/tmp/file1` to `/tmp/file2` instead of
`/kaniko/0/tmp/file2`. This change will append the correct directory to
the link, and fixes #437 #362 #352 #342.
2018-11-16 16:18:49 -08:00
Kartik Verma b4be847fd2
Rebasing 2018-11-14 12:39:01 +05:30
dlorenc 58b607b4d0
Fix caching for multi-step builds. (#441)
This change fixes that by properly "replaying" the Dockerfile and mutating the config when
calculating cache keys. Previously we were looking at the wrong cache key for each command
when there was more than one.
2018-11-09 12:28:18 -06:00
Sharif Elgamal 224b7e2b41
parse arg commands at the top of dockerfiles (#404)
* parse arg commands at the top of dockerfiles

* fix pointer reference bug and remove debugging

* fixing tests

* account for meta args with no value

* don't take fs snapshot if / is the only changed path

* move metaArgs inside KanikoStage

* removing unused property

* check for any directory instead of just /

* remove unnecessary check
2018-11-06 15:27:09 -08:00
Kartik Verma fdac2fa94c
Resolved merge in README 2018-11-02 19:46:48 +05:30
Kartik Verma b9c678e6f8
Seperate Tests for bucketContextTests and gitRepoTests 2018-11-02 19:35:02 +05:30
Priya Wadhwa 55e6157000 Fix bugs with .dockerignore and improve integration test
I improved handling of the .dockerignore file by:

1. Using docker's parser to parse the .dockerignore and using their
helper functions to determine if a file should be deleted
2. Copying the Dockerfile we are building to /kaniko/Dockerfile so that
if the Dockerfile is specified in .dockerignore it won't be deleted, and
if it is specified in the .dockerignore it won't end up in the final
image
3. I also improved the integration test to create a temp directory with
files to ignore, and updated the .dockerignore to include exclusions (!)
2018-10-31 12:50:23 -07:00
priyawadhwa 6ef616b8b2
Merge pull request #394 from priyawadhwa/ignore
Add support for .dockerignore file
2018-10-30 16:49:04 -07:00
Priya Wadhwa cb0a5e0a18 Fix integration tests 2018-10-30 15:59:50 -07:00
Priya Wadhwa 3fc43f4c73 Add support for .dockerignore file 2018-10-19 09:58:50 -07:00
priyawadhwa 5108ee3ee1
Merge pull request #403 from peter-evans/invalid-root-home
Invalid HOME for root user fix
2018-10-18 10:25:39 -07:00
priyawadhwa f4612404c4
Merge pull request #389 from peter-evans/fix-symlink-extraction
Fix symlink extraction
2018-10-18 10:21:23 -07:00
peter-evans 39d6dc1ce7 Modify integration test for setting root user explicitly 2018-10-18 18:08:34 +09:00
Cyrille Hemidy 38c8c89b6a fix mispell 2018-10-14 00:38:18 +02:00
peter-evans d8beff6f28 Update test for link and file extraction to non-empty dir 2018-10-13 08:04:27 +09:00
Priya Wadhwa adac8d495d Add test dir for ignore files
It seems like .dockerignore deletes files containeed within the file locally upon
docker build, so I created a temporary test dir to make sure the
--ignore flag works. We make sure it exists before building docker and
kaniko for Dockerfile_test_ignore, and then delete it after the builds
have completed.
2018-10-12 12:48:16 -07:00
Priya Wadhwa a572774bbe Add --ignore flag
Added a --ignore flag to ignore packages and files in the build context.
This should mimic the .dockerignore file. Before starting the build, we
go through and delete ignored files from the build context.
2018-10-12 12:09:59 -07:00
Sharif Elgamal effac9dfc3
Persistent volume caching for base images (#383)
* comments

* initial commit for persisent volume caching

* cache warmer works

* general cleanup

* adding some debugging

* adding missing files

* Fixing up cache retrieval and cleanup

* fix tests

* removing auth since we only cache public images

* simplifying the caching logic

* fixing logic

* adding volume cache to integration tests. remove auth from cache warmer image.

* add building warmer to integration-test

* move sample yaml files to examples dir

* small test fix
2018-10-11 13:38:05 -07:00
peter-evans 796b2515a7 Add test for symlink extraction to non-empty dir 2018-10-11 11:18:26 +09:00
Kartik Verma ead210ba6e
Docker Build for Git Integration Test 2018-10-04 22:45:41 +05:30
Kartik Verma a9e7da4cdc
Added Integration Tests 2018-10-02 16:42:11 +05:30
Priya Wadhwa 589197b416 Fix travis @ HEAD
I merged a contributor's PR which modifed the HasFilepathPrefix function
to take an additional argument, but the PR hadn't been rebased. One of the
liting tests in Travis caught this bug.
2018-10-01 14:56:46 -07:00
priyawadhwa 8f0d257134
Merge pull request #334 from peter-evans/fix-volume-cmd
Fix handling of the volume directive
2018-10-01 14:49:33 -07:00
dlorenc e1b0f7732e
Fixes a whitelist issue when untarring files in ADD commands. (#371)
* Fixes a whitelist issue when untarring files in ADD commands.

* Add go-cmp test tool.

* Make the integration test tolerate some file differences.
2018-09-28 11:42:07 -07:00
peter-evans b1e28ddb4f Fix handling of volume directive 2018-09-28 11:16:25 +09:00
Sharif Elgamal 49184c2114 set default HOME env properly (#341)
* set default HOME env properly

* set HOME to / if user is set by uid

* fix test

* continue to skip user_run test

* fix unit test to match new functionality
2018-09-27 07:31:51 -07:00
priyawadhwa 1a13c81be8
Merge pull request #348 from priyawadhwa/entrypoint
Review config for cmd/entrypoint after building a stage
2018-09-26 21:26:42 +01:00
xanonid 59cb0ebec9 Enable overwriting of links (solves #351) (#360)
* Enable overwriting of links (solves #351)

* add integration test to check extraction of images with replaced hardlinks

* Prevent following symlinks during extracting normal files

This fixes #359, #361, #362.
2018-09-26 07:14:35 -07:00
Priya Wadhwa 6c39f29081 Only return stdout when running commands for integration tests
When running container-diff in integration tests, both stdout and stderr were being returned
and unmarshalled into the container-diff json object. If container-diff
was giving any error messages (such as, if it didn't have permissions to
extract a file), this would fail even if ultimately no
differences between the filesystems existed.

I updated the RunCommands to only return stdout and print stderr if the
command fails.
2018-09-25 10:05:11 -07:00
Priya Wadhwa e2ca1152f4 Rename flags and default caching to false
Rename --use-cache to --cache, and --cache to --cache-repo to clarify
what the flags are used for. Default caching to false.
2018-09-24 13:18:42 -07:00
Priya Wadhwa 177bd4f40e Fix typo and update comments 2018-09-17 11:05:57 +01:00
Priya Wadhwa eb7194a165 Fix linting errors 2018-09-13 22:06:38 -07:00
Priya Wadhwa c216fbf91b Add layer caching to kaniko
To add layer caching to kaniko, I added two flags: --cache and
--use-cache.

If --use-cache is set, then the cache will be used, and if --cache is
specified then that repo will be used to store cached layers. If --cache
isn't set, a cache will be inferred from the destination provided.

Currently, caching only works for RUN commands. Before executing the
command, kaniko checks if the cached layer exists. If it does, it pulls
it and extracts it. It then adds those files to the snapshotter and
append a layer to the config history.  If the cached layer does not exist, kaniko executes the command and
pushes the newly created layer to the cache.

All cached layers are tagged with a stable key, which is built based off
of:

1. The base image digest
2. The current state of the filesystem
3. The current command being run
4. The current config file (to account for metadata changes)

I also added two integration tests to make sure caching works

1. Dockerfile_test_cache runs 'date', which should be exactly the same
the second time the image is built
2. Dockerfile_test_cache_install makes sure apt-get install can be
reproduced
2018-09-13 18:32:53 -07:00
Priya Wadhwa da6f099820 Merge branch 'master' of github.com:GoogleContainerTools/kaniko into entrypoint 2018-09-12 16:45:25 -07:00
Priya Wadhwa 7635421ae9 Add t.Helper() call to checkLayers for better error logging 2018-09-11 16:24:21 -07:00
Priya Wadhwa 99ab68e7f4 Replace gometalinter with GolangCI-Lint
gometalinter is broken @ HEAD, and I looked into why that was. During
that process, I remembered that we took the linting scripts from
skaffold, and found that in skaffold gometalinter was replaced with
GolangCI-Lint:

https://github.com/GoogleContainerTools/skaffold/pull/619

The change made linting in skaffold faster, so I figured instead of
fixing gometalinter it made more sense to remove it and replace it with
GolangCI-Lint for kaniko as well.
2018-09-11 13:30:42 -07:00
Priya Wadhwa d923d5ef02 Fix integration test 2018-09-11 10:07:54 -07:00
Priya Wadhwa 5d2d2829d0 Review config for cmd/entrypoint after building a stage
As mentioned in #346, if only ENTRYPOINT is set in a stage then any
CMD inherited from a parent should be cleared.

If both entrypoint and cmd are set then nothing should change.

I added a function and unit test to review the config file after building a stage
which clears out config.Cmd if ENTRYPOINT was declared but CMD wasn't.

I also added an integration test to make sure this works, which should
be tested by the preexisting container-diff --metadata test.
2018-09-10 18:15:51 -07:00
Priya Wadhwa 5bdb87e0e7 Extract filesystem in order rather than in reverse
Extracting the layers of the filesystem in order will make it easier to
extract cached layers and deal with hardlinks.

This PR implements extracting in order and adds an integration tests to
make sure hardlinks are extracted properly.

It also fixes two bugs I found when extracting symlinks:

1. We'd get a "file exists" error when trying to symlink to an existing
file with a whiteout later in the layer tarball
2. We'd get a "file exists" error when trying to create a symlink from a
file that was created in a prior layer (perhaps as a regular file or as
a symlink pointing to someting else)

To fix both of these, we resolve all symlinks in a layer at the end. I
also added logic to delete any existing paths before creating the
symlink.
2018-08-29 15:44:38 -07:00
Christie Wilson 7f64037a8c Separate snapshotting of parent dirs from files
To make the logic a bit more clear, when snapshotting files, the
parent dirs are now snapshotted in a different loop from the files we
are actually trying to snapshot. Unfortunately this loop is nearly
duplicated but I did managed to group some fo the related logic
together:
- A function to check if the file should be snapshotted (e.g. isn't
whitelisted, etc.)
- Created a `Tar` type to handle some of the logic around tar-ing, e.g.
tracking hardlinks and stat-ing files before adding them

One side effect of this is that now when snapshoting the file system,
files will be stat-ed twice.
2018-08-24 16:34:59 -07:00
Christie Wilson 607af5f7a6 Always snapshot files in COPY and RUN commands
Kaniko uses mtime (as well as file contents and other attributes) to
determine if files have changed. COPY and ADD commands should _always_
update the mtime, because they actually overwrite the files. However it
turns out that the mtime can lag, so kaniko would sometimes add a new
layer when using COPY or ADD on a file, and sometimes would not. This
leads to a non-deterministic number of layers.

To fix this, we have updated the kaniko commands to be more
authoritative in declaring when they have changed a file (e.g. WORKDIR
will now only create the directory when it doesn't exist) and we will
trust those files and _always_ add them, instead of only adding them if
they haven't changed.

It is possible for RUN commands to also change the filesystem, in which
case kaniko has no choice but to look at the filesystem to determine
what has changed. For this case we have added a call to `sync` however
we still cannot guarantee that sometimes the mtime will not lag, causing the
number of layers to be non-deterministic. However when I tried to cause
this behaviour with the RUN command, I couldn't.

This changes the snapshotting logic a bit; before this change, the last
command of the last stage in a Dockerfile would always scan the whole
file system and ignore the files returned by the kaniko command. Instead
we will now trust those files and assume that the snapshotting
performed by previous commands will be adequate.

Docker itself seems to rely on the storage driver to determine when
files have changed and so doesn't have to deal with these problems
directly.

An alternative implementation would use `inotify` to track which files
have changed. However that would mean watching every file in the
filesystem, and adding new watches as files are added. Not only is there
a limit on the number of files that can be watched, but according to the
man pages a) this can take a significant amount of time b) there is
complication around when events arrive (e.g. by the time they arrive,
the files may have changed) and lastly c) events can be lost, which
would mean we'd run into this non-deterministic behaviour again anyway.

Fixes #251
2018-08-23 18:23:39 -07:00
Priya Wadhwa d8ae5618af Get absolute path of file before checking whitelist
Issue 291 pointed out that symlink "../proc/self/mounts" in the fedora image wasn't being extracted properly and kaniko was erroring out.
This is because the file path wasn't absolute so kaniko wasn't recognizing it as a whitelisted path.
With this change, we first resolve a path to it's absolute path before checking the whitelist.
2018-08-17 18:29:11 -04:00
priyawadhwa 4e77fa000d
Set default home value (#281)
* Set default home value

* Apply  default home value based on user for run commands

* rename default home function
2018-08-10 12:58:07 -07:00
priyawadhwa 52e9863810
fix add command bug when adding remote URLs (#277) 2018-08-07 17:10:27 -07:00
Andrea Giardini c44c317b00 Environment variables with multiple '=' are not parsed correctly (#278)
* Provide failing test for an env variable with multiple '='

* Environment variables are split only in two parts
2018-08-07 10:22:48 -07:00
Christie Wilson 53b5fb41d2 Don't copy same files twice in copy integration tests (#273)
* Don't copy same files twice in copy integration tests

* Use error from RunCommandWithoutTest
2018-08-03 10:01:29 -07:00
priyawadhwa 954b6129d6
Extract intermediate stages to filesystem (#266)
* WIP

* save and extract stage tarballs if there are dependencies
2018-08-02 09:40:24 -07:00
priyawadhwa 71c83e369c
Only add whiteout files once (#270)
* Only add whiteout files once

* Updated vars
2018-08-01 17:27:20 -07:00
Christie Wilson 57b1159951 Add a bit more context to layer offset failures
In #251 we are investigating test flakes due to layer offsets not
matching, this change will give us a bit more context so we can be sure
which image has which number of layers, and it will also include the
digest of the image, since kaniko always pushes images to a remote repo,
so if the test fails we can pull the digest and see what is up.

Also updated reproducible Dockerfile to be built with reproducible flag,
which I think was the original intent (without this change, there is no
difference between how `kaniko-dockerfile_test_copy_reproducible` and
`kaniko-dockerfile_test_copy` are built.
2018-07-31 15:33:47 -07:00
Christie Wilson b5a4d7636f Pass bucket and repo as args to tests
To allow contributors to run the integration tests with their own GCS
buckets and image repos (since not all contributors will have accesss to
the projects used by the kaniko maintainers) this updates the
integration tests so that these can be provided on the command line.

This allows tests to be run individually, without using `make
integration-test`. Previously, part of the test setup was done
in the shell script (creating the context tarball that is required
for the tests that build images with context). Instead it will be
done in the test iself, so we can use `go test` to run tests
individually if we want to.

If we are running only one individual test, we don't want to build
all of the images, so this commit creates a builder which tracks which
images it has built and can be used by a tests to check if it should
build an image before running, or it will use the images that have
already been built by a previous test.

The name of the context tarball has also been made unique (it includes
the unix timestamp) to avoid potential test flakes if two tests using
the same GCS bucket run simultaneously.
2018-07-31 09:53:59 -07:00
priyawadhwa cac00b9cb2
Add --target flag for multistage builds (#255)
* Add --target flag for multistage builds

* change validate to validateTarget
2018-07-30 09:43:23 -07:00
Balint Pato ba4c7f4b57
Merge pull request #258 from balopat/fix_247_daemons
Kill grandchildren spun up by child processes
2018-07-26 14:49:53 -07:00
balopat 8cad6d0082 reproduced 247 with integration test 2018-07-26 11:16:26 -07:00
priyawadhwa ca5069271c
Fully qualify images in dockerfile tests (#257) 2018-07-25 17:56:17 -07:00
priyawadhwa eb6faa05a0
Save each stage in multistage dockerfiles as a tarball (#244)
* resolve basenames in dockerfile to fix multistage bug

* WIP

* WIP

* Save dockerfile stages as tarballs

* added unit tests

* fix unit tests
2018-07-19 11:27:49 -07:00
priyawadhwa 31b7cd3732
Fix bug in copy command by refactoring whitelist checks (#231)
* Fixed bug

* WIP

* fix unit tests
2018-07-10 08:23:35 -07:00
Christian Jantz 65d7b0a9aa Feature/contextsources (#195)
* added switch to extract different sources as build context

* first rough implementation of aws s3

* added buildcontext package and interface

* added GetBuildContext func to buildcontext.go
added fallback to gcs
renamed GC struct to GCS

* improved the default behavior of build context retrieval

* renamed gc:// to gs:// in order to follow common standards

* renamed struct File to Dir and some cleanup work

* moved context.tar suffix to the buildcontext processors where it is needed

* added buildcontext retrieval as struct variable

added fallback if prefix in bucket specifier is present

* cleanup if structures

* added prefix to s3

* WIP

* Fixed build context bugs

* refactored build context
2018-07-06 06:24:50 -07:00
Priya Wadhwa 28f3ec30c2
update vendored go-containerregistry 2018-06-22 14:45:46 -07:00
Sharif Elgamal a7c82cf6f6
adding reproducible flag (#205)
* adding reproducible test

* newer version of go-containerregistry

* new ImageOptions

* switch reproducible flag to default to false

* small fixes

* update dep
2018-06-22 12:00:44 -07:00
Priya Wadhwa 2adf82cd66
update integration test 2018-06-21 15:27:05 -07:00
Priya Wadhwa b09526bc62 added integration test to check layers 2018-06-14 08:44:49 -07:00
Priya Wadhwa 89c9f15bde Add --single-snapshot flag to snapshot once after the build 2018-06-13 11:22:12 -07:00
Priya Wadhwa 44d7266058
Resolve env replacement for FROM command 2018-06-04 11:51:33 -07:00
Sharif Elgamal 5e6b60f46e
adding metadata tests back to integration tests (#185)
* adding metadata tests back to integration tests and fixing resulting bugs

* fix onbuild and default env

* removing old test files

* adding the ArgsEscaped boolean on CMD commands

* fix onbuild test

* ignore failing test until container-diff is fixed

* code comments

* adding todo to remove uncomment failing test
2018-05-24 11:28:32 -07:00
Priya Wadhwa d6bb88f924
Resolve environment replacement for arg 2018-05-21 14:51:00 -07:00
Sharif Elgamal f8aa88b119
Integration test refactoring (#126)
* integration test refactoring

* config file cleanup

* more test refactoring

* remove debug file

* moving around more files

* fixing up integration tests

* integration tests work

* some housekeeping

* fixing tests

* addressing comments

* debugging

* debugging

* actual debugging

* skip integration tests for travis

* install container-diff before integration tests

* syntax

* make test failures less noisy

* fixing tests

* hopefully fixing CI?

* fixes

* more fixes

* let's actually fix CI

* more testing

* testing

* proper auth

* typos

* adding support for args in integration tests

* formatting

* formatting

* adding support for testing bucket context

* adding bucket test dockerfile

* addressing comments

* syntax
2018-05-15 13:42:35 -07:00