Commit graph

46005 commits

Author SHA1 Message Date
Sebastiaan van Stijn
0df38c3e2b
vendor: github.com/opencontainers/runtime-spec v1.1.0-rc.2
release notes: https://github.com/opencontainers/runtime-spec/releases/tag/v1.1.0-rc.2

Additions

- config-linux: add support for rsvd hugetlb cgroup
- features: add features.md to formalize the runc features JSON
- config-linux: add support for time namespace

Minor fixes and documentation

- config-linux: clarify where device nodes can be created
- runtime: remove When serialized in JSON, the format MUST adhere to the following pattern
- Update CI to Go 1.20
- config: clarify Linux mount options
- config-linux: fix url error
- schema: fix schema for timeOffsets
- schema: remove duplicate keys

full diff: https://github.com/opencontainers/runtime-spec/compare/v1.1.0-rc.1...v1.1.0-rc.2

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-30 19:54:38 +02:00
Sebastiaan van Stijn
0ea9305f99
Merge pull request #45423 from thaJeztah/vendor_runc_1.1.7
vendor: github.com/opencontainers/runc v1.1.7
2023-04-30 19:53:31 +02:00
Sebastiaan van Stijn
8d375b44eb
Merge pull request #45435 from thaJeztah/c8d_import_argsescaped
daemon/containerd: containerConfigToOciImageConfig: add ArgsEscaped
2023-04-30 19:51:01 +02:00
Sebastiaan van Stijn
e510abbc8c
daemon/containerd: containerConfigToOciImageConfig: add ArgsEscaped
The OCI image-spec now also provides ArgsEscaped for backward compatibility
with the option used by Docker.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-29 00:20:07 +02:00
Sebastiaan van Stijn
e22758bfb2
Merge pull request #45314 from corhere/graceful-shutdown
cmd/dockerd: gracefully shut down the API server
2023-04-28 23:54:34 +02:00
Brian Goff
dffad6b0b7
Merge pull request #45426 from vvoland/c8d-import-dangling
c8d/import: Don't gc unnamed images
2023-04-28 11:18:55 -07:00
Sebastiaan van Stijn
4e2f000b3c
Merge pull request #45422 from thaJeztah/runc_binary_1.1.7
update runc binary to v1.1.7
2023-04-28 19:57:07 +02:00
Sebastiaan van Stijn
3cad7f99e0
Merge pull request #45431 from laurazard/remove-dangling-pull
c8d: delete dangling image on pull
2023-04-28 19:52:55 +02:00
Sebastiaan van Stijn
04f21d86cf
Merge pull request #43506 from thaJeztah/libnetwork_fix_reexec_defer
libnetwork: processSetKeyReexec() remove defer(), and some refactoring
2023-04-28 19:35:49 +02:00
Laura Brehm
44a6587608
c8d: delete dangling image on pull
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2023-04-28 17:41:56 +01:00
Sebastiaan van Stijn
1e9ebfb00c
libnetwork: inline sendKey() into SetExternalKey()
This function included a defer to close the net.Conn if an error occurred,
but the calling function (SetExternalKey()) also had a defer to close it
unconditionally.

Rewrite it to use json.NewEncoder(), which accepts a writer, and inline
the code.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-28 16:44:54 +02:00
Sebastiaan van Stijn
9d8fcb3296
libnetwork: setKey(): remove intermediate buffer
Use json.NewDecoder() instead, which accepts a reader.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-28 16:44:54 +02:00
Sebastiaan van Stijn
a813d7e961
libnetwork: don't register "libnetwork-setkey" re-exec on non-unix
It's a no-op on Windows and other non-Linux, non-FreeBSD platforms,
so there's no need to register the re-exec.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-28 16:44:54 +02:00
Sebastiaan van Stijn
881fff1a2f
libnetwork: processSetKeyReexec: don't use logrus.Fatal()
Just print the error and os.Exit() instead, which makes it more
explicit that we're exiting, and there's no need to decorate the
error.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-28 16:44:40 +02:00
Sebastiaan van Stijn
e974599593
libnetwork: processSetKeyReexec() remove defer()
Split the function into a "backing" function that returns an error, and the
re-exec entrypoint, which handles the error to provide a more idiomatic approach.

This was part of a larger change accross multiple re-exec functions (now removed).

For history's sake; here's the description for that;

The `reexec.Register()` function accepts reexec entrypoints, which are a `func()`
without return (matching a binary's `main()` function). As these functions cannot
return an error, it's the entrypoint's responsibility to handle any error, and to
indicate failures through `os.Exit()`.

I noticed that some of these entrypoint functions had `defer()` statements, but
called `os.Exit()` either explicitly or implicitly (e.g. through `logrus.Fatal()`).
defer statements are not executed if `os.Exit()` is called, which rendered these
statements useless.

While I doubt these were problematic (I expect files to be closed when the process
exists, and `runtime.LockOSThread()` to not have side-effects after exit), it also
didn't seem to "hurt" to call these as was expected by the function.

This patch rewrites some of the entrypoints to split them into a "backing function"
that can return an error (being slightly more iodiomatic Go) and an wrapper function
to act as entrypoint (which can handle the error and exit the executable).

To some extend, I'm wondering if we should change the signatures of the entrypoints
to return an error so that `reexec.Init()` can handle (or return) the errors, so
that logging can be handled more consistently (currently, some some use logrus,
some just print); this would also keep logging out of some packages, as well as
allows us to provide more metadata about the error (which reexec produced the
error for example).

A quick search showed that there's some external consumers of pkg/reexec, so I
kept this for a future discussion / exercise.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-28 12:52:38 +02:00
Paweł Gronowski
1845a915b0
c8d/import: Don't gc unnamed images
Create dangling images for imported images which don't have a name
annotation attached. Previously the content got loaded, but no image
referencing it was created which caused it to be garbage collected
immediately.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-04-28 09:30:04 +02:00
Tianon Gravi
4597f50deb
Merge pull request #45392 from thaJeztah/filters_inline_and_simplify
inline filters.Args where possible, and use filters.Arg() when constructing
2023-04-27 23:31:59 +00:00
Tianon Gravi
751888979c
Merge pull request #44382 from thaJeztah/client_rewrite
client: defaultHTTPClient() accept URL
2023-04-27 23:27:59 +00:00
Sebastiaan van Stijn
0ffd3225d2
vendor: github.com/opencontainers/runc v1.1.7
release notes: https://github.com/opencontainers/runc/releases/tag/v1.1.7
full diff: https://github.com/opencontainers/runc/compare/v1.1.6...v1.1.7

This is the seventh patch release in the 1.1.z release of runc, and is
the last planned release of the 1.1.z series. It contains a fix for
cgroup device rules with systemd when handling device rules for devices
that don't exist (though for devices whose drivers don't correctly
register themselves in the kernel -- such as the NVIDIA devices -- the
full fix only works with systemd v240+).

- When used with systemd v240+, systemd cgroup drivers no longer skip
  DeviceAllow rules if the device does not exist (a regression introduced
  in runc 1.1.3). This fix also reverts the workaround added in runc 1.1.5,
  removing an extra warning emitted by runc run/start.
- The source code now has a new file, runc.keyring, which contains the keys
  used to sign runc releases.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-27 12:19:33 +02:00
Sebastiaan van Stijn
2d0e899819
update runc binary to v1.1.7
release notes: https://github.com/opencontainers/runc/releases/tag/v1.1.7
full diff: https://github.com/opencontainers/runc/compare/v1.1.6...v1.1.7

This is the seventh patch release in the 1.1.z release of runc, and is
the last planned release of the 1.1.z series. It contains a fix for
cgroup device rules with systemd when handling device rules for devices
that don't exist (though for devices whose drivers don't correctly
register themselves in the kernel -- such as the NVIDIA devices -- the
full fix only works with systemd v240+).

- When used with systemd v240+, systemd cgroup drivers no longer skip
  DeviceAllow rules if the device does not exist (a regression introduced
  in runc 1.1.3). This fix also reverts the workaround added in runc 1.1.5,
  removing an extra warning emitted by runc run/start.
- The source code now has a new file, runc.keyring, which contains the keys
  used to sign runc releases.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-27 12:17:14 +02:00
Sebastiaan van Stijn
f117aef2ea
Merge pull request #45361 from Flowdalic/do-not-check-for-rt-group-sched
check-config.sh: do not check for RT_GROUP_SCHED
2023-04-27 02:04:11 +02:00
Sebastiaan van Stijn
c80f205f86
Merge pull request #45298 from thaJeztah/pkg_pkatform_cleanup
pkg/platform: cleanup, and deprecate OSType
2023-04-27 02:02:41 +02:00
Sebastiaan van Stijn
31bf00d3ec
Merge pull request #44234 from thaJeztah/resolvconf_refactor_step1
libnetwork/resolvconf: some cleaning up and optimisations
2023-04-27 01:22:40 +02:00
Tianon Gravi
3eca54384d
Merge pull request #45291 from thaJeztah/bump_swarmkit
vendor: github.com/moby/swarmkit/v2 v2.0.0-20230406225228-75e92ce14ff7
2023-04-26 22:54:21 +00:00
Sebastiaan van Stijn
79dd264517
Merge pull request #45339 from vvoland/c8d-prune-upstream-gc
c8d/prune: Remove gc.ref labels from configs of deleted images
2023-04-26 22:54:10 +02:00
Sebastiaan van Stijn
56fbbde2ed
libnetwork/resolvconf: fix some minor (linting) issues
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-26 22:49:50 +02:00
Sebastiaan van Stijn
820975595c
libnetwork/resolvconf: improve tests for Build
- Verify the content to be equal, not "contains"; this output should be
  predictable.
- Also verify the content returned by the function to match.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-26 22:49:50 +02:00
Sebastiaan van Stijn
93c7b25ccd
libnetwork/resolvconf: refactor tests for readability
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-26 22:49:50 +02:00
Sebastiaan van Stijn
43378636d0
libnetwork/resolvconf: allow tests to be run on unix
Looks like the intent is to exclude windows (which wouldn't have /etc/resolv.conf
nor systemd), but most tests would run fine elsewhere. This allows running the
tests on macOS for local testing.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-26 22:49:49 +02:00
Sebastiaan van Stijn
73c637ad60
libnetwork/resolvconf: use t.TempDir(), change t.Fatal to t.Error
Use t.TempDir() for convenience, and change some t.Fatal's to Errors,
so that all tests can run instead of failing early.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-26 22:49:49 +02:00
Sebastiaan van Stijn
fc1e698914
libnetwork/resolvconf: fix TestGet() testing wrong path
The test was assuming that the "source" file was always "/etc/resolv.conf",
but the `Get()` function uses `Path()` to find the location of resolv.conf,
which may be different.

While at it, also changed some `t.Fatalf()` to `t.Errorf()`, and renamed
some variables for clarity.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-26 22:49:49 +02:00
Sebastiaan van Stijn
55d18b7db9
libnetwork/resolvconf: use []byte for hash instead of string
After my last change, I noticed that the hash is used as a []byte in most
cases (other than tests). This patch updates the type to use a []byte, which
(although unlikely very important) also improves performance:

Compared to the previous version:

    benchstat new.txt new2.txt
    name         old time/op    new time/op    delta
    HashData-10     128ns ± 1%     116ns ± 1%   -9.77%  (p=0.000 n=20+20)

    name         old alloc/op   new alloc/op   delta
    HashData-10      208B ± 0%       88B ± 0%  -57.69%  (p=0.000 n=20+20)

    name         old allocs/op  new allocs/op  delta
    HashData-10      3.00 ± 0%      2.00 ± 0%  -33.33%  (p=0.000 n=20+20)

And compared to the original version:

    benchstat old.txt new2.txt
    name         old time/op    new time/op    delta
    HashData-10     201ns ± 1%     116ns ± 1%  -42.39%  (p=0.000 n=18+20)

    name         old alloc/op   new alloc/op   delta
    HashData-10      416B ± 0%       88B ± 0%  -78.85%  (p=0.000 n=20+20)

    name         old allocs/op  new allocs/op  delta
    HashData-10      6.00 ± 0%      2.00 ± 0%  -66.67%  (p=0.000 n=20+20)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-26 22:49:47 +02:00
Sebastiaan van Stijn
630fc3839e
libnetwork/resolvconf: simplify hashData() and improve performance
The code seemed overly complicated, requiring a reader to be constructed,
where in all cases, the data was already available in a variable. This patch
simplifies the utility to not require a reader, which also makes it a bit
more performant:

    go install golang.org/x/perf/cmd/benchstat@latest
    GO111MODULE=off go test -run='^$' -bench=. -count=20 > old.txt
    GO111MODULE=off go test -run='^$' -bench=. -count=20 > new.txt

    benchstat old.txt new.txt
    name         old time/op    new time/op    delta
    HashData-10     201ns ± 1%     128ns ± 1%  -36.16%  (p=0.000 n=18+20)

    name         old alloc/op   new alloc/op   delta
    HashData-10      416B ± 0%      208B ± 0%  -50.00%  (p=0.000 n=20+20)

    name         old allocs/op  new allocs/op  delta
    HashData-10      6.00 ± 0%      3.00 ± 0%  -50.00%  (p=0.000 n=20+20)

A small change was made in `Build()`, which previously returned the resolv.conf
data, even if the function failed to write it. In the new variation, `nil` is
consistently returned on failures.

Note that in various places, the hash is not even used, so we may be able to
simplify things more after this.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-26 22:47:23 +02:00
Sebastiaan van Stijn
489543cd25
Merge pull request #45391 from vvoland/windows-flaky-testkillcontainer
integration/TestKillContainer: Bigger timeout on Windows
2023-04-26 17:02:31 +02:00
Sebastiaan van Stijn
8ff481b436
Merge pull request #45393 from vvoland/c8d-fix-panic-imagemanifest
containerd integration: Handle nil container.ImageManifest
2023-04-26 17:02:06 +02:00
Sebastiaan van Stijn
ce3ad31e2e
Merge pull request #45404 from rumpl/fix-buildx-tag-events
Use the image service instead of the reference store for tagging
2023-04-26 16:59:57 +02:00
Cory Snider
12bf850c84 cmd/dockerd: gracefully shut down the API server
As of Go 1.8, "net/http".Server provides facilities to close all
listeners, making the same facilities in server.Server redundant.
http.Server also improves upon server.Server by additionally providing a
facility to also wait for outstanding requests to complete after closing
all listeners. Leverage those facilities to give in-flight requests up
to five seconds to finish up after all containers have been shut down.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2023-04-26 10:57:28 -04:00
Sebastiaan van Stijn
18a0ab6b3b
Merge pull request #45382 from wojiushixiaobai/patch-pty
build(deps): bump github.com/creack/pty from v1.1.11 to v1.1.18
2023-04-26 16:54:03 +02:00
Paweł Gronowski
520aa08d42
c8d/prune: Logging fixes
- Use logrus.Fields instead of multiple WithField
- Split one giant debug log into one log per image

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-04-26 16:40:37 +02:00
Paweł Gronowski
52af6d957e
c8d/prune: Remove gc.ref labels from configs of deleted images
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-04-26 16:40:34 +02:00
Cory Snider
993ca8c6de cmd/dockerd/trap: log to logrus directly
Logging through a dependency-injected interface value was a vestige of
when Trap was in pkg/signal to avoid importing logrus in a reusable
package: cc4da81128.
Now that Trap lives under cmd/dockerd, nobody will be importing this so
we no longer need to worry about minimizing the package's dependencies.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2023-04-26 09:53:01 -04:00
Cory Snider
0f3c5d3893 cmd/dockerd/trap: don't force exit after cleanup
Always calling os.Exit() on clean shutdown may not always be desirable
as deferred functions are not run. Let the cleanup callback decide
whether or not to call os.Exit() itself. Allow the process to exit the
normal way, by returning from func main().

Simplify the trap.Trap implementation. The signal notifications are
buffered in a channel so there is little need to spawn a new goroutine
for each received signal. With all signals being handled in the same
goroutine, there are no longer any concurrency concerns around the
interrupt counter.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2023-04-26 09:51:36 -04:00
Djordje Lukic
a1e1038736
Use the image service instead of the reference store for tagging
The image store sends events when a new image is created/tagged, using
it instead of the reference store makes sure we send the "tag" event
when a new image is built using buildx.

Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
2023-04-26 15:10:01 +02:00
Paweł Gronowski
9fe5ac6614
c8d: Handle nil container.ImageManifest
Don't panic when processing containers created under fork containerd
integration (this field was added in the upstream and didn't exist in
fork).

Co-authored-by: Djordje Lukic <djordje.lukic@docker.com>
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-04-26 14:54:01 +02:00
Sebastiaan van Stijn
214e200f95
Merge pull request #45308 from corhere/libnet/overlay-bpf-ipv6
libnetwork/drivers/overlay: make VNI matcher IPv6-compatible
2023-04-26 14:37:09 +02:00
Sebastiaan van Stijn
2379b49177
Merge pull request #45362 from laurazard/c8d-delete-short-images
c8d: add support for removing images by shortID
2023-04-26 11:34:34 +02:00
Cory Snider
16d5d4b6e1 cmd/dockerd: ignore SIGPIPE using signal.Ignore
The fix to ignore SIGPIPE signals was originally added in the Go 1.4
era. signal.Ignore was first added in Go 1.5.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2023-04-25 17:50:12 -04:00
Brian Goff
0970cb054c
Merge pull request #45366 from akerouanton/fix-docker0-PreferredPool
daemon: set docker0 subpool as the IPAM pool
2023-04-25 11:07:57 -07:00
Sebastiaan van Stijn
801202349a
Merge pull request #45387 from cuishuang/master
fix some comments
2023-04-25 16:31:22 +02:00
Albin Kerouanton
2d31697d82
daemon: set docker0 subpool as the IPAM pool
Since cc19eba (backported to v23.0.4), the PreferredPool for docker0 is
set only when the user provides the bip config parameter or when the
default bridge already exist. That means, if a user provides the
fixed-cidr parameter on a fresh install or reboot their computer/server
without bip set, dockerd throw the following error when it starts:

> failed to start daemon: Error initializing network controller: Error
> creating default "bridge" network: failed to parse pool request for
> address space "LocalDefault" pool "" subpool "100.64.0.0/26": Invalid
> Address SubPool

See #45356.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2023-04-25 15:32:46 +02:00