Commit Graph

256 Commits

Author SHA1 Message Date
Priya Wadhwa d923d5ef02 Fix integration test 2018-09-11 10:07:54 -07:00
Priya Wadhwa e300101579 Fix linting error 2018-09-04 13:50:57 -07:00
Priya Wadhwa 4f3ab61b96 Add CacheCommand to DockerCommand interface
CacheCommand returns true if the command should be cached. Currently,
it's only true for RUN but can be added to ADD/COPY later on (these are
different since the contents of files for ADD/COPY need to be included
in the cache key generation).

I also changed CreatedBy to String so that we can log each command
before cache extraction or regular execution takes place.
2018-09-04 13:16:05 -07:00
Priya Wadhwa 7080a8dd69 Add specific files from tar archives to list of snapshotted filesa
I changed UnpackLocalTarArchive to return a list of files that were
extracted, so that the list of snapshotted files for ADD is more
accurate. Previously, we used to add all files in the extracted dir to
be snapshotted, but this could result in preexisting files being
snapshotted again.
2018-08-27 13:44:39 -07:00
Priya Wadhwa 9a93f5bad9 Snapshot only specific files for COPY
Before #289 was merged, when copying over directories for COPY kaniko
would get a list of all files at the destination specified and add them
to the list of files to be snapshotted. If the destination was root it
would add all files. This worked because the snapshotter made sure the
file had been changed before adding it to the layer.

After #289, we changed the logic to add all files snapshotted to a layer
without checking if the files had been changed. This created the bug in
got all the files at root and added them to the layer without checking
if they had been changed.

This change should fix this bug. Now, the CopyDir function returns a
list of files it copied over and only those files are added to the list
of files to be snapshotted.

Should fix #314
2018-08-27 11:39:00 -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
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
Dale Tristram 2261adca68 Ensure cmd.SysProcAttr is set before modifying it (#275) 2018-08-07 10:09:49 -07:00
dlorenc 8a2492d241
Fix process group handling. (#271)
Also add a makefile target to build the debug image.
2018-08-01 16:47:32 -07:00
Nick Kubala e45d1f6aac
Update deps 2018-07-31 16:23:23 -07:00
balopat 6fe9ea4248 fixes #247 killing grandchildren processes 2018-07-26 13:56:19 -07:00
Jon Johnson 8b0a1a7689 dep update go-containerregistry 2018-06-03 00:59:34 +00: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
Maximilian Schrupp b6cb74b2be include stderr of RUN commands in log output (#187) 2018-05-17 07:47:59 -07:00
priyawadhwa cde277c374
Merge pull request #141 from priyawadhwa/multistage
Support multi stage builds
2018-05-14 15:41:18 -07:00
Christian Jantz fbe3e05801 WIP: Feature/healthcheck signal (#177)
* added basic healthcheck implementation

* updated go-containerregistry version

* added build args parameter to healthcheck execute

* added go-containerregistry HealthCheck passing

* dereferenced health for conversion
2018-05-14 14:28:24 -07:00
Priya Wadhwa 459ddffb3c
Updated tests 2018-05-11 16:19:33 -07:00
Priya Wadhwa 282f8abbee
Merge master, refactor to work with ARG 2018-05-11 15:53:11 -07:00
Priya Wadhwa 4de14c34dd
Wrap BuildArgs in our own type 2018-05-11 10:23:13 -07:00
Priya Wadhwa 33f4805f62
Merged master, fixed merge conflict 2018-05-10 13:51:23 -07:00
Priya Wadhwa 347ce66a9b
Merged master, fixed merge conflict 2018-05-09 13:50:33 -07:00
Priya Wadhwa 26d8501489
Support BuildArgs for arg command 2018-05-09 12:24:38 -07:00
Priya Wadhwa f5b8457405
Add shell command to commands.go 2018-05-09 12:01:05 -07:00
Priya Wadhwa 7fbc21ec73
Merged master, fixed merge conflict 2018-05-07 09:14:17 -07:00
Priya Wadhwa 67a3727eba Merge branch 'master' of github.com:GoogleContainerTools/kaniko into multistage 2018-05-01 11:29:51 -04:00
Christian Jantz dbdbee035d Merge branch 'master' into feature/cmd_stopsignal 2018-05-01 12:54:55 +02:00
Christian Jantz d63bc6da4b set fixed index for resolvedEnv slice on environment replacement - will always be len 1 2018-05-01 12:29:57 +02:00
Christian Jantz b5e68f4b7b added signal validation 2018-05-01 12:12:36 +02:00
Christian Jantz 5af3645a83 added shell command (#158)
* added shell command input to commands prepending shell

* Added shell command and test
2018-04-30 10:59:10 -07:00
Christian Jantz 281c69c6c6 Revert "added shell command input to commands prepending shell"
This reverts commit bccc664b19.
2018-04-28 17:43:42 +02:00
Christian Jantz 35b5f4b34a Revert "Added shell command and test"
This reverts commit ae47a03023.
2018-04-28 17:43:34 +02:00
Christian Jantz fd8d4b6170 added test for stopsignal command implementation 2018-04-28 17:41:40 +02:00
Christian Jantz d73f8c031f added stopsignal implementation 2018-04-28 17:30:18 +02:00
Christian Jantz ae47a03023 Added shell command and test 2018-04-28 15:12:04 +02:00
Christian Jantz bccc664b19 added shell command input to commands prepending shell 2018-04-28 15:02:33 +02:00
Priya Wadhwa 904575d0cb
support multi stage builds 2018-04-26 15:40:41 -07:00
dlorenc cd5b744904
Switch from containers/image to go-containerregistry (#140)
* Vendor changes for go-containerregistry switch.

* Manual changes for go-containerregistry switch.

The biggest change is refactoring the tarball unpacking.

* Pull more of container-diff out.

* More vendor removals.

* More unit tests.
2018-04-25 19:21:05 -07:00
Priya Wadhwa a211c1ec71
Make sure to snapshot parent directories of specific files for add/copy 2018-04-24 16:22:37 -07:00
Priya Wadhwa be38696c7d Updated unit tests after refactor 2018-04-19 20:39:29 -07:00
Priya Wadhwa 6054d7e653 Refactor copy and add
Refactor copy and add

Add/copy pass integration tests
2018-04-19 20:27:41 -07:00
priyawadhwa 55557ff2e1
Merge pull request #112 from priyawadhwa/maintainer
Skip maintainer command
2018-04-18 10:46:17 -07:00
priyawadhwa 1b2d6bf4f6
Merge pull request #114 from r2d4/makefil
Org rename
2018-04-17 15:34:34 -07:00
Matt Rickard cff201dee6 org rename from GoogleCloudPlatform to GoogleContainerTools 2018-04-17 11:45:39 -07:00
Cyrille Hemidy 6e5ed87633
Update add.go
fix comment
2018-04-17 10:57:03 +02:00
Cyrille Hemidy 44a97ae53f
Update run.go
fix comment
2018-04-17 10:52:35 +02:00
Priya Wadhwa 6548835db5
skip maintainer command 2018-04-16 14:21:37 -07:00
dlorenc 0438539cbc
Set env at command run time instead of in the process. (#91) 2018-04-15 18:05:21 -07:00
priyawadhwa cebb4031b3 copy symlinks (#90) 2018-04-14 08:00:20 -07:00
dlorenc da1eab7251
Set a user-agent for registry pushes. (#87) 2018-04-13 14:25:58 -07:00
Priya Wadhwa a8ecbbd365
Check if config fields are nil 2018-04-13 14:00:05 -07:00
Priya Wadhwa ec510a161b
change imports from k8s-container-builder to kaniko 2018-04-12 15:35:54 -07:00
Priya Wadhwa cf90bd73d4
Fixed merge conflict 2018-04-11 15:05:12 -07:00
Sharif Elgamal ce2b515d49
adding VOLUME command (#62)
* adding VOLUME command

* proper test project

* general fixes

* fixing project name

* fixing volume unit test

* fixing integration test

* adding tests

* adding util test

* fixing test

* actually create the volume mounted directory

* fix test
2018-04-06 12:02:57 -07:00
Priya Wadhwa 59a5950e9e
onbuild integration test 2018-04-05 09:43:52 -07:00
Priya Wadhwa 27f964957b
Support for onbuild and unit test 2018-04-04 17:06:01 -07:00
Priya Wadhwa 32b067af0c
Merged master, fixed conflict 2018-04-04 14:06:38 -07:00
sharifelgamal 7ebc313974 Merge branch 'master' of github.com:GoogleCloudPlatform/k8s-container-builder into user-cmd 2018-03-30 13:43:56 -07:00
sharifelgamal da0231a4d1 adding support of env variable replacement 2018-03-30 10:13:35 -07:00
Priya Wadhwa 687e00e3aa Fixed merge conflict 2018-03-29 20:50:52 -07:00
sharifelgamal abc85905c0 adding necessary functions 2018-03-29 12:54:00 -07:00
sharifelgamal b315cf1049 adding user command to switch 2018-03-29 11:54:51 -07:00
sharifelgamal bc78e2b838 adding USER command 2018-03-29 11:53:31 -07:00
Priya Wadhwa 89400b7410
Add command with unit tests 2018-03-28 13:34:00 -07:00
priyawadhwa 976afd1992
Merge pull request #47 from priyawadhwa/env-replacement
Support environment replacement in expose/copy/env
2018-03-28 13:14:56 -07:00
Priya Wadhwa 1b3b8accab
Fixed merge conflict 2018-03-28 12:47:19 -07:00
Priya Wadhwa ad17811c39
Update workdir to use default escape token 2018-03-27 15:15:55 -07:00
Priya Wadhwa 416c58e956
Merge branch 'env-replacement' of github.com:priyawadhwa/k8s-container-builder into workdir 2018-03-27 15:14:59 -07:00
Priya Wadhwa e885d6a5e6
Use default token for env replacement parsing 2018-03-27 09:51:36 -07:00
Priya Wadhwa 6eced4b12d
Merge branch 'master' of github.com:GoogleCloudPlatform/k8s-container-builder into env-replacement 2018-03-27 09:44:59 -07:00
Priya Wadhwa b64f23b078
Use default token for parsing 2018-03-27 09:44:51 -07:00
Priya Wadhwa 54a53489b2
Added comment to unit test 2018-03-26 16:56:28 -07:00
Priya Wadhwa 316e2847a7
Fixed merge conflict 2018-03-26 15:51:00 -07:00
Priya Wadhwa 41aed3948b
Merged master, fixed merge confict 2018-03-26 14:57:57 -07:00
Sharif Elgamal f38dd2d85b
Merge pull request #44 from sharifelgamal/label-cmd
adding LABEL command
2018-03-26 14:28:56 -07:00
sharifelgamal 96b0b12bc7
adding extra test case 2018-03-26 14:13:20 -07:00
sharifelgamal 4551bd0dc0
adding test for escaped words 2018-03-26 11:45:59 -07:00
sharifelgamal 986074eb45
unescaping values when appropriate 2018-03-26 11:38:43 -07:00
Priya Wadhwa 0787a93372
Workdir command and unit tests 2018-03-26 11:37:50 -07:00
Priya Wadhwa f6139f249a
Merge branch 'master' of github.com:GoogleCloudPlatform/k8s-container-builder into env-replacement 2018-03-26 10:50:23 -07:00
Priya Wadhwa dbb0774778
Environment replacement 2018-03-21 15:01:21 -07:00
sharifelgamal f352583bc1
boilerplate 2018-03-21 11:45:41 -07:00
sharifelgamal ba77ba0822
adding LABEL command 2018-03-21 11:34:37 -07:00
Priya Wadhwa cf24231121
WIP 2018-03-20 17:15:09 -07:00
Priya Wadhwa 8d85fe91f3
resolve merge conflict 2018-03-20 15:17:08 -07:00
sharifelgamal 7bc750d793
add check for valid protocol 2018-03-20 14:27:58 -07:00
Priya Wadhwa bf47ea928b
Integration tests for entrypoint 2018-03-20 13:05:20 -07:00
Priya Wadhwa d49c7c5ed1
Entrypoint command and unit tests 2018-03-20 12:58:38 -07:00
sharifelgamal 58ce938778
things are working now 2018-03-20 10:56:19 -07:00
Priya Wadhwa 5da78632a1
CMD command and unit tests 2018-03-20 10:40:45 -07:00
sharifelgamal 5578e683a1
Merge branch 'master' of github.com:GoogleCloudPlatform/k8s-container-builder into expose-cmd 2018-03-19 17:26:30 -07:00
sharifelgamal 288ac0b93b
adding EXPOSE command 2018-03-19 17:25:12 -07:00
Priya Wadhwa b3ec877b60
Use io.Copy when creating files 2018-03-19 16:37:12 -07:00
Priya Wadhwa 5ba9510ee8
Fixed merge conflict 2018-03-19 11:08:07 -07:00
Priya Wadhwa 070b0517d5
Get escape token by parsing ENV command 2018-03-19 10:42:40 -07:00
Priya Wadhwa f4e9eeb15a
Modified fs util functions 2018-03-19 09:47:51 -07:00
Priya Wadhwa de8cc1a285
Fixed check srcs function and create file with correct permissions 2018-03-16 14:11:06 -07:00
Priya Wadhwa f33e507018
Replaced shlex with dockerfile/shell package 2018-03-16 12:20:50 -07:00
Priya Wadhwa 5ebf156d94
Fixed relative filepath and unit test 2018-03-15 13:47:40 -07:00
Priya Wadhwa 21a9207428
Copy command and unit tests 2018-03-14 17:06:46 -07:00
Priya Wadhwa 2d65be548a
Added env unit test, updated env integration test, fixed env 2018-03-12 15:18:15 -07:00
Priya Wadhwa ab0fc3802e
Add ENV command 2018-03-09 13:47:18 -08:00
Priya Wadhwa 27b09f28be
Add config as point to ExecuteCommand, fix snapshots 2018-03-09 11:30:35 -08:00
Priya Wadhwa 75e7e47b76
Added integration test, minor changes to files 2018-03-08 11:49:56 -08:00
Priya Wadhwa 04cca43ce4
Merged master and fixed merge conflicts 2018-03-08 10:18:04 -08:00
Priya Wadhwa cefb4448b1
Integration tests for run cmd 2018-03-07 15:34:56 -08:00