• 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
..
admission Loading commit data...
api Loading commit data...
apimachinery Loading commit data...
apis Loading commit data...
apiserver Loading commit data...
auth Loading commit data...
capabilities Loading commit data...
client Loading commit data...
cloudprovider Loading commit data...
controller Loading commit data...
conversion Loading commit data...
credentialprovider Loading commit data...
fieldpath Loading commit data...
fields Loading commit data...
genericapiserver Loading commit data...
healthz Loading commit data...
httplog Loading commit data...
hyperkube Loading commit data...
kubectl Loading commit data...
kubelet Loading commit data...
kubemark Loading commit data...
labels Loading commit data...
master Loading commit data...
metrics Loading commit data...
probe Loading commit data...
proxy Loading commit data...
registry Loading commit data...
runtime Loading commit data...
securitycontext Loading commit data...
serviceaccount Loading commit data...
storage Loading commit data...
types Loading commit data...
ui Loading commit data...
util Loading commit data...
version Loading commit data...
volume Loading commit data...
watch Loading commit data...