Commit graph

45342 commits

Author SHA1 Message Date
Albin Kerouanton
799cc143c9
Always use iptables -C to look for rules
iptables -C flag was introduced in v1.4.11, which was released ten
years ago. Thus, there're no more Linux distributions supported by
Docker using this version. As such, this commit removes the old way of
checking if an iptables rule exists (by using substring matching).

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2022-12-23 11:04:28 +01:00
Albin Kerouanton
205e5278c6
Merge iptables.probe() into iptables.detectIptables()
The former was doing some checks and logging warnings, whereas
the latter was doing the same checks but to set some internal variables.
As both are called only once and from the same place, there're now
merged together.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2022-12-23 11:04:28 +01:00
Cory Snider
3330fc2e93
Merge pull request #44667 from masibw/44610-logs-for-DNS-failures
libnetwork: improve logs for DNS failures
2022-12-22 16:24:47 -05:00
Tianon Gravi
bcb8f69cc5
Merge pull request #44239 from thaJeztah/resolvconf_refactor_step2
libnetwork: simplify handling of reading resolv.conf
2022-12-22 13:18:47 -08:00
Sebastiaan van Stijn
1eb09c8ce2
Merge pull request #44683 from thaJeztah/libnetwork_consts
libnetwork/netlabel: make consts actual consts, remove redundant utils
2022-12-22 21:55:05 +01:00
Sebastiaan van Stijn
b97ee34947
Merge pull request #44669 from thaJeztah/mux_tests
registry: use http.NewServeMux for tests instead of gorilla/mux
2022-12-22 21:49:26 +01:00
Sebastiaan van Stijn
bee4b80754
Merge pull request #44534 from thaJeztah/layer_minor_fix
layer: layerStore.registerWithDescriptor: rename var to prevent shadowing
2022-12-22 21:17:27 +01:00
Yamazaki Masashi
0787ea8b26 libnetwork: improve logs for DNS failures
Signed-off-by: Yamazaki Masashi <masi19bw@gmail.com>

libnetwork: fix function call

Signed-off-by: Yamazaki Masashi <masi19bw@gmail.com>
2022-12-22 23:25:21 +09:00
Tianon Gravi
204cbfb68d
Merge pull request #44684 from thaJeztah/libnetwork_bridge_remove_deprecated
libnetwork/drivers/bridge: remove "ioctl" fallback code for legacy kernels
2022-12-21 09:41:19 -08:00
Tianon Gravi
e6d4475a6c
Merge pull request #44678 from thaJeztah/errdefs_improve_debug_logs
errdefs: FromStatusCode() don't log "FIXME" debug message
2022-12-21 09:38:33 -08:00
Sebastiaan van Stijn
a959487597
libnetwork/netlabel: remove Key(), Value(), and KeyValue() utils
These were only used in a single location, and in a rather bad way;
replace them with strings.Cut() which should be all we need for this.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-21 18:17:54 +01:00
Sebastiaan van Stijn
9015cb7111
libnetwork: controller: rename vars that collided or shadowed
- config collided with import
- cap collided with a built-in
- c collided with the "controller" receiver

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-21 18:17:17 +01:00
Sebastiaan van Stijn
96cfb076ce
libnetwork/netlabel: make consts actual consts
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-21 18:17:13 +01:00
Tianon Gravi
3a5598affa
Merge pull request #44381 from thaJeztah/strings_cut
Replace uses of `strings.Split(N)` with `strings.Cut()`
2022-12-21 09:16:05 -08:00
Sebastiaan van Stijn
36151bd1d7
libnetwork/drivers/bridge: remove "ioctl" fallback code for legacy kernels
This code was forked from libcontainer (now runc) in
fb6dd9766e

From the description of this code:

> THIS CODE DOES NOT COMMUNICATE WITH KERNEL VIA RTNETLINK INTERFACE
> IT IS HERE FOR BACKWARDS COMPATIBILITY WITH OLDER LINUX KERNELS
> WHICH SHIP WITH OLDER NOT ENTIRELY FUNCTIONAL VERSION OF NETLINK

That comment was added as part of a refactor in;
4fe2c7a4db

Digging deeper into the code, it describes:

> This is more backward-compatible than netlink.NetworkSetMaster and
> works on RHEL 6.

That comment (and code) moved around a few times;

- moved into the libcontainer pkg: 6158ccad97
- moved within the networkdriver pkg: 4cdcea2047
- moved into the networkdriver pkg: 90494600d3

Ultimately leading to 7a94cdf8ed, which implemented
this:

> create the bridge device with ioctl
>
> On RHEL 6, creation of a bridge device with netlink fails.  Use the more
> backward-compatible ioctl instead.  This fixes networking on RHEL 6.

So from that information, it looks indeed to support RHEL 6, and Ubuntu 12.04
which are both EOL, and we haven't supported for a long time, so probably time
to remove this.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-21 17:32:04 +01:00
Sebastiaan van Stijn
6a91e09218
pkg/parsers: use strings.Cut(), and cleanup error-messages
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-21 11:09:03 +01:00
Sebastiaan van Stijn
3f935d0e2c
daemon/graphdriver/zfs: use strings.Cut, and refactor
Fixes a (theoretical?) panic if ID would be shorter than 12
characters. Also trim the ID _after_ cutting off the suffix.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-21 11:09:03 +01:00
Sebastiaan van Stijn
f95e9b68d6
daemon: use strings.Cut() and cleanup error messages
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-21 11:09:03 +01:00
Sebastiaan van Stijn
46f7c92c9a
libnetwork: use strings.Cut() and minor refactor
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-21 11:09:03 +01:00
Sebastiaan van Stijn
87ca9490b0
libnetwork/datastore: rename var that collided with import
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-21 11:09:03 +01:00
Sebastiaan van Stijn
ff447f4fd5
runconfig/opts: use strings.Cut()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-21 11:09:03 +01:00
Sebastiaan van Stijn
bffb35612c
plugin: use strings.Cut()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-21 11:09:02 +01:00
Sebastiaan van Stijn
01365cbd74
libcontainerd/local: use strings.Cut()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-21 11:09:02 +01:00
Sebastiaan van Stijn
6059d38f21
pkg/parsers/operatingsystem: don't use strings.SplitN()
We're looking for a specific prefix, so remove the prefix instead. Also remove
redundant error-wrapping, as `os.Open()` already provides details in the error
returned;

    open /no/such/file: no such file or directory
    open /etc/os-release: permission denied

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-21 11:09:02 +01:00
Sebastiaan van Stijn
451b8579ef
pkg/parsers/kernel: use strings.Cut() and minor refactor
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-21 11:09:02 +01:00
Sebastiaan van Stijn
774cd9a26c
opts: use strings.Cut() and refactor parseDaemonHost()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-21 11:09:02 +01:00
Sebastiaan van Stijn
d3cd746067
integration-cli: use strings.Cut()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-21 11:09:02 +01:00
Sebastiaan van Stijn
38b0c47f37
integration-cli: links: use gotest.tools compare and assert.Check
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-21 11:09:02 +01:00
Sebastiaan van Stijn
ebda2fa2b5
integration/internal: use strings.Cut() and minor refactor
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-21 11:09:01 +01:00
Sebastiaan van Stijn
39f59c3289
daemon/links: use strings.Cut()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-21 11:09:01 +01:00
Sebastiaan van Stijn
ad7f1a8dcc
daemon/logger: use strings.Cut()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-21 11:09:01 +01:00
Sebastiaan van Stijn
32c4c15f15
daemon/events: use strings.Cut()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-21 11:09:01 +01:00
Sebastiaan van Stijn
5008409b5c
cmd/dockerd: use strings.Cut()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-21 11:09:01 +01:00
Sebastiaan van Stijn
19cd5ff164
client: use strings.Cut()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-21 11:09:01 +01:00
Sebastiaan van Stijn
64adea1ce1
volume: use strings.Cut() and minor refactor
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-21 11:09:00 +01:00
Sebastiaan van Stijn
19db33afc9
pkg/tarsum: use strings.Cut() and minor refactor
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-21 11:09:00 +01:00
Sebastiaan van Stijn
59880cb855
builder/dockerfile: use strings.Cut()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-21 11:09:00 +01:00
Sebastiaan van Stijn
604a2d67b5
builder/remotecontext/git: use strings.Cut()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-21 11:09:00 +01:00
Sebastiaan van Stijn
380a2dfc3a
api/types: use strings.Cut()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-21 11:09:00 +01:00
Sebastiaan van Stijn
7841ce781c
api/types/time: use strings.Cut()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-21 11:09:00 +01:00
Sebastiaan van Stijn
ba9bcf92f6
api/types/filters: use strings.Cut()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-21 11:08:59 +01:00
Sebastiaan van Stijn
6db4af7bd5
graphdriver: windows: use strings.Cut()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-21 11:08:59 +01:00
Sebastiaan van Stijn
c545473920
daemon/cluster: use strings.Cut()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-21 11:08:57 +01:00
Sebastiaan van Stijn
ec878a3d89
pkg/sysinfo: unify ReadMemInfo implementation
Use a single exported implementation, so that we can maintain the
GoDoc string in one place, and use non-exported functions for the
actual implementation.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-21 10:53:45 +01:00
Sebastiaan van Stijn
09ea6744fe
pkg/sysinfo: remove github.com/docker/go-units dependency
It was only used in a test, and only for a single const; define
it locally.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-21 10:53:45 +01:00
Sebastiaan van Stijn
6a516acb2e
pkg/system: move memory-info types to pkg/systeminfo
These types and functions are more closely related to the functionality
provided by pkg/systeminfo, and used in conjunction with the other functions
in that package, so moving them there.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-21 10:53:45 +01:00
Sebastiaan van Stijn
6919b9879b
pkg/sysinfo: unify NumCPU implementation
Use a single exported implementation, so that we can maintain the
GoDoc string in one place, and use non-exported functions for the
actual implementation (which were already in place).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-21 10:53:42 +01:00
Sebastiaan van Stijn
298d3aa8b8
Merge pull request #44515 from thaJeztah/move_ioutils_tempdir
pkg/ioutils: TempDir: move to pkg/longpath
2022-12-21 10:37:50 +01:00
Sebastiaan van Stijn
c63ea32a17
pkg/ioutils: TempDir: move to pkg/longpath
This utility wasn't very related to all other utilities in pkg/ioutils.
Moving it to longpath to also make it more clear what it does.

It looks like there's only a single (public) external consumer of this
utility, and only used in a test, and it's not 100% clear if it was
intentional to use our package, of if it was a case of "I actually meant
`io/ioutil.MkdirTemp`" so we could consider skipping the alias.

While moving the package, I also renamed `TempDir` to `MkdirTemp`, which
is the signature it matches in "os" from stdlib.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-20 23:24:12 +01:00
Sebastiaan van Stijn
3314f4ef09
pkg/ioutils: unify TempDir implementation
This allows us to maintain a single GoDoc string to describe
what it's used for.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-20 23:23:59 +01:00