Commit Graph

64 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
Logan Price 14b2ea5528
feat: ensure images layers correspond with the image media type (#2719)
Ensure zstd compression only gets applied to oci images.
When adding a layer to an image ensure that they are compatable if not convert them.
Create function to convert mediatypes between oci and docker types.
2023-09-13 10:49:56 -07:00
guangwu 382cf3a9c2
chore: unnecessary use of fmt.Sprintf (#2717)
Signed-off-by: guoguangwu <guoguangwu@magic-shield.com>
2023-09-01 09:44:31 -07:00
Logan Price e9787f85d4
fix: ensure layer media type matches image media type if oci image (#2700)
test: add to ensure media type being saved
2023-08-29 10:33:13 -07:00
Kraev Sergei eea12bd025
Fix multistage caching with COPY --from (#2559)
* Removed block on use --cache-copy-layers with multistage builds
* Removed using digest in composite key with command COPY --from
* COPY --from command uses src as file context (only changed files will be reason for change hash)
* ARG and ENV changed before COPY dont change composite key
* Add and fix some tests
* Caching work same as caching in docker buildx

Co-authored-by: Sergei Kraev <skraev@tradingview.com>
2023-06-16 10:56:05 -07:00
Fedor V 90fe22bc2e
fix: paths deduplication while resolving symlinks (#2504)
Closes #2381
2023-05-29 01:37:20 -07:00
Joe Kimmel 906cc96b59
Upgrade docker (#2440)
* somehow now the only thing that doesnt work is devices.Device

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>

* this gets rid of all the compiler errors in the vendored code

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>

* fixed some things but a bunch of tests and maybe some compiler steps are still failing

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>

* all the things i figured out how to fix so far

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>

* guess i had to redo go mods after rebasing again

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>

* update docker constants to be SHOUTY CASE now

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>

* include DestPath in resolveEnv

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>

* fix one mistake in Docker lib upgrade and some typos/deprecations in the file

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>

* last changes (hopefully) to update to new docker libs

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>

---------

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>
2023-03-23 20:34:25 -04:00
Natalie Arellano 4d077e2a40
Provide `--cache-repo` as OCI image layout path (#2250)
* Adds the ability to provide `--cache-repo` as an OCI image layout path

- Adds cache.LayoutCache to implement cache.LayerCache interface
- When opts.CacheRepo has "oci:" prefix, instantiates a LayoutCache

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Add integration test for layout cache

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Updates from PR review

Signed-off-by: Natalie Arellano <narellano@vmware.com>

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-09-28 10:19:02 -04:00
Natalie Arellano 76c0a8c1ec
Add the ability to skip unpacking the initial file system (#2234)
- Adds a new option, InitialFSUnpacked
- When opts.InitialFSUnpacked is true, the first stage builder will
  skip unpacking the file system; later stages are unaffected

Signed-off-by: Natalie Arellano <narellano@vmware.com>

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-09-06 10:21:12 -04:00
Ramy f9dcb92c38
add cache run command option (#2032)
Co-authored-by: Rami CHAABANE <rchaabane@scaleway.com>
2022-08-09 08:35:00 -04:00
Diego Gonzalez 1b59a296a8
Use canonical platform values. Fix 1995. (#2025)
* Use canonical image architectures. Closes #1995.

Prior to this change, Kaniko was not using the platform's canonical value.

* Update platform unit test.
2022-03-31 15:15:24 -04:00
Jason Hall 3589382378
Correctly handle platforms that include CPU variants (#1929)
* Correctly handle platforms that include CPU variants

Prior to this change, Kaniko would only select the platform-specific
image from a multi-platform image using the OS and architecture to
select the image. This leads to problems when there are two platforms
that are indistinguishable using only this information (e.g.,
linux/arm/v5 and linux/arm/v7).

This change more explicitly selects the right image from a
multi-platform image, taking CPU variant into account (v5 vs v7), using
containerd's CPU variant detection logic.

This also moves platform defaulting up as early as possible in execution
as it can go, so that malformed platform values are detected as soon as
possible.

* set platform in unit test
2022-02-10 09:12:23 -08:00
Eng Zer Jun 0adbbee21d
test: use `T.TempDir` to create temporary test directory (#1918)
The directory created by `T.TempDir` is automatically removed when the
test and all its subtests complete.

Reference: https://pkg.go.dev/testing#T.TempDir
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2022-02-07 13:27:34 -05:00
Dawei Ma ee2249b3d5
fix: ARG/ENV used in script does not invalidate build cache (#1688) (#1693) 2021-12-30 12:51:00 -05:00
Janosch Maier 46e01340c2
Remove tarball.WithCompressedCaching flag to resolve OOM Killed error (#1722)
* Remove tarball.WithCompressedCaching flag to resolve OOM Killed error

Large images cannot be build as the kaniko container will be killed due to an OOM error. Removing the tarball compression drastically reduces the memory required to push large image layers. Fixes #1680

This change may increase the build time for smaller images. Therefore a command line option to trigger the compression or a more intelligent behaviour may be useful.

* Add new command line flag to toggle compressed caching

* Add unittest for build with --compressed-caching command line flag set to false
2021-10-19 00:14:06 -07:00
Gilbert Gilb's a42adb9bb4
Fix composite cache key for multi-stage copy command (#1735)
* 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

* Fix composite cache key for multi-stage copy command (#1706)

PR #1518 reintroduced COPY layers caching using the `--cache-copy-layers`
flag. Unfortunately, this PR also introduced a bug by not including the
stage digest into the caching key of the COPY command when the
`--cache-copy-layers` flag was not set. As a result, kaniko would use
any previous (possibly stalled) layer from the cache because the digest
of the "COPY --from" command would never change.

PR author probably expected Go to fallthrough in the switch just like C
does. However, this is not the case. Go does not fallthrough in
switch-statements by default and requires the fallthrough keyword to be
used. Note that this keyword is not available in type-switches though,
because it wouldn't work properly with typings.

* refactor: add an abstract copy command interface to avoid code duplication

* fix typo in error message

Co-authored-by: Tejal Desai <tejal29@gmail.com>
2021-10-18 23:31:01 -07:00
Tejal Desai b04399eeac
add caching copy layers back (#1518)
* add caching copy layers back

* fix test

* lint

* fix test - 2

* Add integration test

* fix lint
2020-12-11 00:25:03 -08:00
Tinjo Schöni 5f4e2f1366
Fix .dockerignore for build context copies in later stages (#1447)
* Extend .dockerignore integration test with copies in later stages

.dockerignore should continue to apply when copying from the build context in later stages, but it currently doesn't

* Replace excluded global with passed along FileContext struct

This new FileContext struct allows much cleaner handling of context specific file exclusions.
The global excluded file state is no longer needed.

Additionally this also fixes the issue where excluded files aren't being applied for build context copies in later build stages.
2020-10-08 12:47:14 -07:00
Ian Kerins 1240333657
Stop caching COPY layers (#1408)
Cached COPY layers are expensive in that they both need to be retrieved
over the network and occupy space in the layer cache.

They are unnecessary in that we already have all resources needed to
execute the COPY locally, and doing so is a trivial file-system
operation.  This is in contrast to RUN layers, which can do
arbitrary and unbounded work.

The end result is that cached COPY commands were more expensive when
cached, not less.  Remove them.

Resolves #1357
2020-09-30 17:18:50 -07:00
Tejal Desai 98a2ee2e34 intoduce delay 2020-06-06 20:52:58 -07:00
Tejal Desai 07cdfcf091 fix tests 2020-06-06 20:28:04 -07:00
Tejal Desai c85d64c8ae better shdTakeSnapshot 2020-06-06 19:49:34 -07:00
Tejal Desai b7462742c1 add deletion logic 2020-06-06 02:05:45 -07:00
Tejal Desai 43338d4b2f add a new run command along with a new flag 2020-06-05 19:53:16 -07:00
Jordan Goasdoue a9c7839491 fix: stages are now resolved correctly if skip-unused 2020-05-04 18:38:18 +02:00
Tejal Desai ee097f9b70 fix unit tests 2020-05-03 22:01:50 -07:00
Tejal Desai d37896b94f
Merge branch 'master' into experiment 2020-05-03 21:02:41 -07:00
Tejal Desai a2af3272cf
Merge pull request #1192 from tp-tc/snapshot-maintainers
Handle `MAINTAINERS` when passing `--single-snapshot`.
2020-05-03 20:45:48 -07:00
Tejal Desai 7d32139a13 fix a bug where file check nil is insufficient 2020-05-01 22:38:14 -07:00
Tom Prince 484d03550c Handle `MAINTAINERS` when passing `--single-snapshot`. 2020-04-13 15:54:27 -06:00
Dani Raznikov f720c817c7 add unit tests 2020-04-12 20:17:40 +03:00
Dani Raznikov 3ab6524fe5 optimize: don't parse Dockerfile twice and just reuse stages 2020-04-03 18:53:22 +03:00
Dani Raznikov a3ce1cebf3 optimize: don't parse Dockerfile twice and just reuse stages 2020-04-03 17:39:59 +03:00
Tejal Desai 9567b755dd fix unit tests 2020-03-25 10:09:33 -07:00
Tejal Desai 2ea28fc7f5 revert back to previous file to save logic 2020-03-25 09:43:59 -07:00
Tejal Desai caaf6c8adf fix tests 2020-03-24 10:50:59 -07:00
Tejal Desai ffc372a63b refactor to add unit tests 2020-03-23 17:48:49 -07:00
Tejal Desai 0302e5150c
Merge pull request #1085 from tejal29/rm_buildargs_from_cache_key
remove build args from composite key and replace all build args
2020-03-17 16:02:59 -07:00
Yoan Blanc 53326fa0bf
executor: add --label flag
Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
2020-03-07 18:17:26 +01:00
Tejal Desai 579ec52a30 add more tests for stageBuilder_build 2020-03-04 17:04:42 -08:00
Tejal Desai b9f4c4bab5 add more tests for stageBuilder_build 2020-03-04 16:57:26 -08:00
Tejal Desai ae5a7bf158 fix tests 2020-02-28 02:53:42 -08:00
Tejal Desai 58c0d47fa6 fix npe 2020-02-28 02:44:43 -08:00
Tejal Desai 2ba7d25090 remove build args from composite key and replace all build args before adding command to the cache 2020-02-28 01:51:31 -08:00
Cole Wippern 782e4916b6 update build and composite cache tests 2020-01-23 15:37:38 -08:00
Cole Wippern 9e9b8a6e71 Fix #899 cached copy results in inconsistent key
* Update cached copy command to return the same result for
files used from context so that cached and uncached copy
commands produce the same cache key
* Update tests for fix
* Add test for cached run command key consistency
2019-12-15 10:23:31 -08:00
Cole Wippern b19214ad1e Use cachekey not digest for COPY --from src
* use the cachekey of the src stage rather than the digest
for COPY --from commands as they are reproducible unlike digests
* track digest to cache keys and stage indexes to digest
* add extra debug logging for troubleshooting cachekey building issues
* convert Sha256 hashes to hex encoded strings rather than plain strings
for easier human reading
2019-12-10 08:45:13 -08:00
Cole Wippern 7b4b768edf Update copy command cache key logic
Include the digest of the stage specified in the --from argument for
COPY commands which use --from
2019-12-09 16:48:20 -08:00
Cole Wippern 7ba65daf7f cleanup executor/build_test.go 2019-11-28 09:36:39 -08:00
Cole Wippern 6d0c8da90e more stagebuilder caching tests 2019-11-28 08:42:13 -08:00