1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/daemon
Sebastiaan van Stijn 651e694508
Prevent panic on network attach
In situations where `container.NetworkSettings` was not nil, but
`container.NetworkSettings.Networks` was, a panic could occur:

```
2019-06-10 15:26:50.548309 I | http: panic serving @: assignment to entry in nil map
goroutine 1376 [running]:
net/http.(*conn).serve.func1(0xc4211068c0)
	/usr/local/go/src/net/http/server.go:1726 +0xd2
panic(0x558939d7e1e0, 0x55893a0c4410)
	/usr/local/go/src/runtime/panic.go:502 +0x22d
github.com/docker/docker/daemon.(*Daemon).updateNetworkSettings(0xc42090c5a0, 0xc420fb6fc0, 0x55893a101140, 0xc4210e0540, 0xc42112aa80, 0xc4217d77a0, 0x0)
	/go/src/github.com/docker/docker/daemon/container_operations.go:275 +0x40e
github.com/docker/docker/daemon.(*Daemon).updateNetworkConfig(0xc42090c5a0, 0xc420fb6fc0, 0x55893a101140, 0xc4210e0540, 0xc42112aa80, 0x55893a101101, 0xc4210e0540, 0x0)
	/go/src/github.com/docker/docker/daemon/container_operations.go:683 +0x219
github.com/docker/docker/daemon.(*Daemon).connectToNetwork(0xc42090c5a0, 0xc420fb6fc0, 0xc420e8290f, 0x40, 0xc42112aa80, 0x558937eabd01, 0x0, 0x0)
	/go/src/github.com/docker/docker/daemon/container_operations.go:728 +0x1cb
github.com/docker/docker/daemon.(*Daemon).ConnectToNetwork(0xc42090c5a0, 0xc420fb6fc0, 0xc420e8290f, 0x40, 0xc42112aa80, 0x0, 0x0)
	/go/src/github.com/docker/docker/daemon/container_operations.go:1046 +0x2b3
github.com/docker/docker/daemon.(*Daemon).ConnectContainerToNetwork(0xc42090c5a0, 0xc4214ca580, 0x40, 0xc420e8290f, 0x40, 0xc42112aa80, 0x2, 0xe600000000000001)
	/go/src/github.com/docker/docker/daemon/network.go:450 +0xa1
github.com/docker/docker/api/server/router/network.(*networkRouter).postNetworkConnect(0xc42121bbc0, 0x55893a0edee0, 0xc420de7cb0, 0x55893a0ec2e0, 0xc4207f0e00, 0xc420173600, 0xc420de7980, 0x5589394707cc, 0x5)
	/go/src/github.com/docker/docker/api/server/router/network/network_routes.go:278 +0x330
github.com/docker/docker/api/server/router/network.(*networkRouter).(github.com/docker/docker/api/server/router/network.postNetworkConnect)-fm(0x55893a0edee0, 0xc420de7cb0, 0x55893a0ec2e0, 0xc4207f0e00, 0xc420173600, 0xc420de7980, 0x558937fd89dc, 0x558939f2cec0)
	/go/src/github.com/docker/docker/api/server/router/network/network.go:37 +0x6b
github.com/docker/docker/api/server/middleware.ExperimentalMiddleware.WrapHandler.func1(0x55893a0edee0, 0xc420de7cb0, 0x55893a0ec2e0, 0xc4207f0e00, 0xc420173600, 0xc420de7980, 0x55893a0edee0, 0xc420de7cb0)
	/go/src/github.com/docker/docker/api/server/middleware/experimental.go:26 +0xda
github.com/docker/docker/api/server/middleware.VersionMiddleware.WrapHandler.func1(0x55893a0edee0, 0xc420de7a70, 0x55893a0ec2e0, 0xc4207f0e00, 0xc420173600, 0xc420de7980, 0x0, 0x0)
	/go/src/github.com/docker/docker/api/server/middleware/version.go:62 +0x401
github.com/docker/docker/pkg/authorization.(*Middleware).WrapHandler.func1(0x55893a0edee0, 0xc420de7a70, 0x55893a0ec2e0, 0xc4207f0e00, 0xc420173600, 0xc420de7980, 0x0, 0x558939640868)
	/go/src/github.com/docker/docker/pkg/authorization/middleware.go:59 +0x7ab
github.com/docker/docker/api/server/middleware.DebugRequestMiddleware.func1(0x55893a0edee0, 0xc420de7a70, 0x55893a0ec2e0, 0xc4207f0e00, 0xc420173600, 0xc420de7980, 0x55893a0edee0, 0xc420de7a70)
	/go/src/github.com/docker/docker/api/server/middleware/debug.go:53 +0x4b8
github.com/docker/docker/api/server.(*Server).makeHTTPHandler.func1(0x55893a0ec2e0, 0xc4207f0e00, 0xc420173600)
	/go/src/github.com/docker/docker/api/server/server.go:141 +0x19a
net/http.HandlerFunc.ServeHTTP(0xc420e0c0e0, 0x55893a0ec2e0, 0xc4207f0e00, 0xc420173600)
	/usr/local/go/src/net/http/server.go:1947 +0x46
github.com/docker/docker/vendor/github.com/gorilla/mux.(*Router).ServeHTTP(0xc420ce5950, 0x55893a0ec2e0, 0xc4207f0e00, 0xc420173600)
	/go/src/github.com/docker/docker/vendor/github.com/gorilla/mux/mux.go:103 +0x228
github.com/docker/docker/api/server.(*routerSwapper).ServeHTTP(0xc421078330, 0x55893a0ec2e0, 0xc4207f0e00, 0xc420173600)
	/go/src/github.com/docker/docker/api/server/router_swapper.go:29 +0x72
net/http.serverHandler.ServeHTTP(0xc420902f70, 0x55893a0ec2e0, 0xc4207f0e00, 0xc420173600)
	/usr/local/go/src/net/http/server.go:2697 +0xbe
net/http.(*conn).serve(0xc4211068c0, 0x55893a0ede20, 0xc420d81440)
	/usr/local/go/src/net/http/server.go:1830 +0x653
created by net/http.(*Server).Serve
	/usr/local/go/src/net/http/server.go:2798 +0x27d
```

I have not been able to reproduce the situation, but preventing a panic should
not hurt.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-07-22 19:44:14 +02:00
..
cluster Merge pull request #38441 from sirlatrom/swarm_plugin_env 2019-07-08 15:26:55 -04:00
config Merge pull request #39329 from tiborvass/buildkit-honor-daemon-dnsconfig 2019-07-16 16:19:20 +02:00
discovery
events
exec Handle blocked I/O of exec'd processes 2019-06-21 12:02:15 -04:00
graphdriver Merge pull request #39270 from kolyshkin/moar-aufs-fixes 2019-06-11 20:43:50 +02:00
images Merge pull request #39217 from microsoft/jjh/lcowfromscratch 2019-07-03 10:09:46 +08:00
initlayer
links
listeners
logger Be more conservative for Windows in TestFrequency for Splunk 2019-07-17 13:13:50 -07:00
names
network Network: add support for 'dangling' filter 2019-02-27 15:08:44 -05:00
stats stats: avoid cgo in collector 2019-06-05 22:21:11 -07:00
testdata
apparmor_default.go
apparmor_default_unsupported.go
archive.go daemon: fix docker cp when container source is / 2019-06-13 06:31:15 +00:00
archive_tarcopyoptions.go
archive_tarcopyoptions_unix.go
archive_tarcopyoptions_windows.go
archive_unix.go
archive_windows.go
attach.go
auth.go
changes.go
checkpoint.go Merge pull request #38405 from rst0git/enable-cr-tty 2019-03-21 14:12:49 -07:00
cluster.go
commit.go Windows: (WCOW) Generate OCI spec that remote runtime can escape 2019-03-12 18:41:55 -07:00
configs.go
configs_linux.go
configs_unsupported.go
configs_windows.go
container.go
container_linux.go
container_operations.go Prevent panic on network attach 2019-07-22 19:44:14 +02:00
container_operations_unix.go Merge pull request #38579 from thaJeztah/fix_net_host_systemd_resolved 2019-03-21 15:34:48 -07:00
container_operations_windows.go Move EnableServiceDiscoveryOnDefaultNetwork to container-operations 2019-03-20 18:45:20 +01:00
container_unix_test.go
container_windows.go
create.go Merge pull request #38918 from thaJeztah/bump_selinux 2019-03-28 17:27:03 -07:00
create_test.go
create_unix.go Entropy cannot be saved 2019-06-07 11:54:45 +01:00
create_windows.go Entropy cannot be saved 2019-06-07 11:54:45 +01:00
daemon.go Remove skip evaluation of symlinks to data root on IoT Core 2019-07-13 23:44:51 +02:00
daemon_linux.go Remove skip evaluation of symlinks to data root on IoT Core 2019-07-13 23:44:51 +02:00
daemon_linux_test.go Export all spec generation opts 2019-04-10 15:38:36 -04:00
daemon_test.go
daemon_unix.go Merge pull request #39496 from cpuguy83/fix_missing_dir_cleanup_file 2019-07-12 13:39:58 -04:00
daemon_unix_test.go bugfix: fetch the right device number which great than 255 2019-05-16 15:32:59 +08:00
daemon_unsupported.go
daemon_windows.go Remove skip evaluation of symlinks to data root on IoT Core 2019-07-13 23:44:51 +02:00
daemon_windows_test.go
debugtrap_unix.go
debugtrap_unsupported.go
debugtrap_windows.go
delete.go Updates daemon's remove link method to use more verbose error output. 2019-04-25 13:08:08 -04:00
delete_test.go
dependency.go
devices_linux.go Add DeviceRequests to HostConfig to support NVIDIA GPUs 2019-03-18 17:19:45 +00:00
disk_usage.go
errors.go Merge pull request #38541 from Microsoft/jjh/containerd 2019-03-19 21:09:19 -07:00
events.go
events_test.go
exec.go Merge pull request #38522 from cpuguy83/fix_timers 2019-06-07 13:16:46 +02:00
exec_linux.go Export all spec generation opts 2019-04-10 15:38:36 -04:00
exec_linux_test.go
exec_windows.go Windows: (WCOW) Generate OCI spec that remote runtime can escape 2019-03-12 18:41:55 -07:00
export.go Add chroot for tar packing operations 2019-06-03 09:45:29 -07:00
health.go LCOW: fix using wrong shell for healthchecks 2019-06-21 13:58:25 +02:00
health_test.go
info.go Adding OS version info to the nodes' Info struct 2019-06-06 22:40:10 +00:00
info_test.go
info_unix.go Make cgroup namespaces configurable 2019-05-07 10:22:16 -07:00
info_unix_test.go
info_windows.go Make cgroup namespaces configurable 2019-05-07 10:22:16 -07:00
inspect.go
inspect_linux.go
inspect_test.go
inspect_windows.go
keys.go
keys_unsupported.go
kill.go do not stop health check before sending signal 2019-07-14 11:53:13 +02:00
licensing.go
licensing_test.go
links.go
list.go
list_test.go Switch to google/uuid 2019-03-13 14:13:58 +00:00
list_unix.go
list_windows.go
logdrivers_linux.go
logdrivers_windows.go
logs.go
logs_test.go
metrics.go Adding OS version info to the nodes' Info struct 2019-06-06 22:40:10 +00:00
metrics_unix.go
metrics_unsupported.go
monitor.go Merge pull request #39497 from cpuguy83/better_container_error 2019-07-15 13:53:58 -04:00
mounts.go
names.go Entropy cannot be saved 2019-06-07 11:54:45 +01:00
network.go Move EnableServiceDiscoveryOnDefaultNetwork to container-operations 2019-03-20 18:45:20 +01:00
nvidia_linux.go daemon: fix bug in nvidia device registration 2019-03-29 16:07:01 -07:00
oci_linux.go Make cgroup namespaces configurable 2019-05-07 10:22:16 -07:00
oci_linux_test.go
oci_utils.go LCOW:Reworking spec builder 2019-03-12 18:41:55 -07:00
oci_windows.go Merge pull request #38541 from Microsoft/jjh/containerd 2019-03-19 21:09:19 -07:00
oci_windows_test.go Making it possible to pass Windows credential specs directly to the engine 2019-03-15 19:20:19 -07:00
pause.go
prune.go
reload.go
reload_test.go
reload_unix.go Make cgroup namespaces configurable 2019-05-07 10:22:16 -07:00
reload_windows.go
rename.go
resize.go Merge pull request #38522 from cpuguy83/fix_timers 2019-06-07 13:16:46 +02:00
resize_test.go
restart.go Windows: Fix restart for Hyper-V containers 2019-02-22 10:37:39 -08:00
seccomp_disabled.go Export all spec generation opts 2019-04-10 15:38:36 -04:00
seccomp_linux.go Export all spec generation opts 2019-04-10 15:38:36 -04:00
seccomp_unsupported.go Export all spec generation opts 2019-04-10 15:38:36 -04:00
secrets.go
secrets_linux.go
secrets_unsupported.go
secrets_windows.go
selinux_linux.go
selinux_unsupported.go
start.go
start_unix.go
start_windows.go LCOWv1:Remote lcow.kernel and lcow.initrd 2019-03-12 19:31:12 -07:00
stats.go ContainerStats: return early on unsupported API versions 2019-07-10 21:47:50 +02:00
stats_collector.go
stats_unix.go
stats_windows.go
stop.go
top_unix.go
top_unix_test.go
top_windows.go Windows: Implement docker top for containerd 2019-03-12 18:41:55 -07:00
trustkey.go Revert "Remove the rest of v1 manifest support" 2019-06-18 00:36:01 +00:00
trustkey_test.go Revert "Remove the rest of v1 manifest support" 2019-06-18 00:36:01 +00:00
unpause.go
update.go
update_linux.go Windows: Experimental: Allow containerd for runtime 2019-03-12 18:41:55 -07:00
update_windows.go Windows: Experimental: Allow containerd for runtime 2019-03-12 18:41:55 -07:00
util_test.go Remove inmemory container map 2019-04-05 15:48:07 -04:00
volumes.go
volumes_linux.go
volumes_linux_test.go
volumes_unit_test.go
volumes_unix.go daemon/mountVolumes(): eliminate MakeRPrivate call 2019-04-09 12:58:38 -07:00
volumes_unix_test.go
volumes_windows.go
wait.go
workdir.go