machine 0.3.1-rc1 panic when running commands
Environment:
- OS X
- Previously running docker-machine 0.3.0; upgraded to
docker-machine version 0.3.1-rc1 (993f2db) - Drivers in use:
amazonec2,softlayer,virtualbox, andnone
I am now getting panics anytime I run any command that reads my amazonec2 or none based configs, such as docker-machine ls or docker-machine ssh <instance-name>. I can do a docker-machine ssh successfully to instances utilizing the softlayer and virtualbox drivers but not amazonec2 and none drivers.
My config files (with secrets removed) https://gist.github.com/mbentley/40fba8ae44bdfe39327c
These configs have been around for quite some time and I know that @ehazlett and I did some hacking to migrate them around like 0.1.0 or so.
Output from amazonec2 driver when attempting to docker-machine ssh:
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x1697e1]
goroutine 1 [running]:
github.com/docker/machine/libmachine.(*Host).LoadConfig(0x208c80320, 0x0, 0x0)
/go/src/github.com/docker/machine/libmachine/host.go:287 +0x3d1
github.com/docker/machine/libmachine.Filestore.loadHost(0x208bf2f20, 0x1f, 0x208c404e0, 0x2c, 0x208c405a0, 0x30, 0x7fff5fbffb0b, 0xd, 0x8, 0x0, ...)
/go/src/github.com/docker/machine/libmachine/filestore.go:34 +0x287
github.com/docker/machine/libmachine.Filestore.Get(0x208bf2f20, 0x1f, 0x208c404e0, 0x2c, 0x208c405a0, 0x30, 0x7fff5fbffb0b, 0xd, 0x667fc0, 0x0, ...)
/go/src/github.com/docker/machine/libmachine/filestore.go:112 +0x65
github.com/docker/machine/libmachine.(*Filestore).Get(0x208c40750, 0x7fff5fbffb0b, 0xd, 0x208c8caf0, 0x0, 0x0)
<autogenerated>:10 +0xcc
github.com/docker/machine/libmachine.(*Provider).Get(0x208c8caf0, 0x7fff5fbffb0b, 0xd, 0x0, 0x0, 0x0)
/go/src/github.com/docker/machine/libmachine/provider.go:79 +0x66
github.com/docker/machine/commands.cmdSsh(0x208c580c0)
/go/src/github.com/docker/machine/commands/ssh.go:37 +0x486
github.com/codegangsta/cli.Command.Run(0x7765d0, 0x3, 0x0, 0x0, 0x859b90, 0x30, 0x821830, 0x26, 0x0, 0x0, ...)
/go/src/github.com/docker/machine/Godeps/_workspace/src/github.com/codegangsta/cli/command.go:113 +0x1038
github.com/codegangsta/cli.(*App).Run(0x208c10680, 0x208bde000, 0x3, 0x3, 0x0, 0x0)
/go/src/github.com/docker/machine/Godeps/_workspace/src/github.com/codegangsta/cli/app.go:156 +0xcf7
main.main()
/go/src/github.com/docker/machine/main.go:114 +0x9bc
goroutine 2 [runnable]:
runtime.forcegchelper()
/usr/src/go/src/runtime/proc.go:90
runtime.goexit()
/usr/src/go/src/runtime/asm_amd64.s:2232 +0x1
goroutine 3 [runnable]:
runtime.bgsweep()
/usr/src/go/src/runtime/mgc0.go:82
runtime.goexit()
/usr/src/go/src/runtime/asm_amd64.s:2232 +0x1
goroutine 4 [runnable]:
runtime.runfinq()
/usr/src/go/src/runtime/malloc.go:712
runtime.goexit()
/usr/src/go/src/runtime/asm_amd64.s:2232 +0x1
goroutine 5 [runnable]:
os/signal.loop()
/usr/src/go/src/os/signal/signal_unix.go:19
created by os/signal.init·1
/usr/src/go/src/os/signal/signal_unix.go:27 +0x35
Output from none driver when attempting to docker-machine ssh:
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x1697e1]
goroutine 1 [running]:
github.com/docker/machine/libmachine.(*Host).LoadConfig(0x208c96050, 0x0, 0x0)
/go/src/github.com/docker/machine/libmachine/host.go:287 +0x3d1
github.com/docker/machine/libmachine.Filestore.loadHost(0x208c88200, 0x1f, 0x208c3ea80, 0x2c, 0x208c3eb40, 0x30, 0x7fff5fbffb0b, 0x8, 0x8, 0x0, ...)
/go/src/github.com/docker/machine/libmachine/filestore.go:34 +0x287
github.com/docker/machine/libmachine.Filestore.Get(0x208c88200, 0x1f, 0x208c3ea80, 0x2c, 0x208c3eb40, 0x30, 0x7fff5fbffb0b, 0x8, 0x667fc0, 0x0, ...)
/go/src/github.com/docker/machine/libmachine/filestore.go:112 +0x65
github.com/docker/machine/libmachine.(*Filestore).Get(0x208c3ecf0, 0x7fff5fbffb0b, 0x8, 0x208c8e5e0, 0x0, 0x0)
<autogenerated>:10 +0xcc
github.com/docker/machine/libmachine.(*Provider).Get(0x208c8e5e0, 0x7fff5fbffb0b, 0x8, 0x0, 0x0, 0x0)
/go/src/github.com/docker/machine/libmachine/provider.go:79 +0x66
github.com/docker/machine/commands.cmdSsh(0x208c7a0c0)
/go/src/github.com/docker/machine/commands/ssh.go:37 +0x486
github.com/codegangsta/cli.Command.Run(0x7765d0, 0x3, 0x0, 0x0, 0x859b90, 0x30, 0x821830, 0x26, 0x0, 0x0, ...)
/go/src/github.com/docker/machine/Godeps/_workspace/src/github.com/codegangsta/cli/command.go:113 +0x1038
github.com/codegangsta/cli.(*App).Run(0x208c105b0, 0x208bde000, 0x3, 0x3, 0x0, 0x0)
/go/src/github.com/docker/machine/Godeps/_workspace/src/github.com/codegangsta/cli/app.go:156 +0xcf7
main.main()
/go/src/github.com/docker/machine/main.go:114 +0x9bc
goroutine 2 [runnable]:
runtime.forcegchelper()
/usr/src/go/src/runtime/proc.go:90
runtime.goexit()
/usr/src/go/src/runtime/asm_amd64.s:2232 +0x1
goroutine 3 [runnable]:
runtime.bgsweep()
/usr/src/go/src/runtime/mgc0.go:82
runtime.goexit()
/usr/src/go/src/runtime/asm_amd64.s:2232 +0x1
goroutine 4 [runnable]:
runtime.runfinq()
/usr/src/go/src/runtime/malloc.go:712
runtime.goexit()
/usr/src/go/src/runtime/asm_amd64.s:2232 +0x1
goroutine 5 [runnable]:
os/signal.loop()
/usr/src/go/src/os/signal/signal_unix.go:19
created by os/signal.init·1
/usr/src/go/src/os/signal/signal_unix.go:27 +0x35
After doing some comparisons from a newly generated config for amazonec2 and mine, I am seeing some major differences. "HostOptions": { and "AuthOptions": { seem to be the big offenders that are different. Just in testing, I was able to add some of those lines and I can at least do a docker-machine ls with a stripped down config of a single machine but it looks like it is failing to migrate configuration data, assuming there are changes.
Argh, I suspect it's related to https://github.com/docker/machine/pull/1263, unfortunately I may have to revert that PR.
cc @ehazlett WDYT about this?
I'd be happy to test a binary with #1263 reverted if that would help or I can ship you the complete config of an instance for testing... I trust you :)
Alright @ehazlett I know the underlying cause and want to know your take / how you think we should handle this.
If the user did not do anything which is performed through "run action with context" (e.g. start, stop, and other verbs which take multiple arguments on the CLI) on a new machine version, then the migration will happen in-memory but the config will not be saved to disk. In Matt's case this is b0rking now because we removed that migration code but his config never actually got migrated on disk, just in the Machine binary's internal representation each time. And now, since the migration code is gone, it's panicking.
My take is to maybe do something like this:
- Add the migration code back in (revert that PR) for this release.
- Also add a field to the
config.jsonforConfigVersion - Check when that field gets unmarshalled, if it is empty.
- If it is empty, perform the migration, and then save the config. That way, all old configs will definitely get migrated and saved, but we won't be doing this migration and save every single time we read configs from disk.
This will clean up the remaining users who have the old flat config and we should be able to safely remove it in a release or two, in addition to setting us up for a more proper migration structure in the future (since we can check versions). Open to other ideas if you have them of course.
@nathanleclaire thanks for the digging and +1 to the course of action.
https://github.com/docker/machine/pull/1564 should fix this issue.
Random suggestion - might be a good idea to cut another 0.3.x release with this patch if possible. Default install via homebrew (brew install docker-machine) is still picking up 0.3.1 with this bug.
No idea if it's possible/level of difficulty, just a polite suggestion :smile:
@p5k6 Please try the RC! https://github.com/docker/machine/releases
Or, if you are very keen on brew, this should work for master: brew install --HEAD docker-machine
Yep - I did the HEAD install (as did my coworker who was affected) - working for me now. More of a heads up that default brew install is currently broken is all.
Thanks for the quick reply!
No problem glad it's fixed @p5k6 !