Commit graph

47229 commits

Author SHA1 Message Date
Sebastiaan van Stijn
91a3a95385
libnetwork/options: OptionExecRoot: skip osl.SetBasePath on non-Linux
The basepath is only used on Linux, so no need to call it on other
platforms. SetBasePath was already stubbed out on other platforms,
but "osl" was still imported in various places where it was not actually
used, so trying to reduce imports to get a better picture of what parts
are used (and not used).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-12 15:29:20 +02:00
Sebastiaan van Stijn
48ea7ec970
libnetwork/osl: use filepath.Join() only when changing basedir
Use filepath.Join() only when the base-path is updated, instead of every
time it is accessed.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-12 15:29:20 +02:00
Sebastiaan van Stijn
8bf62010a4
libnetwork: merge linux-only test-files
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-12 01:27:38 +02:00
Sebastiaan van Stijn
c0562d4eed
libnetwork: rename unix-only testfiles
Some tests were implicitly skipped through the `getTestEnv()` utility,
which made it hard to discover they were not ran on Windows.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-12 01:27:38 +02:00
Sebastiaan van Stijn
8070f15966
libnetwork/drivers/bridge: rename some linux-only files
This makes it easier to spot if code is only used on Linux. Note that "all of"
the bridge driver is Linux-only.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-12 00:37:43 +02:00
Sebastiaan van Stijn
014fefee1d
libnetwork/drivers/bridge: minor formatting fixes
My IDE kept on re-formatting, so let's do so.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-12 00:37:43 +02:00
Sebastiaan van Stijn
a9e8110fe3
Merge pull request #46187 from thaJeztah/libnetwork_move_windows_things
libnetwork: move some code to platform-specific files
2023-08-12 00:31:49 +02:00
Sebastiaan van Stijn
80d158e0de
daemon: remove containerNotModifiedError
Removing this type, because:

- containerNotModifiedError is not an actual error, and abstracting it away
  was hiding some of these details. It also wasn't used as a sentinel error
  anywhere, so doesn't have to be its own type.
- Defining a type just to toggle the error-message between "not running"
  and "not stopped" felt a bit over-the-top, as each variant was only used once.
- So  "it only had one job", and it didn't even do that right; it produced
  capitalized error messages, which makes linters unhappy.

So, let's just inline what it does in the two places it was used.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-11 21:28:06 +02:00
Sebastiaan van Stijn
dffe634c19
daemon: Daemon.ContainerStart(): make validateState a regular function
There's no need for this to be a closure; let's just make it a regular
function. While moving it out, also make some minor code-changes and
add some code-comments to describe the flow / intent, which may not
be trivial for people that are not familiar with these details.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-11 21:28:06 +02:00
Sebastiaan van Stijn
896f246888
Merge pull request #46191 from thaJeztah/integration_testutil_improvements
integration/container: refactor some test-utilities and fix var-names shadowing imports
2023-08-11 17:49:42 +02:00
Sebastiaan van Stijn
5fe81ef1bb
Merge pull request #46193 from thaJeztah/daemon_error_comment
daemon: Daemon.containerStart(): add comment to clarify error-type
2023-08-11 16:18:49 +02:00
Paweł Gronowski
6da42ca830
c8d/diff: Reuse mount, mount parent as read-only
The container rw layer may already be mounted, so it's not safe to use
it in another overlay mount. Use the ref counted mounter (which will
reuse the existing mount if it exists) to avoid that.

Also, mount the parent mounts (layers of the base image) in a read-only
mode.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-08-11 15:30:38 +02:00
Paweł Gronowski
051d51b222
c8d/export: Use ref counted mounter
To prevent mounting the container rootfs in a rw mode if it's already
mounted.  This can't use `mount.WithReadonlyTempMount` because the
archive code does a chroot with a pivot_root, which creates a new
directory in the rootfs.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-08-11 15:30:36 +02:00
Paweł Gronowski
303e2b124e
integration: Add test for not breaking overlayfs
Check that operations that could potentially perform overlayfs mounts
that could cause undefined behaviors.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-08-11 15:30:29 +02:00
Sebastiaan van Stijn
05deecaa45
internal/testutils/netnsutils: move utils that were not used on Windows
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-11 15:00:30 +02:00
Sebastiaan van Stijn
d4e1c072e2
libnetwork: move resolverIPSandbox closer to where it's used
It's only used on non-Windows platforms, so let's move it there.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-11 15:00:30 +02:00
Sebastiaan van Stijn
f661bd8ee5
libnetwork: Resolved.SetupFunc() minor cleanup
Remove intermediate variables in favor of struct-literals.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-11 15:00:30 +02:00
Sebastiaan van Stijn
de4ba13400
libnetwork: move resolver tests that were skipped on Windows
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-11 15:00:30 +02:00
Sebastiaan van Stijn
1e4e9161c5
libnetwork: move TestDNSOptions to a non-windows file
It was only testing stub implementations on Windows that are not
used in production code.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-11 14:59:30 +02:00
Sebastiaan van Stijn
bf1fb97575
daemon: Daemon.containerStart(): add comment to clarify error-type
Any error that occurs while creating the spec, even if it's the
result of an invalid container config, must be considered a System
error (internal server error), as it's not an error with the request
to start the container.

Invalid configuration in the config itself must be validated when
creating the container (creating its config), but some errors are
dependent on the current state, for example when starting a container
that shares a namespace with another container, and that container
is not running (or missing).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-11 14:47:22 +02:00
Akihiro Suda
b039bbc678
update runc binary to v1.1.9
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2023-08-11 21:29:53 +09:00
Akihiro Suda
79b467808e
vendor.mod: github.com/opencontainers/runc v1.1.9
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2023-08-11 21:29:16 +09:00
Sebastiaan van Stijn
74feadacf8
integration/internal/container: refactor CreateExpectingErr
This utility was only used for a single test, and it was very limited
in functionality as it only allowed for a certain error-string to be
matched.

Let's change it into a more generic function; a helper that allows a
container to be created from a `TestContainerConfig` (which can be
constructed using `NewTestConfig`) and that returns the response from
client.ContainerCreate(), so that any result from that can be tested,
leaving it up to the test to check the results.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-11 14:03:08 +02:00
Sebastiaan van Stijn
0899ba4a3f
integration/internal/container: add NewTestConfig utility
Introduce a NewTestConfig utility, to allow using the available utilities
for constructing a config, and use them with the regular API client.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-11 14:03:08 +02:00
Sebastiaan van Stijn
3cb52a6359
integration/internal/container: use consistent name for api-client
The `client` variable was colliding with the `client` import. In some cases
the confusing `cli` name (it's not the "cli") was used. Given that such names
can easily start spreading (through copy/paste, or "code by example"), let's
make a one-time pass through all of them in this package to use the same name.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-11 14:02:17 +02:00
Sebastiaan van Stijn
26be2bc6b9
integration/container: use consistent name for api-client
The `client` variable was colliding with the `client` import in various
files. While it didn't conflict in all files, there was inconsistency
in the naming, sometimes using the confusing `cli` name (it's not the
"cli"), and such names can easily start spreading (through copy/paste,
or "code by example").

Let's make a one-time pass through all of them in this package to use
the same name.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-11 13:51:57 +02:00
Sebastiaan van Stijn
e0da5cb929
Merge pull request #46171 from thaJeztah/client_context
client: Client.buildRequest: use http.NewRequestWithContext
2023-08-10 21:00:13 +02:00
Paweł Gronowski
220fba06e7
Merge pull request #46182 from akerouanton/daemon-create-replace-pkg-errors
daemon/create.go: Supersede github.com/pkg/errors
2023-08-10 13:26:52 +02:00
Sebastiaan van Stijn
3c8b68c636
Merge pull request #46181 from vvoland/tests-volumemounts-nilerror
test/volume: Replace Check with NilError where suitable
2023-08-10 13:12:28 +02:00
Albin Kerouanton
38e26c4717
daemon/create.go: Fix error capitalization
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2023-08-10 12:15:34 +02:00
Sebastiaan van Stijn
8b69cb4482
Merge pull request #46176 from vvoland/refactor-integration-tag-subtests
integration/tag: Use subtests, make parallel and move to client unit test
2023-08-10 12:13:17 +02:00
Paweł Gronowski
435ecfe6e0
test/volume: Replace Check with NilError where suitable
In these cases, continuing after a non nil error will result in a nil
dereference in panic.
Change the `assert.Check` to `assert.NilError` to avoid that.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-08-10 11:18:56 +02:00
Sebastiaan van Stijn
3d3ce9812f
integration/tag: Move to client unit test
This test was testing the client-side validation, so might as well
move it there, and validate that the client invalidates before
trying to make an API call.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-08-10 10:37:04 +02:00
Albin Kerouanton
742475bc8d
daemon/create.go: Supersede github.com/pkg/errors
Will make it possible to use `errors.Join()` in that file.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2023-08-10 01:30:10 +02:00
Sebastiaan van Stijn
4cc796ab93
client: Client.buildRequest: use http.NewRequestWithContext
Attach the context to the request while we're creating it, instead of
creating the context first, and adding the context later.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-09 20:30:25 +02:00
Sebastiaan van Stijn
58dc0fcd1e
client: Client.Ping: re-use request when falling back to GET
Re-use the request, and change the method to GET instead of building
a new request "from scratch".

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-09 20:30:25 +02:00
Sebastiaan van Stijn
87fff769f4
client: Client.checkResponseErr: change errorMessage to an error
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-09 20:30:25 +02:00
Paweł Gronowski
71da8c13e1
integration/tag: Use subtests and make parallel
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-08-09 14:11:18 +02:00
Sebastiaan van Stijn
89b542b421
Merge pull request #46175 from vvoland/pkg-plugins-gotest
pkg/plugins: Rewrite with assert.Check
2023-08-09 13:44:05 +02:00
Sebastiaan van Stijn
cfc117826a
Merge pull request #46168 from vvoland/hack-integrationcli-dont-failfast
hack/test: Don't fail-fast before integration-cli
2023-08-09 13:43:43 +02:00
Sebastiaan van Stijn
1614b534fe
Merge pull request #46169 from vvoland/hack-integration-testfilter-fixes
hack/test: Fix `TEST_FILTER` with regex matching integration and integration-cli tests
2023-08-09 13:29:46 +02:00
Paweł Gronowski
11a0c2779b
pkg/plugins: Rewrite with assert.Check
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-08-09 12:22:25 +02:00
Sebastiaan van Stijn
6598cba32f
Merge pull request #46174 from thaJeztah/libnetwork_osl_cleanups
libnetwork/osl: remove redundant locks, and assorted cleanups
2023-08-09 12:17:54 +02:00
Paweł Gronowski
43956e1b71
hack/test: Don't exit early when all tests are filtered out
Don't exit immediately (due to `set -e` bash behavior) when grep returns
with a non-zero exit code. Use empty dirs instead and let it print
messages about all tests being filtered out.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-08-09 09:47:02 +02:00
Paweł Gronowski
ae008570ff
hack/test: Split -test.run for integration and integration-cli
To avoid passing the `/` prefix in the -test.run to the integration test
suite, which for some reason executes all tests, but works fine with
integration-cli.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-08-09 09:47:01 +02:00
Paweł Gronowski
510cac5f5b
hack/test: Fix checking if integration-cli are filtered out
Previous check checked if ANY of the test directories isn't
integration-cli. This means it was true if TEST_FILTER matched multiple
tests from both integration and integration-cli suite.

Remove the grep `-v` inversion and replace it with a bash negation, so
it actually checks if there is no `integration-cli` in test dirs.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-08-09 09:47:00 +02:00
Sebastiaan van Stijn
2cccb1f02c
Merge pull request #46075 from thaJeztah/libnetwork_remove_NetworkInfo
libnetwork: remove Network.Info() and remove NetworkInfo interface
2023-08-09 01:15:44 +02:00
Sebastiaan van Stijn
8a1ca49657
libnetwork/osl: nwIface: add godoc
Copy the godoc from the interface to the implementation.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-08 23:05:42 +02:00
Sebastiaan van Stijn
16785b9b7b
libnetwork/osl: move all networkNamespace methods together
These methods were sprinkled throughout the code; let's move
them together.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-08 23:04:19 +02:00
Sebastiaan van Stijn
5b0fa7aaca
libnetwork/osl: some minor nits
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-08 22:33:29 +02:00