Commit Graph

476 Commits

Author SHA1 Message Date
Sebastiaan van Stijn
bd20bfdc41 all: remove redundant import-aliases for "go-winio"
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-05 12:11:30 +02:00
Sebastiaan van Stijn
021dd75bc4 libcontainerd: remove // import comments
These comments were added to enforce using the correct import path for
our packages ("github.com/docker/docker", not "github.com/moby/moby").
However, when working in go module mode (not GOPATH / vendor), they have
no effect, so their impact is limited.

Remove these imports in preparation of migrating our code to become an
actual go module.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-30 15:59:14 +02:00
Matthieu MOREL
f06c450a8e libcontainerd: replace uses of errdefs package
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-05-28 05:40:24 +00:00
Sebastiaan van Stijn
152db74d96 libcontainerd: remove/rename err-returns
Prevent accidentally shadowing these errors, which are used in defers.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-08 14:33:09 +02:00
Sebastiaan van Stijn
d8a5e8928b replace uses of idtools.MkdirAllAndChown, MkdirAllAndChownNew
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-09 12:04:42 +02:00
Paweł Gronowski
df519e9e1a daemon: Fix giving up too early while connecting to containerd socket
Explicitly set the gRPC connection params to take the timeout into
account to workaround the containerd v2 client not passing down the
stack.

containerd v2 replaced usages of deprecated gRPC functions but didn't
pass the timeout to the actual dial connection options.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-03-07 19:03:40 +01:00
Sebastiaan van Stijn
ca114a1851 Merge pull request #49544 from thaJeztah/fix_windows_errors
fix some errors for windows containers
2025-03-03 12:33:31 +01:00
Sebastiaan van Stijn
b301c34b92 libcontainerd/local: remove arg-names for stubs
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-26 19:00:20 +01:00
Sebastiaan van Stijn
12f89cc19b libcontainerd/local: NewClient: remove unused cli, stateDir, ns args
The "local" client does not use containerd, but implements the same interface,
many args are not used though, so remove these to make it more clear what's
actually in use.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-26 19:00:20 +01:00
Sebastiaan van Stijn
620f26e1e3 libcontainerd/local: client.createWindows: remove unused runtimeOptions
The "local" client does not use containerd, but implements the same interface,
many args are not used though, so remove these to make it more clear what's
actually in use.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-26 19:00:20 +01:00
Sebastiaan van Stijn
9c4e10126e libcontainerd/local: client.NewContainer: use early return
Also remove an intermediate var, and remove a "WithError" in favor of
adding the error field to the "WithFields".

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-26 19:00:20 +01:00
Sebastiaan van Stijn
7c1a2301f0 libcontainerd/local: client.extractResourcesFromSpec: use early return
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-26 19:00:20 +01:00
Sebastiaan van Stijn
fdd534d2ca libcontainerd: windows: return errdefs type for pausing
Noticed this log in CI on Windows,  which wasn't clear if it was an error
in Windows or in Docker;

    2025-02-25T03:21:35.9273942Z [Error] Handler for POST /v1.48/containers/1713bc845f9bde79aa0017c16613fbfc8810b3272b31dbb2535d3fb1a3550f9c/pause returned error: cannot pause container 1713bc845f9bde79aa0017c16613fbfc8810b3272b31dbb2535d3fb1a3550f9c: Unimplemented: not implemented

Looks like it's a feature that's not implemented when using process-isolation,
so updating the error-message to make it more identifiable as an error
produced by us.

I kept the type to be a "not implemented", which will be converted to a
501 HTTP status (so still logged as error); alternatively, we could make
this a "invalid parameter".

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-25 17:53:25 +01:00
Sebastiaan van Stijn
0fad8324a8 libcontainer/supervisor: monitorDaemon: move options inline again
These were moved in 84965c0752

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-17 22:54:19 +01:00
Sebastiaan van Stijn
29ce3633e5 libcontainerd/supervisor: remove grpc options that are the default
The default message size is set unconditionally in containerd's client,
so unlike Dial-options, there's no risk of implicitly dropping these
options.

TThis patch removes the options, as they were the same as the default
already set in containerd itself.

https://github.com/containerd/containerd/blob/v1.7.22/client.go#L133-L138

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-17 22:54:19 +01:00
Derek McGowan
0aa8fe0bf9 Update to containerd v2.0.2, buildkit v0.19.0-rc2
Update buildkit version to commit which uses 2.0

Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-01-15 14:09:30 +01:00
Sebastiaan van Stijn
ad860173a2 vendor: github.com/containerd/containerd v1.7.25
full diff: https://github.com/containerd/containerd/compare/v1.7.24...v1.7.25

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-10 13:10:42 +01:00
Paweł Gronowski
3db72b255d pkg/sysinfo: Deprecate NumCPU
Deprecate in favor of `runtime.NumCPU` as the behavior is the same now.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-01-09 13:39:49 +01:00
Sebastiaan van Stijn
05ec732667 libcontainerd/supervisor: remove uses of deprecated system.MkdirAll
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-21 14:33:04 +01:00
Paweł Gronowski
90fef061ec daemon/c8d: Force c8dimages alias for containerd/images
Change all github.com/containerd/containerd/images imports to be
imported as `c8dimages`.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-12-19 18:39:43 +01:00
Sebastiaan van Stijn
31fc7dd750 libcontainer: ReplaceContainer: fix var shadowing import
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-16 16:35:44 +01:00
Paweł Gronowski
e1dd1c5d1d Merge pull request #47955 from CharityKathure/windows-containerd-as-managed-process
Windows: Run containerd as managed process
2024-11-15 10:20:18 +00:00
Sebastiaan van Stijn
4768d680d1 libcontainerd/remote: remove redundant capturing of loop vars (copyloopvar)
pkg/idtools/idtools_unix_test.go:188:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:11 +01:00
Charity Kathure
84965c0752 Windows: Run containerd as managed process
Signed-off-by: Charity Kathure <ckathure@microsoft.com>
Co-authored-by: Olli Janatuinen <olli.janatuinen@gmail.com>
2024-11-06 21:04:31 +03:00
Sebastiaan van Stijn
5c48736863 remove redundant alias for runtime-spec
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-26 18:31:39 +02:00
Sebastiaan van Stijn
abcb9e972b libcontainerd/supervisor: set log-level through the config-file
The config.logLevel field, when set, is used to set the `--log-level`
flag when starting the managed `containerd` binary. This flag is the
equivalent to setting the `Config.Debug.Level` field, as can be seen
in the [`md/containerd/command.setLogLevel()`][1] function.

As we're already producing a generated containerd configuration file,
and this file already includes `Debug` options, we might as well include
the option in that file, instead of using the `--log-level` flag.

For entertainment of whoever reads this commit-message, it's worth noting
that previously we were writing this option to the config-file, and
yours truly removed that part in b6b0b0a05f,
but to my defence, we were _also_ setting the `--log-level` flag at the
time :)

[1]: https://github.com/containerd/containerd/blob/v1.7.20/cmd/containerd/command/main.go#L348-L357

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-20 15:58:48 +02:00
Sebastiaan van Stijn
7e864f163c Merge pull request #48353 from thaJeztah/libcontainer_consolidate_defaults_step1
libcontainerd/supervisor: consolidate platform-specific defaults
2024-08-20 14:43:05 +02:00
Sebastiaan van Stijn
62bcc6ef50 libcontainerd/supervisor: consolidate platform-specific defaults
Commit a0009345f5 updated the default
MaxRecvMsgSize and MaxSendMsgSize for Linux, but did not modify the
defaults for Windows. Those options should not be platform-specific,
which means that the only difference between the Linux and Windows
config are the addresses for GRPC and Debug (Windows defaulting
to a named pipe, whereas Linux sockets within exec-root).

This patch

- implements functions to return the default addresses for each platform
- moves the defaults into `supervisor.Start()`
- removes the now redundant `remote.setDefaults()` method

It's worth noting that prior to this path, `remove.setDefaults()` would
be applied _after_ any (custom) `DaemonOpt` was applied. However, none of
the existing `DaemonOpt` options currently mutates these options. `remote`
is also a non-exported type, so no external implementations can currently
be created. It is therefore safe to set these defaults before options are
applied.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-19 13:03:34 +02:00
Akihiro Suda
f49fad75eb vendor.mod: github.com/microsoft/hcsshim v0.12.5
https://github.com/microsoft/hcsshim/compare/v0.11.7...v0.12.5

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2024-08-18 04:38:57 +09:00
Sebastiaan van Stijn
96762a28c7 libcontainerd/supervisor: remove remnants of adjusting oom-score
In docker versions before v24.0, the dockerd daemon allowed adjusting
its own oom-score; in that case we would forward the configuration to
containerd (when running as child process) for it to do the same.

This feature was deprecated in 5a922dc162,
and removed in fb96b94ed0, but some fields
were left behind in the supervisor package.

This patch removes the oomScore field and adjustOOMScore method from
the remove type.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-29 16:34:16 +02:00
Sebastiaan van Stijn
080a8e1b6b libcontainerd: gofumpt
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-27 23:18:49 +02:00
Albin Kerouanton
6c71ebd82c libcontainerd: Start: add ctx
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-06-14 15:25:07 +02:00
Albin Kerouanton
2d8c4265c7 libcontainerd: NewTask: add ctx
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-06-14 15:25:07 +02:00
Laura Brehm
49ca0d0d03 otel: remove deprecated usages of otelgrpc
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2024-06-07 14:35:51 +01:00
Sebastiaan van Stijn
86f7762d48 vendor: github.com/containerd/containerd v1.7.18
Update to containerd 1.7.18, which now migrated to the errdefs module. The
existing errdefs package is now an alias for the module, and should no longer
be used directly.

This patch:

- updates the containerd dependency: https://github.com/containerd/containerd/compare/v1.7.17...v1.7.18
- replaces uses of the old package in favor of the new module
- adds a linter check to prevent accidental re-introduction of the old package
- adds a linter check to prevent using the "log" package, which was also
  migrated to a separate module.

There are still some uses of the old package in (indirect) dependencies,
which should go away over time.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-05 09:21:00 +02:00
huang-jl
da643c0b8a libcontainerd: change the digest used when restoring
For current implementation of Checkpoint Restore (C/R) in docker, it
will write the checkpoint to content store. However, when restoring
libcontainerd uses .Digest().Encoded(), which will remove the info
of alg, leading to error.

Signed-off-by: huang-jl <1046678590@qq.com>
2024-02-27 20:17:31 +08:00
Sebastiaan van Stijn
c516804d6f vendor: OTEL v0.46.1 / v1.21.0
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-02-23 10:11:07 +01:00
Cory Snider
dd20bf4862 libcontainerd/supervisor: fix data race
The monitorDaemon() goroutine calls startContainerd() then blocks on
<-daemonWaitCh to wait for it to exit. The startContainerd() function
would (re)initialize the daemonWaitCh so a restarted containerd could be
waited on. This implementation was race-free because startContainerd()
would synchronously initialize the daemonWaitCh before returning. When
the call to start the managed containerd process was moved into the
waiter goroutine, the code to initialize the daemonWaitCh struct field
was also moved into the goroutine. This introduced a race condition.

Move the daemonWaitCh initialization to guarantee that it happens before
the startContainerd() call returns.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2024-02-01 15:53:18 -05:00
Cory Snider
659d7b190f libcontainerd: create unstarted tasks
Split task creation and start into two separate method calls in the
libcontainerd API. Clients now have the opportunity to inspect the
freshly-created task and customize its runtime environment before
starting execution of the user-specified binary.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2024-01-10 13:50:26 -05:00
Sebastiaan van Stijn
54fcd40aa4 Merge pull request #46227 from thaJeztah/supervisor_ignore_errs
libcontainerd/supervisor: explicitly ignore process kill errors
2023-11-22 08:40:45 +01:00
Cory Snider
29ac09ee9d Revert "libcontainerd: work around exec start bug in c8d"
The workaround is no longer required. The bug has been fixed in stable
versions of all supported containerd branches.

This reverts commit fb7ec1555c.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2023-11-06 13:26:44 -05:00
Sebastiaan van Stijn
cff4f20c44 migrate to github.com/containerd/log v0.1.0
The github.com/containerd/containerd/log package was moved to a separate
module, which will also be used by upcoming (patch) releases of containerd.

This patch moves our own uses of the package to use the new module.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-10-11 17:52:23 +02:00
Sebastiaan van Stijn
3614749b55 Merge pull request #45966 from neersighted/buildkit_0.12
Update to BuildKit 0.12
2023-09-22 02:13:15 +02:00
Bjorn Neergaard
fd6dd6935b vendor: github.com/containerd/containerd v1.7.6
The DeepEqual ignore required in the daemon tests is a bit ugly, but it
works given the new protoc output.

We also have to ignore lints related to schema1 deprecations; these do
not apply as we must continue to support this schema version.

Signed-off-by: Bjorn Neergaard <bjorn.neergaard@docker.com>
2023-09-21 14:18:40 -06:00
Bjorn Neergaard
0e80073e01 daemon: strongly type containerd log.OutputFormat
This type was introduced in
0a79e67e4f

Make use of it throughout our log-format handling code, and convert back
to a string before we pass it to the containerd client.

Signed-off-by: Bjorn Neergaard <bjorn.neergaard@docker.com>
2023-09-21 05:40:17 -06:00
Sebastiaan van Stijn
3bd3cdd82e Merge pull request #46476 from vvoland/libcontainerd-windows-reap-fix
libcontainerd/windows: Fix cleanup on `newIOFromProcess` error
2023-09-18 15:06:56 +02:00
Sebastiaan van Stijn
96faee9762 libcontainer: client.processEventStream: use locally scoped variables
- use local variables and remove some intermediate variables
- handle the events inside the switch itself; this makes all the
  switch branches use the same logic, instead of "some" using
  a `continue`, and others falling through to have the event handled
  outside of the switch.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-09-17 14:29:54 +02:00
Sebastiaan van Stijn
bd523abd44 remove more direct uses of logrus
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-09-15 20:12:27 +02:00
Paweł Gronowski
0937aef261 libcontainerd/windows: Don't reap on failure
Synchronize the code to do the same thing as Exec.
reap doesn't need to be called before the start event was sent.
There's already a defer block which cleans up the process in case where
an error occurs.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-09-14 11:11:33 +02:00
Paweł Gronowski
b805599ef6 libcontainer/windows: Remove unneeded var declaration
The cleanup defer uses an `outErr` now, so we don't need to worry about
shadowing.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-09-14 11:10:40 +02:00