• Jan Safranek's avatar
    Fixed races in Cinder volume attach/detach. · 220163f6
    Jan Safranek authored
    Add a mutex to guard SetUpAt() and TearDownAt() calls - they should not
    run in parallel.  There is a race in these calls when there are two pods
    using the same volume, one of them is dying and the other one starting.
    
    TearDownAt() checks that a volume is not needed by any pods and detaches the
    volume. It does so by counting how many times is the volume mounted
    (GetMountRefs() call below).
    
    When SetUpAt() of the starting pod already attached the volume and did not mount
    it yet, TearDownAt() of the dying pod will detach it - GetMountRefs() does not
    count with this volume.
    
    These two threads run in parallel:
    
     dying pod.TearDownAt("myVolume")          starting pod.SetUpAt("myVolume")
       |                                       |
       |                                       AttachDisk("myVolume")
       refs, err := mount.GetMountRefs()       |
       Unmount("myDir")                        |
       if refs == 1 {                          |
       |  |                                    Mount("myVolume", "myDir")
       |  |                                    |
       |  DetachDisk("myVolume")               |
       |                                       start containers - OOPS! The volume is detached!
       |
       finish the pod cleanup
    
    
    Also, add some logs to cinder plugin for easier debugging in the future, add
    a test and update the fake mounter to know about bind mounts.
    220163f6
Name
Last commit
Last update
Godeps Loading commit data...
api/swagger-spec Loading commit data...
build Loading commit data...
cluster Loading commit data...
cmd Loading commit data...
contrib Loading commit data...
docs Loading commit data...
examples Loading commit data...
hack Loading commit data...
hooks Loading commit data...
pkg Loading commit data...
plugin Loading commit data...
release Loading commit data...
test Loading commit data...
third_party Loading commit data...
www Loading commit data...
.generated_docs Loading commit data...
.gitignore Loading commit data...
.travis.yml Loading commit data...
CHANGELOG.md Loading commit data...
CONTRIB.md Loading commit data...
CONTRIBUTING.md Loading commit data...
DESIGN.md Loading commit data...
LICENSE Loading commit data...
Makefile Loading commit data...
README.md Loading commit data...
Vagrantfile Loading commit data...
code-of-conduct.md Loading commit data...
logo.pdf Loading commit data...
logo.png Loading commit data...
logo.svg Loading commit data...
logo_usage_guidelines.md Loading commit data...
shippable.yml Loading commit data...