• 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
..
atomic Loading commit data...
bandwidth Loading commit data...
chmod Loading commit data...
chown Loading commit data...
config Loading commit data...
dbus Loading commit data...
deployment Loading commit data...
errors Loading commit data...
exec Loading commit data...
flushwriter Loading commit data...
hash Loading commit data...
httpstream Loading commit data...
intstr Loading commit data...
io Loading commit data...
iptables Loading commit data...
jsonpath Loading commit data...
keymutex Loading commit data...
labels Loading commit data...
limitwriter Loading commit data...
mount Loading commit data...
net Loading commit data...
node Loading commit data...
oom Loading commit data...
parsers Loading commit data...
pod Loading commit data...
procfs Loading commit data...
proxy Loading commit data...
rand Loading commit data...
runtime Loading commit data...
selinux Loading commit data...
sets Loading commit data...
slice Loading commit data...
strategicpatch Loading commit data...
strings Loading commit data...
sysctl Loading commit data...
testing Loading commit data...
validation Loading commit data...
wait Loading commit data...
workqueue Loading commit data...
wsstream Loading commit data...
yaml Loading commit data...
backoff.go Loading commit data...
backoff_test.go Loading commit data...
bool_flag.go Loading commit data...
cache.go Loading commit data...
cache_test.go Loading commit data...
clock.go Loading commit data...
clock_test.go Loading commit data...
configuration_map.go Loading commit data...
crlf.go Loading commit data...
crypto.go Loading commit data...
deadlock-detector.go Loading commit data...
deadlock-detector_test.go Loading commit data...
diff.go Loading commit data...
doc.go Loading commit data...
env.go Loading commit data...
env_test.go Loading commit data...
flags.go Loading commit data...
line_delimiter.go Loading commit data...
line_delimiter_test.go Loading commit data...
logs.go Loading commit data...
resource_container_linux.go Loading commit data...
resource_container_unsupported.go Loading commit data...
runner.go Loading commit data...
runner_test.go Loading commit data...
ssh.go Loading commit data...
ssh_test.go Loading commit data...
string_flag.go Loading commit data...
template.go Loading commit data...
template_test.go Loading commit data...
throttle.go Loading commit data...
throttle_test.go Loading commit data...
trace.go Loading commit data...
umask.go Loading commit data...
umask_windows.go Loading commit data...
util.go Loading commit data...
util_test.go Loading commit data...
uuid.go Loading commit data...