moby--moby/daemon
Sebastiaan van Stijn b241e2008e
daemon.NewDaemon(): fix network feature detection on first start
Commit 483aa6294b introduced a regression, causing
spurious warnings to be shown when starting a daemon for the first time after
a fresh install:

    docker info
    ...
    WARNING: IPv4 forwarding is disabled
    WARNING: bridge-nf-call-iptables is disabled
    WARNING: bridge-nf-call-ip6tables is disabled

The information shown is incorrect, as checking the corresponding options on
the system, shows that these options are available:

    cat /proc/sys/net/ipv4/ip_forward
    1
    cat /proc/sys/net/bridge/bridge-nf-call-iptables
    1
    cat /proc/sys/net/bridge/bridge-nf-call-ip6tables
    1

The reason this is failing is because the daemon itself reconfigures those
options during networking initialization in `configureIPForwarding()`;
cf4595265e/libnetwork/drivers/bridge/setup_ip_forwarding.go (L14-L25)

Network initialization happens in the `daemon.restore()` function within `daemon.NewDaemon()`:
cf4595265e/daemon/daemon.go (L475-L478)

However, 483aa6294b moved detection of features
earlier in the `daemon.NewDaemon()` function, and collects the system information
(`d.RawSysInfo()`) before we enter `daemon.restore()`;
cf4595265e/daemon/daemon.go (L1008-L1011)

For optimization (collecting the system information comes at a cost), those
results are cached on the daemon, and will only be performed once (using a
`sync.Once`).

This patch:

- introduces a `getSysInfo()` utility, which collects system information without
  caching the results
- uses `getSysInfo()` to collect the preliminary information needed at that
  point in the daemon's lifecycle.
- moves printing warnings to the end of `daemon.NewDaemon()`, after all information
  can be read correctly.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-06-03 17:54:43 +02:00
..
cluster Merge pull request #43524 from thaJeztah/daemon_fix_hosts_validation_step2 2022-05-13 02:42:40 +02:00
config daemon/config: remove uses of pointers for ints 2022-04-29 09:39:34 +02:00
events
exec
graphdriver fix unclosed file-handles in tests 2022-05-31 21:53:38 +02:00
images daemon/images: use gotest.tools for tests, and use sub-tests 2022-05-27 15:36:14 +02:00
initlayer daemon/initlayer: Init(): remove unused stub for Windows 2022-05-11 01:27:47 +02:00
links all: replace strings.Replace with strings.ReplaceAll 2022-05-09 19:45:40 +08:00
listeners
logger daemon/logger: Fix TestConcurrentLogging race test 2022-05-31 14:02:59 +02:00
names
network
stats
testdata
apparmor_default.go
apparmor_default_unsupported.go
archive.go
archive_tarcopyoptions.go
archive_tarcopyoptions_unix.go
archive_tarcopyoptions_windows.go
archive_unix.go
archive_windows.go
attach.go Make it explicit raw|multiplexed stream implementation being used 2022-05-12 11:36:31 +02:00
auth.go
changes.go
checkpoint.go
cluster.go
commit.go
configs.go
configs_linux.go
configs_unsupported.go
configs_windows.go
container.go
container_linux.go
container_operations.go
container_operations_unix.go daemon: killWithSignal, killPossiblyDeadProcess: accept syscall.Signal 2022-05-05 00:53:52 +02:00
container_operations_windows.go
container_unix_test.go
container_windows.go
content.go
create.go
create_test.go
create_unix.go
create_windows.go
daemon.go daemon.NewDaemon(): fix network feature detection on first start 2022-06-03 17:54:43 +02:00
daemon_linux.go daemon: fix daemon.Shutdown, daemon.Cleanup not cleaning up overlay2 mounts 2022-05-29 16:28:13 +02:00
daemon_linux_test.go daemon: fix daemon.Shutdown, daemon.Cleanup not cleaning up overlay2 mounts 2022-05-29 16:28:13 +02:00
daemon_test.go
daemon_unix.go daemon.NewDaemon(): fix network feature detection on first start 2022-06-03 17:54:43 +02:00
daemon_unix_test.go
daemon_unsupported.go daemon.NewDaemon(): fix network feature detection on first start 2022-06-03 17:54:43 +02:00
daemon_windows.go daemon.NewDaemon(): fix network feature detection on first start 2022-06-03 17:54:43 +02:00
daemon_windows_test.go
debugtrap_unix.go
debugtrap_unsupported.go
debugtrap_windows.go
delete.go
delete_test.go
dependency.go
devices_linux.go
disk_usage.go
errors.go
events.go
events_test.go
exec.go libcontainerd: SignalProcess(): accept syscall.Signal 2022-05-05 00:53:49 +02:00
exec_linux.go
exec_linux_test.go
exec_windows.go
export.go
health.go health: Start probe timeout after exec starts 2022-04-28 17:21:03 -04:00
health_test.go
id.go daemon: separate daemon ID from trust-key 2022-05-04 20:17:18 +02:00
info.go
info_unix.go
info_unix_test.go
info_windows.go
inspect.go
inspect_linux.go
inspect_test.go
inspect_windows.go
keys.go
keys_unsupported.go
kill.go daemon: fix some minor nits 2022-05-05 11:27:59 +02:00
licensing.go
licensing_test.go
links.go
list.go
list_test.go
list_unix.go
list_windows.go
logdrivers_linux.go
logdrivers_windows.go
logs.go
logs_test.go
metrics.go health: Start probe timeout after exec starts 2022-04-28 17:21:03 -04:00
metrics_unix.go
metrics_unsupported.go
monitor.go
mounts.go
names.go
network.go
network_windows.go
nvidia_linux.go
oci_linux.go Fix validation of IpcMode, PidMode, UTSMode, CgroupnsMode 2022-05-25 17:41:51 +02:00
oci_linux_test.go
oci_opts.go daemon/linux: Set console size on creation 2022-05-19 07:57:27 +02:00
oci_utils.go
oci_windows.go
oci_windows_test.go
pause.go
prune.go
reload.go daemon/config: remove uses of pointers for ints 2022-04-29 09:39:34 +02:00
reload_test.go
reload_unix.go
reload_windows.go
rename.go
resize.go
resize_test.go
restart.go
runtime_unix.go
runtime_windows.go
seccomp_linux.go Remove "seccomp" build tag 2022-05-12 14:48:35 -07:00
seccomp_linux_test.go Remove "seccomp" build tag 2022-05-12 14:48:35 -07:00
seccomp_unsupported.go
secrets.go
secrets_linux.go
secrets_unsupported.go
secrets_windows.go
start.go
start_unix.go
start_windows.go
stats.go
stats_collector.go
stats_unix.go
stats_windows.go
stop.go container: StopSignal(): return syscall.Signal 2022-05-05 00:53:53 +02:00
top_unix.go
top_unix_test.go
top_windows.go
trustkey.go
trustkey_test.go fix unclosed file-handles in tests 2022-05-31 21:53:38 +02:00
unpause.go
update.go
update_linux.go
update_windows.go
util_test.go libcontainerd: SignalProcess(): accept syscall.Signal 2022-05-05 00:53:49 +02:00
volumes.go introduce CreateMountpoint for parity between binds and mounts 2022-05-19 16:43:06 +02:00
volumes_linux.go
volumes_linux_test.go
volumes_unit_test.go
volumes_unix.go
volumes_windows.go
wait.go
workdir.go