Commit Graph

462 Commits

Author SHA1 Message Date
frankyang
10e03e595d fix bug that gen layer tar contains duplicated files
Signed-off-by: frankyang <yyb196@gmail.com>
2023-11-22 10:56:03 +08:00
Tonis Tiigi
30a1b0e8b6 cache: set max batch size limit to prune
Avoid keeping the cache manager lock for too long. Note
that prune is already batched based on deletion criteria
and when items become releaseable. This adds extra limit
to make sure it never gets very large.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2023-11-09 17:27:20 -08:00
Yan Song
10695dc0f1 solver: fix nydus force compression for provenance
We found that when exporting an image using the nydus compression type,
the export fails due to the 20s timeout in `func (s *Solver) recordBuildHistory`
of `solver/llbsolver/solver.go`:

```golang
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
defer cancel()
```

This issue occurs from the execution of the `makeProvenance` func, where
the execution of the `NewProvenanceCreator` -> `LoadRemotes` -> `GetRemotes`
process in `solver/llbsolver/solver.go`.

Because nydus compression type can't be mixed with other compression types
by the logic definition in `needsForceCompression` of `cache/compression_nydus.go`,
layers are compressed to the default gzip compression type by the logic in `worker/cacheresult.go`:

```golang
if compressionopt == nil {
  comp := compression.New(compression.Default)
  compressionopt = &comp
  all = false
}
```

Which can lead to the timeout behavior above.

The fixup removes force compression handle for nydus, it need be set by the
export option `--output type=image,compression=nydus,force-compression=true`.

Signed-off-by: Yan Song <imeoer@linux.alibaba.com>
2023-11-01 00:40:27 +00:00
Justin Chadwell
8ba1deb94a vendor: update fsutil to master@f09800878302
Signed-off-by: Justin Chadwell <me@jedevc.com>
2023-10-23 12:48:33 +01:00
fanjiyun.fjy
8e0b816d01 cache: fix cache leak
Signed-off-by: fanjiyun.fjy <fanjiyun.fjy@alibaba-inc.com>
2023-10-19 18:02:17 +08:00
Tõnis Tiigi
3dedf3c5e7 Merge pull request #4336 from TBBle/skip_export_of_empty_caches
Skip export of caches with no layers to OCI structures
2023-10-17 10:10:56 -07:00
Paul "TBBle" Hampson
bf211cf58c Skip export of caches with no layers to OCI structures
These happen when a container image is built using only metadata
actions, and hence does not generate any filesystem changes.

Such a degenerate cache is not interesting, and some OCI registries
reject OCI images with no layers.

Specifically, this only affects the `registry` and `local` exporters.

The `inline` exporter already early-outs in this case with the same
warning, and the `gha`, `s3`, and `azblob` exporters are unchanged.

Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
2023-10-17 17:44:08 +09:00
Paul "TBBle" Hampson
f4d44fd2e0 Correct package name for inline remote-cache source
Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
2023-10-17 17:35:15 +09:00
Justin Chadwell
5a82dd3e8b gateway: restore original filename in StatFile error message
Follow-up to 38040ae03e.

Messages returned by fsutil.Stat are guaranteed to return a PathError
wrapped by a stack trace (since it calls os.Lstat). However, as these
error messages are printed, they include the temporary directory for the
mounted reference which is not useful to the caller.

On an error, we can restore the filename in the PathError to the
requested filename, as also seen in os.DirFS.

Signed-off-by: Justin Chadwell <me@jedevc.com>
2023-10-11 16:40:43 +01:00
Kohei Tokunaga
5dccc0aa85 Ensure layers in the local content store on FileList API
Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2023-09-25 19:38:50 -07:00
Tonis Tiigi
e371069a5a cache: don't skip unlazy without blob check
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2023-09-25 19:38:49 -07:00
Kohei Tokunaga
e3af4fdc80 diff: gzip with custom level should be compressed by BuildKit's differ
Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
2023-09-25 20:59:54 +09:00
Tõnis Tiigi
915d245f67 Merge pull request #4057 from AkihiroSuda/rewrite-epoch
exporter/containerimage: new option: rewrite-timestamp (Apply `SOURCE_DATE_EPOCH` to file timestamps)
2023-09-13 22:58:44 -07:00
Tõnis Tiigi
83b1db2d83 Merge pull request #4187 from goller/fix/stargz-label-panic
fix: check snapshot labels to avoid panic
2023-09-13 22:56:49 -07:00
Akihiro Suda
bf49911c11 go fmt cache/blobs_nolinux.go
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2023-09-14 12:12:53 +09:00
Akihiro Suda
a36dbcf7ff Move cache/converter.go to util/converter/converter.go
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2023-09-14 11:34:21 +09:00
Sebastiaan van Stijn
2d3722e50a migrate to github.com/distribution/reference v0.5.0
The "reference" package was moved to a separate module, which was extracted
from b9b19409cf

Also updating docker/docker, which also switched to this new module;

vendor: github.com/docker/docker 032797ea4bcb (v25.0.0-dev)

full diff: afd4805278...032797ea4b

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-09-05 15:29:27 +02:00
Chris Goller
395e72c52b fix: log context for future debugging
Signed-off-by: Chris Goller <goller@gmail.com>
2023-08-31 08:37:58 -05:00
Chris Goller
16e9893617 fix: check snapshot labels to avoid panic
I saw a panic while using the stargz snapshotter caused
by the labels being nil.

This adds a check to prevent the panic.

Signed-off-by: Chris Goller <goller@gmail.com>
2023-08-29 16:47:18 -05:00
Erik Sipsma
45b19d34ef Improve cache related trace logging.
This adds trace logs to the solver's cache manager to assist debugging
cache misses+hits.

It also replace the LazyStackTrace struct with a function that returns a
stack trace string only if trace level is enabled, an empty string
otherwise. This makes it easier to use with logrus hooks that pass the
fields around to different goroutines without needing to try to "unlazy"
the fields first.

Signed-off-by: Erik Sipsma <erik@sipsma.dev>
2023-08-07 07:25:40 -07:00
Artem Khramov
c415d85fe0 FreeBSD port
Buildkit code is mostly generic enough to support FreeBSD, however
there are some quirks / infrastructural pieces that need to be
addressed for full support, to name some

-    contenthash.NewFromStat attempts to set Devmajor / Devminor for
    regular files, assuming that RDev is zero for regular
    files. Unlike on Linux, it's not the case for FreeBSD.

-    containerdexecutor.Run uses bind mounts for rootfs. Bind mounts
    are not supported in FreeBSD and we should use nullfs instead

-    There is no CI job to run tests on FreeBSD

-    Some dependencies weren't ported

This change ports buildkit to FreeBSD

Signed-off-by: Artem Khramov <akhramov@pm.me>
Co-authored-by: Akihiro Suda <suda.kyoto@gmail.com>
2023-07-28 17:02:53 +03:00
Justin Chadwell
d6bdf7bc54 chore: remove unused blobIDs for nydus compression
Signed-off-by: Justin Chadwell <me@jedevc.com>
2023-07-27 09:40:29 +01:00
Justin Chadwell
f272167c79 nydus: fix missing imports
Signed-off-by: Justin Chadwell <me@jedevc.com>
2023-07-26 16:59:42 +01:00
Akihiro Suda
67f3e79553 Dedupe "containerd.io/uncompressed" constants and literals
Dedupe the several "containerd.io/uncompressed" constants and literals
into `github.com/containerd/containerd/labels.LabelUncompressed`

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2023-07-25 03:02:09 +09:00
Alex Couture-Beil
caa9579cb0 contenthash: data race
Multiple calls to GetCacheContext may occur from multiple threads;
however they should only occur when dealing with an ImmutableRef.
For this case we still need to perform a lock to prevent data race
warnings; however in reality the linkMap will be unused.

Signed-off-by: Alex Couture-Beil <alex@earthly.dev>
2023-07-11 15:56:58 -07:00
Tonis Tiigi
d4bcef42bf improve error handling in ReadFile
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2023-07-06 22:02:11 -07:00
Justin Chadwell
38040ae03e gateway: restore original filename in ReadFile error message
All messages returned by os.Open are guaranteed to return a PathError.
However, as these error messages are printed, they include the temporary
directory for the mounted reference which is not useful to the caller.

On an error, we can restore the filename in the PathError to the
requested filename, as also seen in os.DirFS.

Signed-off-by: Justin Chadwell <me@jedevc.com>
2023-07-05 11:00:22 +01:00
Tonis Tiigi
8ffc03b8f0 move flightcontrol to use generics
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2023-06-28 23:44:05 -07:00
Erik Sipsma
273aeab1d1 cache: add a few more fields to ref trace logs.
The trace logs now also include the pointer value of the ref, which
serves as its "ID" amongst all the refs for the underlying record.

They also now include equal{Mutable,Immutable} IDs, which are otherwise
hard to determine with the Usage API.

Finally, LazyStackTrace now has a MarshalText method which returns the
same value as the existing String method. This allows it to work with
custom logrus hooks that rely on marshaling the fields.

Signed-off-by: Erik Sipsma <erik@sipsma.dev>
2023-05-25 15:38:07 -07:00
Erik Sipsma
dd53dca59c Add trace logs for cache leaks.
Signed-off-by: Erik Sipsma <erik@sipsma.dev>
2023-05-15 16:03:29 -07:00
CrazyMax
a9e8e39bae Merge pull request #3814 from changweige/update-nydus
nydus: update nydus-snapshotter dependency to v0.8.0
2023-05-15 14:00:52 +02:00
Matt Kang
29fd071f09 feedback changes for moby/buildkit #2251
Signed-off-by: Matt Kang <impulsecss@gmail.com>
2023-05-12 16:05:34 -07:00
Kang, Matthew
797156ac89 added import/export support for OCI compatible image manifest version of cache manifest (opt-in on export, inferred on import) moby/buildkit #2251
Signed-off-by: Kang, Matthew <impulsecss@gmail.com>
2023-05-11 09:45:13 -07:00
Tõnis Tiigi
7a5ca71ce6 Merge pull request #3830 from amurzeau/contrib5
overlay: use function to check for overlay-based mounts
2023-05-10 21:56:28 -07:00
Justin Chadwell
6d4901c10b Merge pull request #3847 from thaJeztah/image_spec_1.1.0-rc3 2023-05-10 10:07:23 +01:00
Erik Sipsma
f1223ede9c cache: always release ref when getting size in usage.
Signed-off-by: Erik Sipsma <erik@sipsma.dev>
2023-05-08 09:12:20 -07:00
Sebastiaan van Stijn
647a2b5892 vendor: github.com/opencontainers/image-spec v1.1.0-rc3
full diff: https://github.com/opencontainers/image-spec/compare/3a7f492d3f1b...v1.1.0-rc3

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-05-07 20:54:31 +02:00
Changwei Ge
483e87725e nydus: update nydus-snapshotter dependency to v0.8.0
Nydus-snapshotter/converter does not record image's blobs digest on
nydus image anymore since it is easy to overflow annotations' limiitations
of Containerd. Nydus-snapshotter now relies on Containerd to GC.

Signed-off-by: Changwei Ge <gechangwei@bytedance.com>
2023-05-06 10:24:37 +08:00
Alexis Murzeau
cbd1a73339 overlay: use function to check for overlay-based mounts
Factorize code that check for an overlay mount type by using a function
instead.

This will allow supporting other overlay-based mount types more easily
in the future (for example fuse-overlayfs).

Signed-off-by: Alexis Murzeau <amubtdx@gmail.com>
2023-05-02 10:41:37 +00:00
Bertrand Paquet
fb339763bc Revert "Problem: can't use anonymous S3 credentials"
Signed-off-by: Bertrand Paquet <bertrand.paquet@gmail.com>
2023-04-13 21:50:11 +02:00
CrazyMax
86c3b26413 Merge pull request #3692 from yrashk/patch-1
Problem: can't use anonymous S3 credentials
2023-03-31 10:34:49 +02:00
coryb
a8aa7b200c use bklog.G(ctx) instead of logrus directly
Signed-off-by: coryb <cbennett@netflix.com>
2023-03-15 12:07:44 -07:00
Yurii Rashkovskii
b70350975a Problem: can't use anonymous S3 credentials
When trying to use S3 cache with anonymous credentials (for example, for importing publicly available layers), the cache is not used.

Solution: enable anonymous credentials

According to the API documentation:

"If using the `NewFromConfig` constructor you'll need to explicitly set
the `Credentials` member to nil, if the external config resolved a
credential provider."

Signed-off-by: Yurii Rashkovskii <yrashk@gmail.com>
2023-03-13 04:41:27 -07:00
Tõnis Tiigi
eb7080c5c4 Merge pull request #3697 from AkihiroSuda/fix-3098
rootless: support Bottlerocket OS
2023-03-10 18:36:59 -08:00
Akihiro Suda
2fed51aea3 rootless: fix up unprivileged mount opts
Port https://github.com/moby/moby/blob/v23.0.1/daemon/oci_linux.go#L430-L460

> // Get the set of mount flags that are set on the mount that contains the given
> // path and are locked by CL_UNPRIVILEGED. This is necessary to ensure that
> // bind-mounting "with options" will not fail with user namespaces, due to
> // kernel restrictions that require user namespace mounts to preserve
> // CL_UNPRIVILEGED locked flags.

Fix issue 3098

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2023-03-09 21:09:58 +09:00
Akihiro Suda
98deacf59c go.mod: github.com/containerd/containerd v1.7.0-rc.3
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2023-03-09 15:07:22 +09:00
Yan Song
39bd8c6cf5 fix a possible panic on cache
```
newDesc.Annotations = nil
for _, k := range addAnnotations {
  newDesc.Annotations[k] = desc.Annotations[k]
}
```

The codes may cause buildkitd panic: assignment to entry in nil map

Signed-off-by: Yan Song <imeoer@linux.alibaba.com>
2023-02-24 11:39:57 +00:00
Tõnis Tiigi
0ad8d61575 Merge pull request #3109 from ktock/reuseremotelayers
Fix cache cannot reuse lazy layers
2023-02-14 16:51:41 -08:00
Tonis Tiigi
488791a5a1 gha: avoid range requests with too big offset
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2023-02-10 19:23:39 -08:00
CrazyMax
82949ae6cc Merge pull request #3607 from crazy-max/remotecache
remotecache: small enhancements
2023-02-10 19:15:58 +01:00