64 Commits
Author SHA1 Message Date
gVisor bot 86abc85f37 Merge pull request #11473 from Champ-Goblem:shim-add-cgroup-v2-metrics-support
PiperOrigin-RevId: 730560110
2025-02-25 14:52:09 -08:00
Champ-Goblem b602afb764 shim: add support for containerd v2 metrics
Add support for v2 containerd metrics in the shim, v2 metrics are only used when runsc is run with --system-cgroup=true.
Containerd requires v2 metrics when the host is run with CGroupsV2.
This issue was noticed when attempting to gather metrics on AL2023 which defaults to CGroupsV2.

Fixes: #11472
Signed-off-by: Champ-Goblem <cameron@northflank.com>
2025-02-19 11:39:15 +00:00
Jing ChenandgVisor bot 53d6f3dd2a Use github.com/containerd/log in gVisor shim.
The package github.com/containerd/containerd/log is removed in containerd 2.0.

PiperOrigin-RevId: 724255233
2025-02-07 01:42:37 -08:00
Jing ChenandgVisor bot 902a56c6c5 Use github.com/containerd/errdefs in gVisor shim.
The github.com/containerd/containerd/errdefs is deprecated.

PiperOrigin-RevId: 723750415
2025-02-05 19:45:54 -08:00
Lucas ManningandgVisor bot 78827837d4 Update containerd shim to use OOMKill instead of OOM.
The reason for this is outlined in https://github.com/containerd/containerd/commit/7275411ec811f1294e1b3466bc24e963ea90f002.

TL;DR: K8s sets mem limits on the pod cgroup (slice), which means
the scope cgroup (container) gets OOMKilled, not OOMed.

Fixes #9723

PiperOrigin-RevId: 686543615
2024-10-16 09:57:40 -07:00
Koichi Shiraishi 0cf77c02f8 all: remove use io/ioutil deprecated package & fix some deprecated thing
Signed-off-by: Koichi Shiraishi <zchee.io@gmail.com>
2024-10-10 20:36:24 +09:00
Jamie LiuandgVisor bot 41f01d8f9c pgalloc: integrate async page loading
When a pages file is provided to `runsc restore`, reads from that file are
asynchronous (via statefile.AsyncReader) in order to maximize throughput.
However, all such reads must complete before Kernel.LoadFrom() returns, so
applications cannot execute before MemoryFile loading is complete. The main
objective of this CL is to allow reads to continue after Kernel.LoadFrom()
returns, allowing applications to execute while MemoryFile loading is still in
progress. This behavior is user-visible: it affects whether deleting the pages
file frees disk space immediately on POSIX filesystems, may affect whether
deletion is possible on non-POSIX filesystems, and prevents unmounting
regardless. Thus it is flag-guarded as `runsc restore --background`.

MemoryFile ranges that have yet to be loaded, but that are being waited-for by
applications, should be prioritized over ranges for which no application is
waiting. This requires that application requests for data (calls to
MemoryFile.(memmap.File).DataFD/MapInternal()) are able to determine which
ranges have not yet been loaded, request reads for such ranges with elevated
priority, and wait for only those reads to be completed; none of these are
supported by the existing statefile.AsyncReader.

Thus:

- Add //pkg/sentry/pgalloc/aio, which provides an async I/O API that is
  designed to be easily implementable using a goroutine pool, Linux native AIO,
  or io_uring, though only includes a goroutine pool implementation. (io_uring
  is widely disabled due to security vulnerabilities. In my testing, Linux
  native AIO is slower than the goroutine pool, but this may change with lower
  GOMAXPROCS which needs further testing.)

- Move I/O scheduling into pgalloc: introduce an async page loader goroutine
  that is started by MemoryFile.LoadFrom() when async page loading is requested
  (implicitly, via the existence of a pages file), which is responsible for
  driving submission of read requests and handling their completions.

PiperOrigin-RevId: 679321884
2024-09-26 15:51:13 -07:00
Jing ChenandgVisor bot 4a38681600 Upgrade containerd in gVisor, from v1.4.13 to v1.6.36.
PiperOrigin-RevId: 679295130
2024-09-26 14:34:06 -07:00
Ayush RanjanandgVisor bot 18f64502ad Pass --detach to restore command when shim translates start to restore.
runsc start does not attached to the started container. runsc restore OTOH
attaches to the container being restored by default and waits for the container
to exit.

So when the shim converts start -> restore, retain the detach behavior.

Fixes 210e3f6ff3 ("Add restore support to runsc shim.")

PiperOrigin-RevId: 665056022
2024-08-19 17:25:14 -07:00
gVisor bot 005fac84b6 Internal change.
PiperOrigin-RevId: 654943997
2024-07-22 17:04:36 -07:00
210e3f6ff3 Add restore support to runsc shim.
Co-authored-by: Fabricio Voznika <fvoznika@google.com>
PiperOrigin-RevId: 652924874
2024-07-16 11:51:03 -07:00
gVisor bot 704e3289d3 Internal change.
PiperOrigin-RevId: 650297675
2024-07-08 10:36:39 -07:00
Fabricio VoznikaandgVisor bot 7335236040 Add support for shim redirection
This allows the shim to be extended by intercepting calls to the
shim and deciding which one to forward to the runsc shim, and which
to handle in the interception shim.

PiperOrigin-RevId: 645421325
2024-06-21 10:07:08 -07:00
Ayush RanjanandgVisor bot f62a4a77d5 Update go branch to Go 1.21.
Starting with Go 1.21, build tags select the language version. We currently
have several `go:build go1.1` tags, which were intended to act as "true" tags.
But that will break with 1.21. So replace them with "!false".

Fixes #9568.

PiperOrigin-RevId: 576020779
2023-10-23 22:09:47 -07:00
Ayush RanjanandgVisor bot f286d71166 Delete lifecycle mount annotation.
Earlier, NewPodMountHints() was modifying the mount hints based on the
lifecycle. This change moves that annotation modification work to runsc shim.
It is more consistent for the shim to do all OCI spec modification work. Also
added more documentation about how EmptyDir is optimized in runsc.

This also allows us to delete the lifecycle mount annotation as it is no longer
used anywhere else.

PiperOrigin-RevId: 574600949
2023-10-18 14:36:27 -07:00
Ayush RanjanandgVisor bot e77deec462 Use disk-backed tmpfs for disk-backed EmptyDir volumes.
This change lands a performance optimization for EmptyDir volumes in gVisor.

Before this change, EmptyDir volumes were optimized as follows:
- If the EmptyDir had memory medium, then EmptyDir mounts in the containers
  were converted into a shared tmpfs mount in the sentry.
- If the EmptyDir had default medium (was disk backed), then:
  - If only one container in a pod was using this EmptyDir, then the EmptyDir
    mount for that container was converted into an overlay mount, which had a
    gofer lower layer and a tmpfs upper layer (with a file backend). The tmpfs
    was backed by a file from the host EmptyDir mount itself. Such a file
    backend was essential for size limit enforcement to work correctly.
  - If multiple containers were using such an EmptyDir, then we can't optimize
    it with such a "self-backed overlay", because it necessitates a "shared
    gofer", which is not supported yet. So we fell back to slow gofer mounts.

However, the lower gofer layer is useless, because upon pod creation, the
EmptyDir is completely empty. Instead we can use a tmpfs with a file-backend.
This is what this change does. As a consequence, we can now optimize all
configurations of disk-backed EmptyDir volumes.

PiperOrigin-RevId: 574564462
2023-10-18 12:58:01 -07:00
Shambhavi SrivastavaandgVisor bot 34c0fe73ed Updating golang's containerd/runc version 1.1.0
This is required to include the NetworkInterface struct
added in go-runc Stats in commit c321e8cd.

https://github.com/containerd/go-runc/blob/main/events.go

PiperOrigin-RevId: 572366821
2023-10-10 14:28:34 -07:00
guangwuandGitHub a99bf4a8ad fix: successfully typo 2023-09-15 14:47:10 +08:00
Ayush RanjanandgVisor bot 0ca9dbc41c Add self-backed overlay for disk-backed EmptyDir volumes.
This change adds a new mount annotation:
dev.gvisor.spec.mount.{volumeName}.lifecycle: shared | pod | container

For now runsc shim will be setting this annotation for all EmptyDir volumes.
Runsc looks at this annotation can adds a self-backed overlay on top of
EmptyDir volumes that have type=bind and share=container.

runsc gives precedence to mount annotations over --overlay2 configuration.
Added a container test for this feature.

This change also updates MountHint.fileAccessType() to be more generic using
all the available information about a mount.

PiperOrigin-RevId: 530746837
2023-05-09 16:43:39 -07:00
Ayush RanjanandgVisor bot f945fc8d01 Refactor mount annotations code base.
This change groups the following refactor work:
* Use volumeKeyPrefix consistently in shim/utils/volumes.go.
* Export boot.PodMountHints and boot.MountHint.
* Rename MountHint.isSupported() to isShared() to make it more accurate.
* Plumb MountHint more consistently throughout containerMounter methods. We do
  this by calling c.hints.findMount() once and caching the result in a new
  abstraction called `mountInfo` (earlier weirdly named mountAndFD). This also
  helps in avoiding duplicate calls to c.hints.findMount() for the same volume.

This change does not impact behavior. This is in preparation for a following
change that adds overlay on top of disk-backed EmptyDir volumes. The intent is
to reduce clutter from the more important change for ease of review.

PiperOrigin-RevId: 529009982
2023-05-03 00:20:25 -07:00
Adin ScannellandgVisor bot 1ceb814544 Add default_applicable_licenses rules to packages.
PiperOrigin-RevId: 513581243
2023-03-02 10:50:04 -08:00
Konstantin BogomolovandgVisor bot eb98adf08c Pass through panic-log flag to the base runsc cmd, not a subcommand.
Previously this flag was attempted to be passed into the Create subcommand,
which would not accept the flag.

PiperOrigin-RevId: 513028383
2023-02-28 13:48:29 -08:00
Zach KoopmansandgVisor bot 9cf34dd35f Internal Change
PiperOrigin-RevId: 488706692
2022-11-15 11:06:14 -08:00
Kevin KrakauerandgVisor bot d8aa09e04c convert uses of interface{} to any
Done via:
  find . -name "*.go" | xargs sed -i -E 's/interface\{\}/any/g'

PiperOrigin-RevId: 487033228
2022-11-08 13:14:06 -08:00
Konstantin BogomolovandgVisor bot 1faac756ee Add shim support for calling runsc create with --panic-log.
Making the panic log directory be inside of the normal user-log directory makes
it possible to simply reuse the same spec annotation.

PiperOrigin-RevId: 466785655
2022-08-10 14:31:14 -07:00