Commit Graph

79 Commits

Author SHA1 Message Date
Manish Giri 7bfc73c3ad
fix: Remove references to deprecated io/ioutil pkg (#2867)
* Update benchmark_test

* Updae tar.go

* Update further refs

* Commit next set of replacements

* Reverting changes in vendor folder

* Update integreation_with_context_test.go

* Update k8s_test.go

* Update remaining usages

* Replace conflicting usage of fs local variable
2023-11-28 13:02:53 -08:00
zhouhaibing089 e65bce193d
snapshotter: use syncfs system call (#2816)
`sync` system call triggers a full page cache sync which may not always
work, especially in kubernetes environment where it is easy to be
interfered by others. I have seen several cases where a broken nfs mount
is blocking kaniko from doing its job.

With `syncfs`, it only writes cache back to disk for the current
filesystem that is used by kaniko which is supposed to be more reliable.
2023-10-30 16:59:40 -07:00
Andreas Fleig 0d925dd651
Don't write whiteout files to directories that were replaced with files or links (#2590)
If a non-empty directory gets replaced with something other than a
directory (e.g. file or symlink), the files in that directory also get
deleted. However, there should not be any whiteout files for them in the
layer. If there were, the resulting tar file would not be extractable.

Fixes #2308
2023-06-22 10:45:47 -07:00
Joël Pepper 14ea7c4071
Fix Integration tests (#2425)
* fix(ci): Bump golangci-lint to 1.51.1

* chore(lint): fix gofmt and goimport issues

* chore(lint): fix linter issues

- Adapted error comparison according to linter recommendation
- Disabled noctx linting for http request where canceling makes no sense
- Disabled nilerror linting where nil error is returned on purpose
- Disabled makezero linter where slice is explicitly deepcopied

* chore(ci): Update go version in tests workflows

* fix(ci): Allow boilerplate years from 2000-2099

Previously the regex only allowed the copyright notice to contain the
years 2018,2019,2020,2021, or 2022. This commit widens to regex to
20\d\d allowing any year in the range [2000-2099]

* feat(ci): Replace minikube with k3s for intregration tests

The existing setup for minikube is very complicated, replicating most of
the setup steps for a full kubernetes cluster in an only partially
supported minikube configuration (driver=none). Furthermore the existing
setup has been broken for sometime, likely, at least in part due to the
changes to CNI and CRI in recent kubernetes versions.

Since what we actually need is only a running Kubernetes cluster on the
node and access to a registry on localhost:5000, we can switch the
extremely complicated minikube setup for a lightweight cluster using
k3s. Minikube came with a default addon for running a registry on every
node, but the same is not the case for k3s, instead we make use of the
package helm controller and its HelmChart CR to deploy twuni/docker-registry.helm
and expose it on localhost using the integrated LoadBalancer controller.

* fix(test-684): pin base container version

The dockerfile for the regression test connected to issue 684 used a
rolling tag as base image, making it flaky and fail since it was
introduced.

This commit pins the base image to the digest of bionic-20200219, which,
based on the date of the commit that introduced to the dockerfile would
be the most newest ubuntu build and likely what the "rolling" tag
resolved to back then. Since this also an image from the pre-oci days of
ubuntu, this circumvents a bug in container-diff as well
(https://github.com/GoogleContainerTools/container-diff/issues/389)
2023-03-21 12:30:54 -04:00
Andreas Fleig bc46c24707
Write parent directories to tar before whiteout files (#2113)
* Write parent directories to tar before whiteout files

Fixes #1149

The OCI image spec does not specify this order but it's a good idea and Docker
does the same.

When manually comparing layers created by Docker and Kaniko there are still
some differences (that container-diff does not show):

* Kaniko adds / to layers
* For `mkdir /test`, docker adds `/test` and an opaque whiteout file
  `/test/.wh..wh..opq`. Kaniko only adds `/test/` (and /).

* snapshot_test: cleanup

Fix typos and use listFilesInTar() where possible
2022-05-31 16:42:32 -04:00
Gabriel Nützi 323e616a67
fix: Refactor `LayersMap` to correct old strange code behavior (#2066)
* fix: Correct flatten function in layers

- Added a test.
- Cache current image, track deletes in `whiteouts` as well as normal adds in `layers`.
- Fix ugly delete behavior of `layerHashCache`.
  Delete it when crerating a new snapshot.
- Slight cleanup in `snapshot.go`.
- Format ugly `WalkFS` function.

* fix: Add symbolic link changes  to Hasher and CacheHasher

* fix: Better log messages

* fix(ci): Integration tests

* fix(ci): Add `--no-cache` to docker builds

* fix(ci): Pass credentials for error integration test

* np: Missing .gitignore in `hack`

* np: Capitalize every log message

- Correct some linting.

* fix: Key function

- Merge only last layer onto `currentImage`.

* fix: Remove old obsolete `cacheHasher`
2022-05-17 20:30:58 -04:00
Gabriel Nützi 76a54a031d
Fix: Flatten layer function needs to return existing files in the layer correctly (#2057)
* fix: Remove hardcoded whiteout prefix

* fix: Flatten function should return all existing files without whiteouts

* np: Documentation
2022-04-26 16:46:09 -04:00
Tejal Desai 1da17b6e9b
chore: add workflows for pr tests (#1766)
* chore: add workflows for pr tests

* fix unit tests

* fix formatting

* chore: fix gobuild

* change minikube script

* chore: fix lint install script

* chore: ignore and fix tests

* fix lint and run gofmt

* lint fixes

* k8s executor image only

* fix Makefile

* fix travis env variables

* more info on k8s tests

* fix travis run

* fix

* fix

* fix

* fix log

* some more changes

* increase timeout

* delete travis.yml and fix multiple copy tests

* fix registry mirror

* fix lint

* add concurency

* last attemot to fix k8 integrations

* diff id for diff workflows
2021-10-18 23:22:44 -07:00
Rhianna b525d1e27b
Support force-building metadata layers into snapshot (#1731)
* feat: add support for forcing build metadata

* Chore: Added snapshot forceBuildMetadata flag tests.
2021-10-18 11:43:51 -07:00
Tejal Desai 094fe52b37
Revert "save snaphots to tmp dir (#1662)" (#1670)
This reverts commit 754253d375.
2021-06-14 12:09:07 -07:00
Patrick Barker 754253d375
save snaphots to tmp dir (#1662) 2021-06-14 12:08:47 -07:00
Josh Chorlton ece215c181
reject tarball writes with no destinations (#1534)
* reject tarball writes with no destinations

* Update pkg/snapshot/snapshot.go

Co-authored-by: Tejal Desai <tejal29@gmail.com>
2021-01-03 10:13:05 -08:00
Tejal Desai 2427b348ac
Merge pull request #1350 from hlubek/bugfix-reproducible-whiteout
Bugfix: Reproducible layers with whiteout
2020-07-28 14:57:28 -07:00
Joe Kutner 29a02b08ff
Move snapshotPathPrefix into a method
This allows the value to be determined on the fly, which supports consumers that use Kaniko snaphot as a library and may need to change the value of config.KanikoDir
2020-07-26 21:46:33 -05:00
Christopher Hlubek 699a4bee32 Bugfix: Reproducible layers with whiteout
When deleting files of previous layers, the whiteout files
were not added to the tar file in a consistent order.

This change adds a stable sorting to the whiteout files and
adds unit tests to check for stable sorting.
2020-07-16 10:56:59 +02:00
Tejal Desai 4ac51ef515 merge 2020-06-06 20:17:17 -07:00
Tejal Desai c85d64c8ae better shdTakeSnapshot 2020-06-06 19:49:34 -07:00
Tejal Desai b9d25dd5db better whiteout logic 2020-06-06 10:50:24 -07:00
Tejal Desai cbf4452fe9 fix snapshot 2020-06-06 10:03:37 -07:00
Tejal Desai ede69f8507 check file changed in loop 2020-06-06 01:24:46 -07:00
Tejal Desai 0f5387960e minimal changes 2020-06-06 00:16:14 -07:00
Tejal Desai 58276274e8 better improvements 2020-06-05 23:44:17 -07:00
Tejal Desai 43338d4b2f add a new run command along with a new flag 2020-06-05 19:53:16 -07:00
Tejal Desai 9c68c9a36c Merge branch 'master' into fix_looping 2020-06-04 13:18:30 -07:00
Tejal Desai cbf3073fda rename whitelist to ignorelist 2020-06-02 15:56:27 -07:00
Tejal Desai 41bc04dc12 add timings for resolving pahts 2020-05-23 14:29:46 -07:00
Tejal Desai 503aad17b7 Fix looping through files twice 2020-05-23 14:24:07 -07:00
Gilbert Gilb's fd8a2d6dd8 Merge branch 'master' into snapshot-directories 2020-03-31 14:25:04 +02:00
Gilbert Gilb's e5585fded8 Always add parent directories of files to snapshots.
During a snapshot, when a file changed and not its parent directories,
the parent directories weren't added to the layer. This is inconsistent
with Docker's behavior which always add parent directories to the layer.
In some edge-cases, it could lead to problems with docker considering
that parent directories where owned by root in forthcoming layers
although they shouldn't (see #1163).

Also, Docker seems to be POSIX compliant regarding the name of
directories in the archive, which always have a slash appended. This
commit also fixes this.

Fixes #1163
2020-03-29 18:25:37 +02:00
Tejal Desai ffc372a63b refactor to add unit tests 2020-03-23 17:48:49 -07:00
Tejal Desai 6c14d202a3 better error wrapping and add more tests for copy 2020-03-06 17:18:36 -08:00
cvgw 965b606720 remove cruft and unneeded loop 2020-02-23 13:38:08 -08:00
cvgw a675ad998a Resolve filepaths before scanning for changes 2020-02-20 09:45:44 -08:00
tinkerborg cc2c9a0663 sort filesToAdd in TakeSnapshot
filesToAdd is sorted in TakeSnapshotFS, but not here. This makes ordering unpredictable within the layer's tarball,
causing the SHA to differ even if layer contents haven't changed
2020-02-06 13:36:21 -05:00
Thomas Bonfort 6b6742fd9d Changle loglevel for whiteouts to debug 2020-01-31 12:02:32 +01:00
Tejal Desai 3e5d0a6334 add unit tests 2020-01-23 11:12:54 -08:00
Tejal Desai bb129e9c88 code review comments 2020-01-22 16:27:06 -08:00
Tejal Desai 478205e5ca fix adding symlinks to FS which do not exists 2020-01-22 15:27:01 -08:00
Tejal Desai f1f7297478 fix tests 2020-01-22 11:47:10 -08:00
Tejal Desai da7e9928e4 Fix Symlinks not being copies across stages 2020-01-22 11:47:10 -08:00
Prashant Arya 85f1a5db00 Merge branch 'master' of https://github.com/GoogleContainerTools/kaniko into log 2019-12-19 03:20:56 +00:00
Cole Wippern 697037cbcf Add unit tests for compositecache and stagebuilder
* add mock types for testing
* enhance error messaging
* add tests
2019-11-27 21:47:00 -08:00
Prashant Arya 857715012f changing log level 2019-11-26 17:52:11 +00:00
priyawadhwa 7adf2fcb50
Merge pull request #714 from MJDSys/reproducible_add
Make container layers captured using FS snapshots reproducible
2019-08-19 14:39:18 -07:00
Taylor Barrella 3422d5572a Misc. small changes/refactoring (#712) 2019-07-23 15:10:22 -07:00
Matthew Dawson 619fc5e59b Make container layers captured using FS snapshots reproducible
When a Dockerfile command requires using the TakeSnapshotFS function,
the resulting layer has a random ordering of files.  This causes the
layer to have a non-deterministic hash defeating the reproducible flag.
Issue #710 appears to document this issue as well.

To fix, always sort the list of files to be added in scanFullFilesystem.
This avoids trying to sort the file list during execution, and takes
almost no time to complete.
2019-07-11 21:58:42 -04:00
Dirk Gustke dd9d081447 this is quite spammy in my multistage build (#640)
.. and as i am surely not the only one, move it down to debug.
2019-04-15 13:22:46 -07: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
Jason Hall faadb2af86 Log "Skipping paths under..." to debug (#571)
This reduces noise in the log output, since it isn't terribly useful to most end users.
2019-02-19 13:54:26 -06:00
dlorenc 8d78db4842
Refactor snapshotting (#561) 2019-02-14 12:14:28 -06:00