Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: we must call Restore container after initialize network Mgr #1422

Merged
merged 1 commit into from
May 28, 2018

Conversation

HusterWan
Copy link
Contributor

@HusterWan HusterWan commented May 27, 2018

Signed-off-by: Michael Wan [email protected]

Ⅰ. Describe what this PR did

fix bug: containerMgr use the networkMgr struct before initialize it that will occur panic: runtime error: invalid memory address or nil pointer dereference

when start pouchd, we will call containerMgr.Restore to restore all running containers, if the container has already exited but disk file record the status is running, we must call markStoppedAndRelease method to clean the container's resources and mark it stopped.

markStoppedAndRelease method will call containerMgr.networkMgr, so if networkMgr not initialized, there will painc:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x48 pc=0x17d2e14]

goroutine 47 [running]:
github.com/alibaba/pouch/daemon/mgr.(*ContainerManager).markStoppedAndRelease(0xc4200e03f0, 0xc4203a6000, 0x0, 0x1, 0x1)
	/tmp/pouchbuild/src/github.com/alibaba/pouch/daemon/mgr/container.go:1643 +0x324
github.com/alibaba/pouch/daemon/mgr.(*ContainerManager).Restore.func1(0x26b4a40, 0xc4203a6000, 0x9b6, 0x1c12bc0)
	/tmp/pouchbuild/src/github.com/alibaba/pouch/daemon/mgr/container.go:212 +0x5cf
github.com/alibaba/pouch/pkg/meta.(*Store).ForEach(0xc420297020, 0xc420288d00, 0xc420561cb0, 0xc420561ca0)
	/tmp/pouchbuild/src/github.com/alibaba/pouch/pkg/meta/store.go:197 +0x1e9
github.com/alibaba/pouch/daemon/mgr.(*ContainerManager).Restore(0xc4200e03f0, 0x26c9280, 0xc4201e6240, 0x1, 0xc4202fa990)
	/tmp/pouchbuild/src/github.com/alibaba/pouch/daemon/mgr/container.go:224 +0x8f
github.com/alibaba/pouch/daemon/mgr.NewContainerManager(0x26c9280, 0xc4201e6240, 0xc420297020, 0x26d34e0, 0xc420390140, 0x26ce480, 0xc4201e62c0, 0x26ce4e0, 0xc42000e0a0, 0x271a960, ...)
	/tmp/pouchbuild/src/github.com/alibaba/pouch/daemon/mgr/container.go:179 +0x509
github.com/alibaba/pouch/internal.GenContainerMgr(0x26c9280, 0xc4201e6240, 0x26cee40, 0xc420341540, 0xc42000e0a0, 0x0, 0x0, 0x0)
	/tmp/pouchbuild/src/github.com/alibaba/pouch/internal/generator.go:28 +0x1c7
github.com/alibaba/pouch/daemon.(*Daemon).Run(0xc420341540, 0x0, 0x0)
	/tmp/pouchbuild/src/github.com/alibaba/pouch/daemon/daemon.go:166 +0x22b
main.runDaemon.func2(0xc420296f00, 0xc420341540)
	/tmp/pouchbuild/src/github.com/alibaba/pouch/main.go:202 +0x2b
created by main.runDaemon
	/tmp/pouchbuild/src/github.com/alibaba/pouch/main.go:200 +0x5aa

Ⅱ. Does this pull request fix one issue?

fixes #1421

Ⅲ. Describe how you did it

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

@pouchrobot pouchrobot added areas/network kind/bug This is bug report for project size/S labels May 27, 2018
@HusterWan HusterWan requested a review from rudyfly May 27, 2018 09:12
@codecov-io
Copy link

Codecov Report

Merging #1422 into master will increase coverage by 22.52%.
The diff coverage is 33.33%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master    #1422       +/-   ##
===========================================
+ Coverage   16.23%   38.75%   +22.52%     
===========================================
  Files         200      250       +50     
  Lines       13580    16629     +3049     
===========================================
+ Hits         2205     6445     +4240     
+ Misses      11220     9356     -1864     
- Partials      155      828      +673
Impacted Files Coverage Δ
daemon/daemon.go 56.25% <0%> (ø)
daemon/mgr/container.go 49.44% <100%> (+49.44%) ⬆️
storage/volume/driver/driver.go 51.23% <0%> (ø)
cri/stream/remotecommand/websocket.go 0% <0%> (ø)
pkg/system/machine.go 75% <0%> (ø)
registry/auth.go 54.12% <0%> (ø)
storage/volume/modules/ceph/types.go 0% <0%> (ø)
storage/volume/modules/tmpfs/tmpfs.go 16.39% <0%> (ø)
cri/stream/httpstream/spdy/upgrade.go 0% <0%> (ø)
pkg/term/term.go 0% <0%> (ø)
... and 114 more

@shaloulcy
Copy link
Contributor

LGTM

1 similar comment
@rudyfly
Copy link
Collaborator

rudyfly commented May 28, 2018

LGTM

@pouchrobot pouchrobot added the LGTM one maintainer or community participant agrees to merge the pull reuqest. label May 28, 2018
@rudyfly rudyfly merged commit dfdb8fa into AliyunContainerService:master May 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
areas/network kind/bug This is bug report for project LGTM one maintainer or community participant agrees to merge the pull reuqest. size/S
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[panic] restart pouchd with the newest code panic
5 participants