Commit graph

46924 commits

Author SHA1 Message Date
Albin Kerouanton
d7fb4dd170
integration: Extract stream demultiplexing from container.Exec
The original code in container.Exec was potentially leaking the copy
goroutine when the context was cancelled or timed out. The new
`demultiplexStreams()` function won't return until the goroutine has
finished its work, and to ensure that it takes care of closing the
hijacked connection.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2023-08-02 10:23:31 +02:00
Sebastiaan van Stijn
95bbbc0418
Merge pull request #46110 from thaJeztah/libnetwork_dead_code
libnetwork: remove some dead code, and un-export internal functions
2023-08-01 00:57:34 +02:00
Sebastiaan van Stijn
97daeb0020
Merge pull request #46131 from akerouanton/libnet-bridge-errors
Improve libnet/d/bridge errors
2023-08-01 00:15:21 +02:00
Albin Kerouanton
e2d400bea9
libnet/d/bridge: Inline InvalidLinkIPAddrError
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2023-07-31 21:33:02 +02:00
Albin Kerouanton
6df4a00bb9
libnet/d/bridge: Remove pointless BadRequestError impl
IPv4AddrNoMatchError and IPv6AddrNoMatchError are currently implementing
BadRequestError. They are returned in two cases, and none are due to a
bad user request:

- When calling daemon's CreateNetwork route, if the bridge's IPv4
  address or none of the bridge's IPv6 addresses match what's requested.
  If that happens, there's a big issue somewhere in libnetwork or the
  kernel.
- When restoring a network, for the same reason. In that case, the
  on-disk state drifted from the interface state.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2023-07-31 21:32:00 +02:00
Albin Kerouanton
7c13985fa1
libnet/d/bridge: Inline InvalidIPTablesCfgError
This error can only be reached because of an error in our code, so it's
not a "bad user request". As it's never type asserted, no need to keep
it around.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2023-07-31 21:30:46 +02:00
Albin Kerouanton
d8f42ee21a
libnet/d/bridge: Inline IPTableCfgError
This error is only used in defensive checks whereas the precondition is
already checked by caller. If we reach it, we messed something else. So
it's definitely not a BadRequest. Also, it's not type asserted anywhere,
so just inline it.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2023-07-31 21:30:20 +02:00
Sebastiaan van Stijn
a40d00c421
libnetwork: remove ErrDataStoreNotInitialized
If was not used as a sentinel error, so inline the error.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-31 21:00:33 +02:00
Sebastiaan van Stijn
66b379785e
libnetwork: remove unused InvalidContainerIDError
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-31 21:00:33 +02:00
Sebastiaan van Stijn
d8cd4f6421
libnetwork: remove unused UnknownEndpointError
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-31 21:00:33 +02:00
Sebastiaan van Stijn
fc5c16f491
libnetwork: remove unused NetworkTypeError
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-31 21:00:33 +02:00
Sebastiaan van Stijn
e9f1888560
libnetwork: remove unused ErrInvalidConfigFile
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-31 21:00:32 +02:00
Sebastiaan van Stijn
eadaaa7f79
libnetwork: remove unused ErrNoContainer
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-31 21:00:32 +02:00
Sebastiaan van Stijn
99ab11bb90
libnetwork: remove unused ErrInvalidJoin
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-31 21:00:32 +02:00
Sebastiaan van Stijn
9174eb00e2
libnetwork: remove unused ErrInvalidNetworkDriver
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-31 21:00:32 +02:00
Sebastiaan van Stijn
7c2665298a
libnetwork/types: move GetMinimalIP to overlay-driver and un-export
It was only used in drivers/overlay, and was not a function for any
"type" defined by libnetwork.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-31 21:00:32 +02:00
Sebastiaan van Stijn
d9b7a5f01a
libnetwork/types: remove ErrInvalidProtocolBinding
It was not used as a sentinel error, and didn't carry a specific type,
which made it a rather complex way to create an error.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-31 21:00:32 +02:00
Sebastiaan van Stijn
4445169cb5
libnetwork/types: remove PortBinding.Equal
It was only used in tests, so move it to a utility in the tests.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-31 21:00:26 +02:00
Sebastiaan van Stijn
4269712d06
libnetwork/types: remove unused UUID type
This type was added moved to the types package as part of a refactor
in 778e2a72b3
but the introduction of the sandbox API changed the existing API to
weak types (not using a plain string);
9a47be244a

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-31 20:57:48 +02:00
Sebastiaan van Stijn
c203171ef6
libnetwork/types: remove unused RetryError and TimeoutError
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-31 20:57:45 +02:00
Albin Kerouanton
6d37ab0a83
libnet/d/bridge: Change interface implemented by error types
- InvalidIPTablesCfgError: implement InternalError instead of
  BadRequestError. This error is returned when an invalid iptables
  action is passed as argument (ie. none of -A, -I, or -D).
- ErrInvalidDriverConfig: don't implement BadRequestError. This is
  returned when libnetwork controller initialization pass bad driver
  config -- there's no call from an HTTP route.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2023-07-31 19:17:09 +02:00
Albin Kerouanton
03db2f8c3d
libnet/d/bridge: Remove unused error types
These error types are removed:

- ErrInvalidContainerConfig
- ErrInvalidPort
- ErrInvalidAddressBinding
- InvalidSandboxIDError
- IPv4AddrRangeError

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2023-07-31 19:17:09 +02:00
Sebastiaan van Stijn
7baab8bd6c
Merge pull request #46118 from thaJeztah/bump_containerd_1.6.22
vendor: github.com/containerd/containerd v1.6.22
2023-07-31 13:13:51 +02:00
Sebastiaan van Stijn
4d674897f3
vendor: github.com/containerd/containerd v1.6.22
- full diff: https://github.com/containerd/containerd/compare/v1.6.21...v1.6.22
- release notes: https://github.com/containerd/containerd/releases/tag/v1.6.22

---

Notable Updates

- RunC: Update runc binary to v1.1.8
- CRI: Fix `additionalGids`: it should fallback to `imageConfig.User`
  when `securityContext.RunAsUser`, `RunAsUsername` are empty
- CRI: Write generated CNI config atomically
- Fix concurrent writes for `UpdateContainerStats`
- Make `checkContainerTimestamps` less strict on Windows
- Port-Forward: Correctly handle known errors
- Resolve `docker.NewResolver` race condition
- SecComp: Always allow `name_to_handle_at`
- Adding support to run hcsshim from local clone
- Pinned image support
- Runtime/V2/RunC: Handle early exits w/o big locks
- CRITool: Move up to CRI-TOOLS v1.27.0
- Fix cpu architecture detection issue on emulated ARM platform
- Task: Don't `close()` io before `cancel()`
- Fix panic when remote differ returns empty result
- Plugins: Notify readiness when registered plugins are ready
- Unwrap io errors in server connection receive error handling

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-30 15:59:52 +02:00
Sebastiaan van Stijn
935c04f33a
Merge pull request #46117 from thaJeztah/bump_gotest_tools
vendor: gotest.tools/v3 v3.5.0
2023-07-30 15:59:33 +02:00
Akihiro Suda
975031bfcb
Merge pull request #46107 from thaJeztah/update_image_spec
vendor: github.com/opencontainers/image-spec v1.1.0-rc4
2023-07-30 11:07:00 +09:00
Akihiro Suda
5919a2944a
Merge pull request #46102 from thaJeztah/update_containerd_binary_1.7.3
update containerd binary to v1.7.3
2023-07-30 11:05:07 +09:00
Sebastiaan van Stijn
a908460adb
Merge pull request #46043 from thaJeztah/cleanup_iptables_the_firewall_strikes_back
libnetwork/iptables: cleaning up: "there's more where that came from"
2023-07-29 22:12:48 +02:00
Sebastiaan van Stijn
ce053a14aa
vendor: gotest.tools/v3 v3.5.0
- go.mod: update dependencies and go version by
- Use Go1.20
- Fix couple of typos
- Added `WithStdout` and `WithStderr` helpers
- Moved `cmdOperators` handling from `RunCmd` to `StartCmd`
- Deprecate `assert.ErrorType`
- Remove outdated Dockerfile
- add godoc links

full diff: https://github.com/gotestyourself/gotest.tools/compare/v3.4.0...v3.5.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-29 19:51:21 +02:00
Sebastiaan van Stijn
077208287b
Merge pull request #46106 from thaJeztah/fix_filter_errors
api/types/filters: fix errors not being matched by errors.Is()
2023-07-29 03:20:01 +02:00
Sebastiaan van Stijn
9200c6be90
Merge pull request #46108 from thaJeztah/driver_scopes
libnetwork: move datastore Scope consts to libnetwork/scope
2023-07-28 23:40:32 +02:00
Sebastiaan van Stijn
6ec03d6745
libnetwork: move datastore Scope consts to libnetwork/scope
The "Capability" type defines DataScope and ConnectivityScope fields,
but their value was set from consts in the datastore package, which
required importing that package and its dependencies for the consts
only.

This patch:

- Moves the consts to a separate "scope" package
- Adds aliases for the consts in the datastore package.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-28 21:56:48 +02:00
Sebastiaan van Stijn
6f2e0fac19
Merge pull request #46086 from thaJeztah/split_discoverapi
libnetwork/driverapi: make discoverAPI an optional part of the interface
2023-07-28 18:09:52 +02:00
Sebastiaan van Stijn
86299bbd35
vendor: github.com/opencontainers/image-spec v1.1.0-rc4
changes:

- specs-go: remove artifact prefixed annotations
- Switch from scratch to empty
- Remove artifact media type reference
- image-index: add artifactType to specs and schema
- Add artifactType to image index
- Apply version change from #1050
- Specify the content of the scratch blob
- Add language from artifacttype field to forbid allowlists of media types
- spec: clarify descriptor, align with de facto artifact usage
- Remove special guidance around wasm
- Update descriptor.go
- releases: use +dev as in-development suffix
- version: bump HEAD back to -dev
- image-index: add the subject field

full diff: https://github.com/opencontainers/image-spec/compare/v1.1.0-rc3...v1.1.0-rc4

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-28 18:04:08 +02:00
Sebastiaan van Stijn
fca38bcd0a
libnetwork/driverapi: make discoverAPI an optional part of the interface
Most drivers do not implement this, so detect if a driver implements
the discoverAPI, and remove the implementation from drivers that do
not support it.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-28 17:16:00 +02:00
Sebastiaan van Stijn
70e620f791
Merge pull request #46101 from thaJeztah/libnetwork_remote_concrete_type
libnetwork/remote: newDriver(): return concrete type
2023-07-28 17:14:52 +02:00
Sebastiaan van Stijn
490fee7d45
api/types/filters: fix errors not being matched by errors.Is()
I found that the errors returned weren't matched with `errors.Is()` when
wrapped.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-28 17:07:41 +02:00
Sebastiaan van Stijn
bf48d3ec29
update containerd binary to v1.7.3
- full diff: https://github.com/containerd/containerd/compare/v1.7.2...v1.7.3
- release notes: https://github.com/containerd/containerd/releases/tag/v1.7.3

----

Welcome to the v1.7.3 release of containerd!

The third patch release for containerd 1.7 contains various fixes and updates.

Notable Updates

- RunC: Update runc binary to v1.1.8
- CRI: Fix `additionalGids`: it should fallback to `imageConfig.User`
  when `securityContext.RunAsUser`,`RunAsUsername` are empty
- CRI: write generated CNI config atomically
- Port-Forward: Correctly handle known errors
- Resolve docker.NewResolver race condition
- Fix `net.ipv4.ping_group_range` with userns
- Runtime/V2/RunC: handle early exits w/o big locks
- SecComp: always allow `name_to_handle_at`
- CRI: Windows Pod Stats: Add a check to skip stats for containers that
  are not running
- Task: don't `close()` io before cancel()
- Remove CNI conf_template deprecation
- Fix issue for HPC pod metrics

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-28 13:21:20 +02:00
Sebastiaan van Stijn
a78381c399
update containerd binary to v1.7.2
- full diff: https://github.com/containerd/containerd/compare/v1.7.1...v1.7.2
- release notes: https://github.com/containerd/containerd/releases/tag/v1.7.2

----

Welcome to the v1.7.2 release of containerd!

The second patch release for containerd 1.7 includes enhancements to CRI
sandbox mode, Windows snapshot mounting support, and CRI and container IO
bug fixes.

CRI/Sandbox Updates

- Publish sandbox events
- Make stats respect sandbox's platform

Other Notable Updates

- Mount snapshots on Windows
- Notify readiness when registered plugins are ready
- Fix `cio.Cancel()` should close pipes
- CDI: Use CRI `Config.CDIDevices` field for CDI injection

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-28 13:20:34 +02:00
Sebastiaan van Stijn
0d76fc431a
libnetwork/remote: newDriver(): return concrete type
Interface matching will happen on the receiver side.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-28 12:52:38 +02:00
Sebastiaan van Stijn
b2bde4a7d8
Merge pull request #46090 from thaJeztah/cleanup_TestLinuxParseMountRawSplit
volume/mounts: cleanup tests
2023-07-28 11:12:04 +02:00
Sebastiaan van Stijn
0e0c725224
Merge pull request #45511 from xpivarc/capabilites
Do not drop effective&permitted set
2023-07-28 01:17:43 +02:00
Sebastiaan van Stijn
ed9cd96bdb
Merge pull request #46083 from akerouanton/move-libnet-testutils
tests: Move libnetwork/testutils to internal/testutils/netnsutils
2023-07-27 20:35:42 +02:00
Bjorn Neergaard
1bbc9d1ae4
Merge pull request #46091 from thaJeztah/windows_fix_service_register
windows: fix --register-service when executed from within binary directory
2023-07-27 12:04:02 -06:00
Albin Kerouanton
2870559b2c
Merge pull request #45649 from akerouanton/allow-all-ipv6-icc
libnet/d/bridge: Allow IPv6 ICC from any IP address
2023-07-27 19:41:55 +02:00
Sebastiaan van Stijn
597ab901b9
Merge pull request #46079 from vvoland/c8d-missing-config
c8d/container: Follow snapshot parents for size calculation
2023-07-27 18:08:56 +02:00
Sebastiaan van Stijn
3e8fda0a70
windows: fix --register-service when executed from within binary directory
Go 1.15.7 contained a security fix for CVE-2021-3115, which allowed arbitrary
code to be executed at build time when using cgo on Windows.

This issue was not limited to the go command itself, and could also affect binaries
that use `os.Command`, `os.LookPath`, etc.

From the related blogpost (https://blog.golang.org/path-security):

> Are your own programs affected?
>
> If you use exec.LookPath or exec.Command in your own programs, you only need to
> be concerned if you (or your users) run your program in a directory with untrusted
> contents. If so, then a subprocess could be started using an executable from dot
> instead of from a system directory. (Again, using an executable from dot happens
> always on Windows and only with uncommon PATH settings on Unix.)
>
> If you are concerned, then we’ve published the more restricted variant of os/exec
> as golang.org/x/sys/execabs. You can use it in your program by simply replacing

At time of the go1.15 release, the Go team considered changing the behavior of
`os.LookPath()` and `exec.LookPath()` to be a breaking change, and made the
behavior "opt-in" by providing the `golang.org/x/sys/execabs` package as a
replacement.

However, for the go1.19 release, this changed, and the default behavior of
`os.LookPath()` and `exec.LookPath()` was changed. From the release notes:
https://go.dev/doc/go1.19#os-exec-path

> Command and LookPath no longer allow results from a PATH search to be found
> relative to the current directory. This removes a common source of security
> problems but may also break existing programs that depend on using, say,
> exec.Command("prog") to run a binary named prog (or, on Windows, prog.exe)
> in the current directory. See the os/exec package documentation for information
> about how best to update such programs.
>
> On Windows, Command and LookPath now respect the NoDefaultCurrentDirectoryInExePath
> environment variable, making it possible to disable the default implicit search
> of “.” in PATH lookups on Windows systems.

A result of this change was that registering the daemon as a Windows service
no longer worked when done from within the directory of the binary itself:

    C:\> cd "Program Files\Docker\Docker\resources"
    C:\Program Files\Docker\Docker\resources> dockerd --register-service
    exec: "dockerd": cannot run executable found relative to current directory

Note that using an absolute path would work around the issue:

    C:\Program Files\Docker\Docker>resources\dockerd.exe --register-service

This patch changes `registerService()` to use `os.Executable()`, instead of
depending on `os.Args[0]` and `exec.LookPath()` for resolving the absolute
path of the binary.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-27 16:20:49 +02:00
Sebastiaan van Stijn
d69b1fdb72
volume/mounts: cleanup tests
- don't use un-keyed structs
- user assert.Check where possible
- use consts for fixed values

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-27 15:00:13 +02:00
Sebastiaan van Stijn
10aff57b26
Merge pull request #46037 from AkihiroSuda/rro-remove-short
volume: remove the short RRO forms in favor of the long forms
2023-07-27 14:11:30 +02:00
Sebastiaan van Stijn
198ba185c7
Merge pull request #46081 from vvoland/c8d-refreshimage-refactor
daemon/list: Refactor refreshImage and make `readConfig` return errdefs
2023-07-27 13:52:51 +02:00