Commit Graph

21 Commits

Author SHA1 Message Date
Cole Wippern 776fa43eb2 refactor cache.Warm and add tests 2020-01-10 12:29:17 -08:00
Cole Wippern b1b0513c05 Fix #926 cache warmer and method signature 2020-01-10 12:29:16 -08:00
Nao YONASHIRO cbba7cec3f chore: fix typo 2019-12-21 14:44:12 -08:00
Cole Wippern a6e458caf1 Update error handling and logging for cache
Previously we returned a low level file system error when checking for
a cached image. By adding a more human friendly log message and explicit
error handling we improve upon the user experience.
2019-11-22 14:54:38 -08:00
tralexa 75083a0c55
Merge branch 'master' into master 2019-09-16 15:58:17 +03:00
Sharif Elgamal 56eeaf41e6
Merge pull request #452 from sharifelgamal/cache-fix
Create cache directory if it doesn't already exist
2019-08-02 13:41:38 -07:00
Sharif Elgamal 8a24115b6a
Prevent panic on nil image 2019-08-02 13:25:20 -07:00
v.rul 7750094ec1 Add checking image presence in cache prior to downloading it
This changes allow to use kaniko-warmer multiple times without unnecessary docker image downloads.
To check image presence in cache directory I'm using existing cache function that is used by kaniko-executor.
I've considered building separate function to only check image presence, but it will have pretty much the same code.
Questionable decision is to embed CacheOptions type to KanikoOptions and WarmerOptions. Probably this should be resolved by creating interface providing needed options and implement it both mentioned structs. But I've struggled to get a meaningfull name to it.
To replicate previous behaviour of downloading regardless of cache state I've added --force(-f) option.

This changes provides crucial speed-up when downloading images from remote registry is slow.

Closes #722
2019-07-24 18:09:21 +03:00
tralexa 66a052255f
Insecure is now honored 2019-06-02 12:24:22 +03:00
Taylor Barrella 5c0603a967 Update go-containerregistry
Resolves #607

* Deleted a duplicate Gopkg.lock block for github.com/otiai10/copy to
  prevent `dep ensure` from deleting it from vendor/

* Searched for breaking changes. Only found ones for
  remote.Delete/List/Write/WriteIndex. Searched for those and fixed

* Noticed that NewInsecureRegistry was deprecated and replaced it
2019-05-25 15:56:20 -07:00
dlorenc 378a3f9573
Look for manifests in the local cache next to the full images. (#570)
Calculating a manifest from a v1.tarball is very expensive. We can
store those locally as well, and use them if they exist.

This should eventually be replaced with oci layout support once that exists
in ggcr.
2019-02-19 13:54:41 -06:00
Fredrik Lönnegren 1b54bda32e Fix typo 2019-02-19 16:43:20 +01:00
Daisuke Taniwaki f8f59ea4c6 Add insecure-registry and tls-skip-verify-registry flags (#537) 2019-01-29 13:29:47 -06:00
dlorenc fcd1976d3b
Make the Digest calculation faster for locally-cached images. (#534)
Right now when we find a v1.Tarball in the local disk cache, we
recompute the digest. This is very expensive and redundant, because
we store tarballs by their digest and use that as a key to look them up.
2019-01-22 13:28:21 -06:00
dlorenc 996bec885f
Refactor our credential fetching to only get k8s credentials if we are on k8s. (#522) 2019-01-11 11:36:43 -07: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
dlorenc 52a6ce6685
More cache cleanups: (#397)
- move the layer cache to an interface
- refactor the DockerCommand implementations to support Cached and non-cached implementations.
2018-11-01 09:11:21 -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
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 f7ba67ea25 Specify cache key to differentiate cache layers 2018-09-14 09:53:03 -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