moby / swarmkit

A toolkit for orchestrating distributed systems at any scale. It includes primitives for node discovery, raft-based consensus, task scheduling and more.
Apache License 2.0
3.38k stars 616 forks source link

Crash when listing networks after adding network with unknown/invalid driver #896

Open marccampbell opened 8 years ago

marccampbell commented 8 years ago

Output is below. There doesn't appear to be validation that the driver exists when adding a network. Once a network is added using swarmctl and it's invalid or not found, requests to swarmctl network ls crashes.

$ swarmctl network create --name test --driver bridge
$ swarmctl network ls
ID  Name  Driver
--  ----  ------
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x46dcb5]

goroutine 1 [running]:
panic(0xb7b300, 0xc82000e0f0)
    /usr/local/go/src/runtime/panic.go:481 +0x3e6
github.com/docker/swarmkit/cmd/swarmctl/network.glob.func3.2(0xc8200524d0)
    /go/src/github.com/docker/swarmkit/cmd/swarmctl/network/list.go:48 +0x2a5
github.com/docker/swarmkit/cmd/swarmctl/network.glob.func3(0x103c800, 0x10648d8, 0x0, 0x0, 0x0, 0x0)
    /go/src/github.com/docker/swarmkit/cmd/swarmctl/network/list.go:57 +0x450
github.com/docker/swarmkit/vendor/github.com/spf13/cobra.(*Command).execute(0x103c800, 0x10648d8, 0x0, 0x0, 0x0, 0x0)
    /go/src/github.com/docker/swarmkit/vendor/github.com/spf13/cobra/command.go:565 +0x62c
github.com/docker/swarmkit/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0x103f800, 0x103c800, 0x0, 0x0)
    /go/src/github.com/docker/swarmkit/vendor/github.com/spf13/cobra/command.go:656 +0x55c
main.main()
    /go/src/github.com/docker/swarmkit/cmd/swarmctl/main.go:18 +0x37
dperny commented 8 years ago

can reproduce. also, other commands work, including swarmctl network inspect on the problem network. also, removing the problem network restores normal functionality of swarmctl network ls. i'll take a look.

the crash is in swarmctl. swarmd shows but does not go down.

ERRO[2903]  Failed allocation for network 8o9gxgs5fq4xgv7e3y6fdv91i: failed during network allocation for network 8o9gxgs5fq4xgv7e3y6fdv91i: failed during network allocation for 8o9gxgs5fq4xgv7e3y6fdv91i: could not resolve network driver asfd

on removal, swarmd shows error

ERRO[3065] Failed during network free for network 8o9gxgs5fq4xgv7e3y6fdv91i: could not get networker state for network 8o9gxgs5fq4xgv7e3y6fdv91i
dperny commented 8 years ago

/cc @mrjana

aluzzardi commented 8 years ago

Thanks @marccampbell

/cc @mavenugo

mavenugo commented 8 years ago

Will take a look @ it later today.

aluzzardi commented 8 years ago

/cc @mrjana @mavenugo

boonkerz commented 5 years ago

bin/swarmctl network create --name test --driver does_not_exists Error: plugin does_not_exists not supported

not reproducible