Commit Graph

195 Commits

Author SHA1 Message Date
Sebastiaan van Stijn
b034dc41a2 deprecate pkg/platform and move internal
Functions in this package are only used internally in the daemon for
the `/info` endpoint (Architecture), and as part of `stats` (NumProcs).

I was not able to find external consumers, but deprecating the package
first, so that we can remove / dismantle the package in a follow-up.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-13 15:05:56 +01:00
Sebastiaan van Stijn
7db58fefdc internal/mod: remove redundant capturing of loop vars (copyloopvar)
internal/mod/mod_test.go:62:3: The copy of the 'for' variable "tt" can be deleted (Go 1.22+) (copyloopvar)
            tt := tt
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:15 +01:00
Sebastiaan van Stijn
6a85a13c0a internal/testutils/specialimage: remove redundant capturing of loop vars (copyloopvar)
internal/testutils/specialimage/partial.go:41:3: The copy of the 'for' variable "platform" can be deleted (Go 1.22+) (copyloopvar)
            platform := platform
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:13 +01:00
Sebastiaan van Stijn
b453aa65fa update go:build tags to use go1.22
commit a0807e7cfe configured golangci-lint
to use go1.23 semantics, which alowed linters like `copyloopvar` to lint
using thee correct semantics.

go1.22 now creates a copy of variables when assigned in a loop; make sure we
don't have files that may downgrade semantics to go1.21 in case that also means
disabling that feature; https://go.dev/ref/spec#Go_1.22

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:09 +01:00
Sebastiaan van Stijn
ad8196f48a Merge pull request #48722 from vvoland/c8d-save-addtests
c8d/save: Add tests
2024-11-05 14:35:06 +01:00
Paweł Gronowski
db68a019fd c8d/save: Add tests
Test saving a shallow/partial image

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-10-28 13:23:10 +01:00
jinjiadu
3cc736e95c chore: fix some function names
Signed-off-by: jinjiadu <jinjiadu@aliyun.com>
2024-10-28 18:20:43 +08:00
Sebastiaan van Stijn
61433c2a6e Merge pull request #48774 from thaJeztah/safepath_nits
internal/safepath: log some unhandled errors, and remove workaround for ECI / Sysbox
2024-10-28 10:39:38 +01:00
Sebastiaan van Stijn
75e8f57579 internal/safepath: Join(): remove workaround for ECI / Sysbox
This workaround was added in 9a0cde66ba to
work around an issue on Docker Desktop with ECI (Enhanced Container Isolation)
enabled, which uses the Sysbox runtime under the hood.

A comment was added during review of the PR that added it (see [1]), and the
internal discussion on Slack tracked down the issue to code in [nestybox/sysfs].

That issue was resolved Sysbox EE, and upstreamed to Sysbox CE through
[nestybox/sysbox-fs@9cf74e4], which is part of Sysbox CE v0.6.3, so we
can remove this workaround.

[1]: https://github.com/moby/moby/pull/45687#discussion_r1280867905
[nestybox/sysfs]: 30fd49edbd/process/process.go (L644-L684)
[nestybox/sysbox-fs@9cf74e4]: 9cf74e4cbf

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-27 13:13:55 +01:00
Sebastiaan van Stijn
4b60c68803 internal/safepath: Join(): log some unhandled errors
Similar to the kubernetesSafeOpen function.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-27 13:13:50 +01:00
Sebastiaan van Stijn
5fc5b0574b internal/safepath: kubernetesSafeOpen: explicitly suppress unhandled err
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-27 12:35:47 +01: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
Albin Kerouanton
bb364cc0f3 inte/t/networking: delete veth ifaces before netns
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-10-24 18:18:13 +02:00
Rob Murray
aba8df74a1 Add TestDirectRoutingOpenPorts
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-10-22 14:38:13 +01:00
Rob Murray
3ba06cf6b9 Merge pull request #48593 from robmry/iptables_doc
Internal documentation for iptables rules
2024-10-15 15:41:30 +01:00
Rob Murray
20571e453b Generate iptables documentation
In an integration test - run a daemon, capture iptables, and feed them
to a markdown text/template describing them.

Prep for repeating that, for different network configurations.

Fail the test if the generated markdown differs from a "golden" version.

(So, at-least the golden markdown will need to be updated if the
iptables rules are deliberately changed - hopefully the corresponding
description in the template will also be updated.)

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-10-15 14:02:49 +01:00
Rob Murray
a0a0bbae6c Discard ErrDumpInterrupted and return data after maxRetries
Returning possibly inconsistent data avoids retrying indefinitely, and
matches the behaviour of vishvananda/netlink prior to version 1.2.1, in
which the NLM_F_DUMP_INTR flag was ignored.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-10-15 11:35:23 +01:00
Rob Murray
2f02f456f5 Fix comments
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-10-07 18:32:06 +01:00
Albin Kerouanton
5875b6e8cf inte/networking: test access to published ports from remote host
Along with this new test, a new struct `L3Segment` is introduced to
simulate hosts connected on a same switched network. This struct will
let us test various scenarios where published ports and containers
should or should not be accessible from remote hosts.

The new test introduced, `TestAccessPublishedPortFromRemoteHost`, skips
link-local address as port publishing doesn't work on those addresses
currently. This will be fixed in a future commit.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-10-04 20:09:05 +02:00
Brian Goff
fe09cab7fe Merge pull request #48407 from robmry/48400_netlink_eintr
Retry on EINTR from netlink dump calls
2024-09-16 09:08:53 -07:00
Sebastiaan van Stijn
c2fc1f4a40 internal/opts: SetOpts: invalidate empty option-names
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-16 11:00:06 +02:00
Sebastiaan van Stijn
908bb959e7 internal/opts: SetOpts.Set: remove redundant var assignment
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-16 10:39:20 +02:00
Sebastiaan van Stijn
758cca6036 internal/opts: SetOpts,NamedSetOpts: test for optional value
The value is optional for SetOpts (and NamedSetOpts), and implied
"true" when omitted.

This patch adds a test-case for this.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-16 10:38:32 +02:00
Rob Murray
edaa0eb56d Add linting rules to spot use of un-wrapped netlink functions.
Spot netlink functions that may return EINTR because
network configuration changed during a state dump, and
point at the nlutil wrappers.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-09-15 12:28:58 +01:00
Rob Murray
00bf437d84 Add nlutil functions to retry on netlink EINTR
A recent change to the vishvananda/netlink package exposes
NLM_F_DUMP_INTR in some netlink responses as an EINTR (with
no data).

Retry the requests when that happens, up to five times, before
returning the error. The limit of five is arbitrary, on most
systems a single retry will be rare but, there's no guarantee
that a retry will succeed. So, on a very busy or misbehaving
system the error may still be returned. In most cases, this
will lead to failure of the operation being attempted (which
may lead to daemon startup failure, network initialisation
failure etc).

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-09-15 12:28:58 +01:00
Sebastiaan van Stijn
164cae56ed Merge pull request #48167 from dmcgowan/add-feature-flags-daemon
Add `--feature` to daemon flags
2024-09-12 19:15:19 +02:00
Derek McGowan
f13c08246d Add feature to daemon flags
Signed-off-by: Derek McGowan <derek@mcg.dev>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-12 15:35:15 +02:00
Paweł Gronowski
f143f4ec51 image/save&load: Support Platform parameter
Add `Platform` parameter that allows to select a specific platform to
save/load.

This is a breaking change to the Go client as it changes the signatures
of `ImageLoad` and `ImageSave`.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-09-11 19:44:35 +02:00
Sebastiaan van Stijn
16d686c7bc internal/unix_noeintr: fix godoc for package
Put the comment in the expected format :)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-09 19:32:11 +02:00
Nathan Baulch
59eba0ae13 Fix typos
Signed-off-by: Nathan Baulch <nathan.baulch@gmail.com>
2024-09-06 21:53:09 +10:00
Paweł Gronowski
980275dc90 Merge pull request #48399 from vvoland/c8d-list-nonimage
c8d/list: Don't exclude non-container images
2024-08-29 19:16:23 +02:00
Paweł Gronowski
f4e82e2fb0 c8d/list: Don't exclude non-container images
Before this, the image list would not show images that are not a valid
container image, but could be a valid artifact.

While they're not directly usable by docker, we should still show them
so the user can still discover them and at least be able to delete them.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-08-29 11:56:17 +02:00
Sebastiaan van Stijn
c308bd3e0e internal/cleanups: fix non-constant format string in call (govet)
internal/cleanups/composite_test.go:46:9: printf: non-constant format string in call to (*testing.common).Logf (govet)
        t.Logf(err.Error())
               ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-27 10:23:39 +02:00
Paweł Gronowski
495fab8e66 c8d/list: Add test for total and content size
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-08-14 14:12:22 +02:00
Sebastiaan van Stijn
d0aa3eaccf Migrate to github.com/containerd/platforms module
Switch to use github.com/containerd/platforms module, because containerd's
platforms package has moved to a separate module. This allows updating the
platforms parsing independent of the containerd module itself.

The package in containerd is deprecated, but kept as an alias to provide
compatibility between codebases.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 21:20:29 +02:00
Akihiro Suda
7083f1fb55 Merge pull request #48108 from thaJeztah/internalize_pkg_directory
pkg/directory: deprecate, and move to internal
2024-07-02 15:52:56 +09:00
Sebastiaan van Stijn
efdaca2792 pkg/rootless/specconv: move to internal
This package is only used by the daemon, so move it to the internal
rootless package instead.

Note that technically this could be in daemon/internal, but as there's
already an existing internal/rootless package (which needs to be in the
top-level internal package because it's also used by /plugin), I'm moving
it there.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-01 21:05:19 +02:00
Sebastiaan van Stijn
3a3bb1cb50 pkg/directory: deprecate, and move to internal
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-01 20:44:31 +02:00
Brian Goff
f3d377e422 Merge pull request #48097 from thaJeztah/internalize_containerfs
pkg/containerfs: move to internal
2024-07-01 16:09:48 +00:00
Sebastiaan van Stijn
f2970e5358 pkg/containerfs: move to internal
The only external consumer are the `graphdriver` and `graphdriver/shim`
packages in github.com/docker/go-plugins-helpers, which depended on
[ContainerFS][1], which was removed in 9ce2b30b81.

graphdriver-plugins were deprecated in 6da604aa6a,
and support for them removed in 555dac5e14,
so removing this should not be an issue.

Ideally this package would've been moved inside `daemon/internal`, but it's used
by the `daemon` (cleanupContainer), `plugin` package, and by `graphdrivers`,
so needs to be in the top-level `internal/` package.

[1]: 6eecb7beb6/graphdriver/api.go (L218)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-30 19:13:23 +02:00
Sebastiaan van Stijn
07469b4509 internal: gofumpt
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-27 23:18:48 +02:00
Sebastiaan van Stijn
b2441c7419 Merge pull request #45052 from cpuguy83/attach_fd_leak
Fix attach goroutine/fd leak when no I/O is ready
2024-06-17 13:16:08 +02:00
Albin Kerouanton
1882da852e Merge pull request #47906 from akerouanton/libnet-add-otel-spans-v3
api, daemon, libnet: Create OTel spans at various places
2024-06-14 17:03:56 +02:00
Albin Kerouanton
57c6a5e691 libnet: SetKey: propagate traces from API to SetKey reexec
The `Sandbox.SetKey()` method is called through an OCI prestart hook
which then calls back the daemon through a UNIX socket. This method is
responsible for provisioning interfaces, etc... into the sandbox.

A new EnvironCarrier is used to propagate the trace context to the
prestart hook, which then marhsals an OTel MapCarrier into the JSON
payload sent back to the daemon. That way, every spans created from
`SetKey()` are correctly parented to the original `ContainerStart` API
call.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-06-14 15:25:08 +02:00
Sebastiaan van Stijn
b7d5a42168 Update go:build comments to go1.21
Match the minimum version that's specified on our vendor.mod.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-13 14:59:54 +02:00
Sebastiaan van Stijn
5343c7b451 remove internal/compatcontext and use context instead
This internal package was added in f6e44bc0e8
to preserve compatibility with go1.20 and older. At the time, our vendor.mod
still had go1.18 as minimum version requirement (see [1]), which got updated to go1.20
in 16063c7456, and go1.21 in f90b03ee5d

The version of BuildKit we use already started using context.WithoutCancel,
without a fallback, so we no longer can provide compatibility with older
versions of Go, which makes our compatiblity package redundant.

This patch removes the package, and updates our code to use stdlib's context
instead.

[1]: f6e44bc0e8/vendor.mod (L7)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-13 13:29:39 +02:00
Sebastiaan van Stijn
7f2ed139fe remove uses of platforms.Platform alias
It's an alias for the OCI-spec type, which was only there for
convenience, but will be deprecated.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-11 11:48:01 +02:00
Paweł Gronowski
999f1c63db testutils/specialimage: Add MultiPlatform
Add utility that allows to construct an image with the specified
platforms.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-06-10 13:35:12 +02:00
Brian Goff
2d134c5abd Fix goroutine/fd leak when client disconnects
In cases where the client disconnects and there is nothing to read from
a stdio stream after that disconnect, the copy goroutines and file
descriptors are leaked because `io.Copy` is just blocked waiting for
data from the container's I/O stream.

This fix only applies to Linux.
Windows will need a separate fix.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2024-05-24 21:32:15 +00:00
Paweł Gronowski
ad0f263eb5 tarexport: Plumb ctx, add OTEL spans, handle cancellation
Pass `context.Context` through `tarexport.Load` and `tarexport.Save`.
Create OTEL spans for the most time consuming operations.

Also, handle context cancellations to actually end saving/loading when
the operation is cancelled - before this PR the daemon would still be
performing the operation even though the user already cancelled it.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-05-14 13:08:33 +02:00