projectatomic / docker

Docker - the open-source application container engine
http://www.docker.com
Apache License 2.0
81 stars 58 forks source link

Don't create source directory while the daemon is being shutdown #327

Closed TomSweeneyRedHat closed 6 years ago

TomSweeneyRedHat commented 6 years ago

Signed-off-by: TomSweeneyRedHat tsweeney@redhat.com

- What I did

Ported the patch from https://github.com/moby/moby/pull/33330 into this branch. The problem is the /var/run/docker.sock file can with the right conditions and bad timing be created as a directory rather than a link when the daemon is shutting down. Without this change docker would not restart after this timing issue hit until the /var/run/docker.sock directory was removed.

Once this is approved, I will do the same in 1.13.1-RHEL

- How I did it

vi is my friend.

- How to verify it The easiest way unfortunately calls for a code change. Please reference the test methodology in https://github.com/moby/moby/pull/33330. The file daemon/oci_linux.go needs to be modified and then docker needs to be compiled and installed after the modification.

- Description for the changelog Don't create /var/run/docker.sock as a directory when the daemon is shutting down

** - Testing:

[root@localhost run]# systemctl start docker
[root@localhost run]# docker run -ti --restart always -v /var/run/docker.sock:/sock alpine
/ # exit
[root@localhost run]# systemctl stop docker
[root@localhost run]# systemctl start docker
[root@localhost run]# docker run -ti --restart always -v /var/run/docker.sock:/sock alpine
/ # exit
[root@localhost run]# systemctl stop docker
[root@localhost run]# systemctl start docker
[root@localhost run]# ls -alF docker.sock
srw-rw----. 1 root root 0 Oct 10 19:47 docker.sock=

From journalctl with the new log entry showing that the error condition is being handled correctly:

Oct 10 19:46:46 localhost.localdomain dockerd-current[4884]: time="2018-10-10T19:46:46.514665986-04:00" level=error msg="restartmanger wait error: Could not mount \"/var/run/docker.sock\" to container while the daemon is shutting down."
runcom commented 6 years ago

ping me when you've re-checked everything Tom - lgtm though as long as it works and compiles, please open another PR for the rhel branch

TomSweeneyRedHat commented 6 years ago

@runcom finished testing and code verification, gtg.

runcom commented 6 years ago

Tom the same PR is needed for the rhel branch

TomSweeneyRedHat commented 6 years ago

Thanks for the merge @runcom. Will tend to the rhel branch first thing tomorrow morn.

TomSweeneyRedHat commented 6 years ago

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1466479