Commit Graph

37 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
Adrià Garriga-Alonso 143e69492d
Create intermediate directories in COPY with correct uid and gid (#2795)
* Create directories with the right UID/GID

* Forgot to create the actual directory

* Integration test creation of intermediate files with correct ownership

* ADD version of the test
2023-11-28 10:43:42 -05:00
Quan Zhang b433ddd6bb
fix: fix `COPY` command error due to missing but ignored files (#2812)
Fixes https://github.com/GoogleContainerTools/kaniko/issues/1598.

This commit puts `context.ExcludesFile` before `os.Lstat` to avoid the `COPY` command error due to missing but ignored files.
2023-10-31 13:29:23 -07:00
JeromeJu b6f14ae676
Add test cases and docString for regex in COPY command (#2773) 2023-10-10 08:07:18 -07:00
Aaron Lehmann 32ce1bf67e
Avoid redundant calls to filepath.Clean (#2652)
filepath.Clean shows up in profiles as a hot spot, and there seem to be
many redundant calls, particularly in ignorelist handling. We can avoid
these redundant calls by pre-cleaning entries in the ignore list, and
providing fast paths when we know we're already dealing with a cleaned
candidate path.

Before:

     580ms  3.03% 72.35%      590ms  3.08%  path/filepath.(*lazybuf).append (inline)
     390ms  2.03% 74.39%      990ms  5.16%  path/filepath.Clean

After:

     0.13s  0.69% 84.01%      0.17s  0.91%  path/filepath.(*lazybuf).append (inline)
     0.13s  0.69% 84.70%      0.31s  1.65%  path/filepath.Clean
2023-07-31 17:18:16 -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
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
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
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
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 44b35b28eb remove read succesS 2020-04-30 15:18:39 -07:00
Tejal Desai ffc372a63b refactor to add unit tests 2020-03-23 17:48:49 -07:00
Yoan Blanc 3ff2ee3ba5
copy: unit test for chown
Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
2020-03-17 15:19:00 +01:00
Dani Raznikov c136f886a9 Add support to --chown flag to ADD command 2020-03-14 16:24:40 +02:00
Tejal Desai 9592f2640f more tests similar to docker cp 2020-03-09 15:54:35 -07:00
Tejal Desai c523c691eb revert back to old 0.17.1 behavior 2020-03-06 23:48:31 -08:00
Tejal Desai 8f87267002 fix lint error 2020-03-06 21:37:00 -08:00
Tejal Desai 6c14d202a3 better error wrapping and add more tests for copy 2020-03-06 17:18:36 -08:00
Tejal Desai b4b70d040a wip 2020-03-06 13:08:02 -08:00
Tejal Desai 17f808da8a check for filepath.Walk error everywhere 2020-02-28 04:23:27 -08:00
Tejal Desai 8d9e6b8ea5
Merge pull request #1027 from tejal29/small_refacto
refactor copy.chown code and add more tests
2020-02-07 13:48:05 -08:00
Tejal Desai d94a1ed53b fix linter 2020-02-06 11:40:41 -08:00
Tejal Desai 9dba097a7e refactor and add more tests 2020-02-06 11:40:41 -08:00
Cole Wippern cd9be5d513 reuse cached layer 2020-01-23 16:48:26 -08:00
ohchang-kwon df767bb195 apply code review results 2020-01-21 12:07:13 +09:00
ohchang-kwon d6fe98aa49 Fixed an issue where the image is broken if there are symlink in the destination path when ADD, COPY 2020-01-03 16:28:12 +09: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 2aa481c15e add unit tests for caching run and copy 2019-12-10 09:29:10 -08:00
Cole Wippern 2b26dfea61 Add unit tests for resolveIfSymlink 2019-11-15 11:23:15 -08:00
Don McCasland 27020f23b9
Resolving comments 2019-10-08 12:19:20 -07:00
Don McCasland 2d73c2d996
addressing lint issues 2019-10-07 13:06:40 -07:00
Don McCasland 2eace1d511
Refactoring to add use of a tempdir 2019-10-07 12:56:34 -07:00
Don McCasland 4e1639c030
Addressing review comments 2019-10-07 10:46:28 -07:00
Don McCasland 1bb5a41d7d
Fixing lint issues. Adding tests for COPY command. Fixing issue with copying files out of snapshots 2019-09-16 10:48:31 -07:00
Don McCasland e003bae87d
first commit of copy_test 2019-09-16 10:46:57 -07:00