Commit graph

44678 commits

Author SHA1 Message Date
Sebastiaan van Stijn
e2114731e7
contrib: make dockerd-rootless-setuptool.sh more robust
The `docker` CLI currently doesn't handle situations where the current context
(as defined in `~/.docker/config.json`) is invalid or doesn't exist. As loading
(and checking) the context happens during initialization of the CLI, this
prevents `docker context` commands from being used, which makes it complicated
to fix the situation. For example, running `docker context use <correct context>`
would fail, which makes it not possible to update the `~/.docker/config.json`,
unless doing so manually.

For example, given the following `~/.docker/config.json`:

```json
{
        "currentContext": "nosuchcontext"
}
```

All of the commands below fail:

```bash
docker context inspect rootless
Current context "nosuchcontext" is not found on the file system, please check your config file at /Users/thajeztah/.docker/config.json

docker context rm --force rootless
Current context "nosuchcontext" is not found on the file system, please check your config file at /Users/thajeztah/.docker/config.json

docker context use default
Current context "nosuchcontext" is not found on the file system, please check your config file at /Users/thajeztah/.docker/config.json
```

While these things should be fixed, this patch updates the script to switch
the context using the `--context` flag; this flag is taken into account when
initializing the CLI, so that having an invalid context configured won't
block `docker context` commands from being executed. Given that all `context`
commands are local operations, "any" context can be used (it doesn't need to
make a connection with the daemon).

With this patch, those commands can now be run (and won't fail for the wrong
reason);

```bash
 docker --context=default context inspect -f "{{.Name}}" rootless
rootless

docker --context=default context inspect -f "{{.Name}}" rootless-doesnt-exist
context "rootless-doesnt-exist" does not exist
```

One other issue may also cause things to fail during uninstall; trying to remove
a context that doesn't exist will fail (even with the `-f` / `--force` option
set);

```bash
docker --context=default context rm blablabla
Error: context "blablabla": not found
```

While this is "ok" in most circumstances, it also means that (potentially) the
current context is not reset to "default", so this patch adds an explicit
`docker context use`, as well as unsetting the `DOCKER_HOST` and `DOCKER_CONTEXT`
environment variables.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-09-28 15:35:04 +02:00
Sebastiaan van Stijn
db1663a1e5
Merge pull request #44205 from thaJeztah/remove_deprecated_stubs
Remove stubs for deprecated functions and consts
2022-09-28 01:51:04 +02:00
Sebastiaan van Stijn
173d16b233
Merge pull request #44193 from thaJeztah/libnetwork_cleanup
libnetwork: cleanup config package, remove old integration tests
2022-09-27 22:41:32 +02:00
Sebastiaan van Stijn
73fe903c96
Merge pull request #44129 from thaJeztah/enable_deprecated_check
Revert "validation: temporarily allows changes in integration-cli"
2022-09-27 22:39:41 +02:00
Sebastiaan van Stijn
0dde471278
Merge pull request #44203 from thaJeztah/idtools_fix_infinite_loop
pkg/idtools: mkdirAs(): fix infinite loops and repeated "chown"
2022-09-27 21:58:50 +02:00
Sebastiaan van Stijn
ee5d8f43e1
pkg/signal: remove stubs for deprecated package
The pkg/signal package was moved to github.com/moby/sys/signal in
28409ca6c7. The DefaultStopSignal const was
deprecated in e53f65a916, and the DumpStacks
function was moved to pkg/stack in ea5c94cdb9,
all of which are included in the 22.x release, so we can safely remove these
from master.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-09-27 21:48:52 +02:00
Sebastiaan van Stijn
4a8b3b8bc5
api/types: remove aliases for deprecated Volume and VolumeUsageData
These were moved, and deprecated in f19ef20a44 and
4caf68f4f6, which are part of the 22.x release, so
we can safely remove these from master.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-09-27 21:44:15 +02:00
Sebastiaan van Stijn
18ca7546f6
pkg/system: remove stubs for deprecated sequential functions
These functions were moved to github.com/moby/sys/sequential, and the
stubs were added in 509f19f611, which is
part of the 22.x release, so we can safely remove these from master.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-09-27 21:36:09 +02:00
Sebastiaan van Stijn
91f14e751f
Merge pull request #44111 from thaJeztah/remove_tagger
api/server/backend/build: remove Tagger and NewTagger
2022-09-27 21:04:16 +02:00
Sebastiaan van Stijn
a4f3c08db4
Merge pull request #44196 from neersighted/createImpliedDirectories
refactor(pkg/archive): factor out createImpliedDirectories helper
2022-09-27 19:20:25 +02:00
Sebastiaan van Stijn
1e13247d6d
pkg/idtools: mkdirAs(): fix infinite loops and repeated "chown"
This fixes an inifinite loop in mkdirAs(), used by `MkdirAllAndChown`,
`MkdirAndChown`, and `MkdirAllAndChownNew`, as well as directories being
chown'd multiple times when relative paths are used.

The for loop in this function was incorrectly assuming that;

1. `filepath.Dir()` would always return the parent directory of any given path
2. traversing any given path to ultimately result in "/"

While this is correct for absolute and "cleaned" paths, both assumptions are
incorrect in some variations of "path";

1. for paths with a trailing path-separator ("some/path/"), or dot ("."),
   `filepath.Dir()` considers the (implicit) "." to be a location _within_ the
   directory, and returns "some/path" as ("parent") directory. This resulted
   in the path itself to be included _twice_ in the list of paths to chown.
2. for relative paths ("./some-path", "../some-path"), "traversing" the path
   would never end in "/", causing the for loop to run indefinitely:

    ```go
    // walk back to "/" looking for directories which do not exist
    // and add them to the paths array for chown after creation
    dirPath := path
    for {
        dirPath = filepath.Dir(dirPath)
        if dirPath == "/" {
            break
        }
        if _, err := os.Stat(dirPath); err != nil && os.IsNotExist(err) {
            paths = append(paths, dirPath)
        }
    }
    ```

A _partial_ mitigation for this would be to use `filepath.Clean()` before using
the path (while `filepath.Dir()` _does_ call `filepath.Clean()`, it only does so
_after_ some processing, so only cleans the result). Doing so would prevent the
double chown from happening, but would not prevent the "final" path to be "."
or ".." (in the relative path case), still causing an infinite loop, or
additional checks for "." / ".." to be needed.

| path           | filepath.Dir(path) | filepath.Dir(filepath.Clean(path)) |
|----------------|--------------------|------------------------------------|
| some-path      | .                  | .                                  |
| ./some-path    | .                  | .                                  |
| ../some-path   | ..                 | ..                                 |
| some/path/     | some/path          | some                               |
| ./some/path/   | some/path          | some                               |
| ../some/path/  | ../some/path       | ../some                            |
| some/path/.    | some/path          | some                               |
| ./some/path/.  | some/path          | some                               |
| ../some/path/. | ../some/path       | ../some                            |
| /some/path/    | /some/path         | /some                              |
| /some/path/.   | /some/path         | /some                              |

Instead, this patch adds a `filepath.Abs()` to the function, so make sure that
paths are both cleaned, and not resulting in an infinite loop.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-09-27 19:15:16 +02:00
Sebastiaan van Stijn
762fc76cf9
Merge pull request #44089 from thaJeztah/update_golangci_lint
golangci-lint: update to v1.49.0
2022-09-27 18:24:15 +02:00
Sebastiaan van Stijn
96355b4f1c
Merge pull request #44016 from thaJeztah/dont_set_ignoreImagesArgsEscaped
daemon: don't set ignoreImagesArgsEscaped, managed where not needed
2022-09-27 17:59:23 +02:00
Sebastiaan van Stijn
5b4d930ae5
Merge pull request #44200 from crazy-max/api-fix-logo
swagger: update links to logo
2022-09-27 17:54:11 +02:00
CrazyMax
7f3602f1c9
swagger: update links to logo
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-09-27 11:56:14 +02:00
Sebastiaan van Stijn
89555e45f2
Merge pull request #44191 from corhere/drop-containerfs-iface
Remove LCOW: pkg/containerfs: drop ContainerFS abstraction
2022-09-27 10:28:35 +02:00
Sebastiaan van Stijn
e3d80cfc15
Merge pull request #44179 from thaJeztah/resolvconf_deadcode
libnetwork/resolvconf: removed unused GetIfChanged() and GetLastModified()
2022-09-26 23:51:52 +02:00
Sebastiaan van Stijn
3582c9da70
Merge pull request #43867 from thaJeztah/consistent_alias
use consistent alias for gotest.tools/v3/assert/cmp
2022-09-26 21:08:31 +02:00
Sebastiaan van Stijn
cf82687f23
Merge pull request #42941 from thaJeztah/jenkinsfile_ubuntu_2004
Jenkinsfile: use Ubuntu 20.04 for DCO stage
2022-09-26 19:55:48 +02:00
Bjorn Neergaard
5dff494b87 test(pkg/archive): add TestImpliedDirectoryPermissions
Co-authored-by: Cory Snider <csnider@mirantis.com>
Signed-off-by: Bjorn Neergaard <bneergaard@mirantis.com>
2022-09-26 11:46:01 -06:00
Sebastiaan van Stijn
cd381aea56
libnetwork: fix empty-lines (revive)
libnetwork/etchosts/etchosts_test.go:167:54: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/osl/route_linux.go:185:74: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/osl/sandbox_linux_test.go:323:36: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/bitseq/sequence.go:412:48: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/datastore/datastore_test.go:67:46: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/datastore/mock_store.go:34:60: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/iptables/firewalld.go:202:44: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/iptables/firewalld_test.go:76:36: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/iptables/iptables.go:256:67: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/iptables/iptables.go:303:128: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/networkdb/cluster.go:183:72: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/ipams/null/null_test.go:44:38: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/drivers/macvlan/macvlan_store.go:45:52: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/ipam/allocator_test.go:1058:39: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/drivers/bridge/port_mapping.go:88:111: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/drivers/bridge/link.go:26:90: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/drivers/bridge/setup_ipv6_test.go:17:34: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/drivers/bridge/setup_ip_tables.go:392:4: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/drivers/bridge/bridge.go:804:50: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/drivers/overlay/ov_serf.go:183:29: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/drivers/overlay/ov_utils.go:81:64: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/drivers/overlay/peerdb.go:172:67: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/drivers/overlay/peerdb.go:209:67: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/drivers/overlay/peerdb.go:344:89: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/drivers/overlay/peerdb.go:436:63: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/drivers/overlay/overlay.go:183:36: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/drivers/overlay/encryption.go:69:28: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/drivers/overlay/ov_network.go:563:81: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/default_gateway.go:32:43: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/errors_test.go:9:40: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/service_common.go:184:64: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/endpoint.go:161:55: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/store.go:320:33: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/store_linux_test.go:11:38: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/sandbox.go:571:36: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/service_common.go:317:246: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/endpoint.go:550:17: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/sandbox_dns_unix.go:213:106: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/controller.go:676:85: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/agent.go:876:60: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/resolver.go:324:69: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/network.go:1153:92: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/network.go:1955:67: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/network.go:2235:9: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/libnetwork_internal_test.go:336:26: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/resolver_test.go:76:35: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/libnetwork_test.go:303:38: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/libnetwork_test.go:985:46: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/ipam/allocator_test.go:1263:37: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/errors_test.go:9:40: empty-lines: extra empty line at the end of a block (revive)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-09-26 19:21:58 +02:00
Sebastiaan van Stijn
267108e113
libnetwork/config: rename ParseConfigOptions() to New()
This function effectively is a constructor, so rename it to better describe
it's functionality.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-09-26 19:20:55 +02:00
Bjorn Neergaard
4831ff9f27 refactor(pkg/archive): factor out createImpliedDirectories helper
This code was duplicated in two places -- factor it out, add
documentation, and move magic numbers into a constant.

Additionally, use the same permissions (0755) in both code paths, and
ensure that the ID map is used in both code paths.

Co-authored-by: Vasiliy Ulyanov <vulyanov@suse.de>
Signed-off-by: Bjorn Neergaard <bneergaard@mirantis.com>
Signed-off-by: Vasiliy Ulyanov <vulyanov@suse.de>
2022-09-26 11:11:06 -06:00
Sebastiaan van Stijn
09cc2f9d0e
libnetwork/config: inline LoadDefaultScopes()
This method was an exported method, but only used as part of ParseConfigOptions,
so inlining it.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-09-26 17:40:06 +02:00
Sebastiaan van Stijn
528428919e
libnetwork/config: merge DaemonCfg into Config
It was unclear what the distinction was between these configuration
structs, so merging them to simplify.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-09-26 12:05:37 +02:00
Sebastiaan van Stijn
571baffd59
libnetwork: remove old integration tests
This was used for testing purposes when libnetwork was in a separate repo, using
the dnet utility, which was removed in 7266a956a8.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-09-26 12:05:37 +02:00
Sebastiaan van Stijn
46f4a45769
libnetwork/config: remove ParseConfig()
Libnetwork configuration files were only used as part of integration tests using
the dnet utility, which was removed in 7266a956a8

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-09-26 12:05:37 +02:00
Sebastiaan van Stijn
7d574f5ac6
libnetwork/config: inline ProcessOptions
This method was only used in a single place; inlining it makes it
easier to see what's done.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-09-26 12:05:37 +02:00
Sebastiaan van Stijn
a8a8bd1e42
libnetwork/config: remove "Experimental" and "Debug" options
These were no longer used.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-09-26 12:05:22 +02:00
Samuel Karp
67da3f7e6b
Merge pull request #44189 from thaJeztah/sequential_release 2022-09-25 00:05:25 -07:00
Akihiro Suda
58dd03a471
Merge pull request #44180 from thaJeztah/bump_gotest_tools
vendor: gotest.tools v3.3.0
2022-09-24 08:03:53 +09:00
Sebastiaan van Stijn
2f1c382a6d
golangci-lint: update to v1.49.0
Remove the "deadcode", "structcheck", and "varcheck" linters, as they are
deprecated:

    WARN [runner] The linter 'deadcode' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter.  Replaced by unused.
    WARN [runner] The linter 'structcheck' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter.  Replaced by unused.
    WARN [runner] The linter 'varcheck' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter.  Replaced by unused.
    WARN [linters context] structcheck is disabled because of generics. You can track the evolution of the generics support by following the https://github.com/golangci/golangci-lint/issues/2649.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-09-23 23:31:27 +02:00
Cory Snider
a5be811269 chore(integration): delete outdated TODO comment
The TODO comment was in regards to allowing graphdriver plugins to
provide their own ContainerFS implementations. The ContainerFS interface
has been removed from Moby, so there is no longer anything which needs
to be figured out.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2022-09-23 16:56:53 -04:00
Cory Snider
6ca4eda960 daemon: clean up vestiges of ContainerFS
Now that the type of Container.BaseFS has been reverted to a string,
values can never implement the extractor or archiver interfaces. Rip out
the dead code to support archiving and unarchiving through those
interfcaes.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2022-09-23 16:56:53 -04:00
Cory Snider
9ce2b30b81 pkg/containerfs: drop ContainerFS type alias
Signed-off-by: Cory Snider <csnider@mirantis.com>
2022-09-23 16:56:53 -04:00
Cory Snider
e332c41e9d pkg/containerfs: alias ContainerFS to string
Drop the constructor and redundant string() type-casts.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2022-09-23 16:56:52 -04:00
Cory Snider
95824f2b5f pkg/containerfs: simplify ContainerFS type
Iterate towards dropping the type entirely.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2022-09-23 16:56:49 -04:00
Cory Snider
be4f4644a8 pkg/containerfs: drop Driver abstraction
The Driver abstraction was needed for Linux Containers on Windows,
support for which has since been removed.

There is no direct equivalent to Lchmod() in the standard library so
continue to use the containerd/continuity version.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2022-09-23 16:25:22 -04:00
Cory Snider
7014c0d65d pkg/containerfs: drop PathDriver abstraction
With LCOW support removed, there is no need to support non-native file
paths any longer.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2022-09-23 16:25:22 -04:00
Cory Snider
e37a2d1879 pkg/containerfs: delete Archiver, Driver
They were needed for Linux Containers on Windows, which is no longer
supported.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2022-09-23 16:25:22 -04:00
Cory Snider
a7c8fdc55b pkg/containerfs: make ResolveScopedPath a free fn
Signed-off-by: Cory Snider <csnider@mirantis.com>
2022-09-23 16:25:22 -04:00
Cory Snider
fd16e003fb pkg/containerfs: Remove NewLocalDriver()
Signed-off-by: Cory Snider <csnider@mirantis.com>
2022-09-23 16:25:22 -04:00
Cory Snider
4d48c00f94 pkg/containerfs: Trim away Driver interface part 1
The Driver interface was required for Linux Containers on Windows, which
is no longer supported.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2022-09-23 16:25:21 -04:00
Sebastiaan van Stijn
489e7b61bf
vendor: github.com/moby/sys/sequential v0.5.0
no changes, just updated to use the tagged version;

full diff: https://github.com/moby/sys/compare/b22ba8a69b30...sequential/v0.5.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-09-23 18:39:20 +02:00
Samuel Karp
8520b322aa
Merge pull request #44174 from thaJeztah/fix_g112_slowlorus 2022-09-22 13:25:44 -07:00
Sebastiaan van Stijn
e352e8deed
Merge pull request #44184 from thaJeztah/bump_go_systemd
vendor: github.com/github.com/coreos/go-systemd v22.4.0
2022-09-22 21:47:47 +02:00
Sebastiaan van Stijn
323ab8ef97
vendor: github.com/github.com/coreos/go-systemd v22.4.0
- dbus: add Connected methods to check connections status
- dbus: add support for querying unit by PID
- dbus: implement support for cgroup freezer APIs
- journal: remove implicit initialization
- login1: add methods to get session/user properties
- login1: add context-aware ListSessions and ListUsers methods

full diff: https://github.com/github.com/coreos/go-systemd/compare/v22.3.2...v22.4.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-09-22 19:57:44 +02:00
Brian Goff
c5c3568573
Merge pull request #44181 from rumpl/remove-os-check
Remove the OS check when creating a container
2022-09-22 09:45:55 -07:00
Djordje Lukic
1a3d8019d1 Remove the OS check when creating a container
Now that we can pass any custom containerd shim to dockerd there is need
for this check. Without this it becomes possible to use wasm shims for
example with images that have "wasi" as the OS.

Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
2022-09-22 17:27:10 +02:00
Sebastiaan van Stijn
3e1601a980
vendor: gotest.tools v3.3.0
full diff: https://github.com/gotestyourself/gotest.tools/compare/v3.2.0...v3.3.0

- golden: accept -update for updating files
- assert: golden variables

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-09-22 15:45:08 +02:00