k3s/pkg/volume
Jan Safranek 220163f67d Fixed races in Cinder volume attach/detach.
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.
2016-02-02 14:38:49 +01:00
..
aws_ebs replacing handwritten client in several controllers 2016-01-31 15:42:02 -08:00
cephfs CephFS: Add subdir Option for Changing Mounted Root Directory 2016-02-01 22:01:19 +01:00
cinder Fixed races in Cinder volume attach/detach. 2016-02-02 14:38:49 +01:00
downwardapi replacing handwritten client in several controllers 2016-01-31 15:42:02 -08:00
empty_dir Remove all instances of "/tmp" from unit tests and replace with a common 2016-01-27 16:11:22 -08:00
fc replacing handwritten client in several controllers 2016-01-31 15:42:02 -08:00
flexvolume replacing handwritten client in several controllers 2016-01-31 15:42:02 -08:00
flocker Merge pull request #20080 from nagarjung/flocker_feature 2016-02-02 02:45:14 -08:00
gce_pd Replace runtime reference by pkg 2016-02-01 21:06:44 +08:00
git_repo Merge pull request #19502 from swagiaal/internalize-ownership 2016-01-26 23:06:39 -08:00
glusterfs replacing handwritten client in several controllers 2016-01-31 15:42:02 -08:00
host_path replacing handwritten client in several controllers 2016-01-31 15:42:02 -08:00
iscsi replacing handwritten client in several controllers 2016-01-31 15:42:02 -08:00
nfs replacing handwritten client in several controllers 2016-01-31 15:42:02 -08:00
persistent_claim replacing handwritten client in several controllers 2016-01-31 15:42:02 -08:00
rbd replacing handwritten client in several controllers 2016-01-31 15:42:02 -08:00
secret replacing handwritten client in several controllers 2016-01-31 15:42:02 -08:00
util Volume Metrics Interface and base implementation. 2015-12-09 16:06:24 -08:00
doc.go
metrics_du.go Volume Metrics Interface and base implementation. 2015-12-09 16:06:24 -08:00
metrics_du_test.go Remove all instances of "/tmp" from unit tests and replace with a common 2016-01-27 16:11:22 -08:00
metrics_nil.go Volume Metrics Interface and base implementation. 2015-12-09 16:06:24 -08:00
metrics_nil_test.go Volume Metrics Interface and base implementation. 2015-12-09 16:06:24 -08:00
plugins.go replacing handwritten client in several controllers 2016-01-31 15:42:02 -08:00
plugins_test.go expand volume.Spec to include full Volume and PV 2015-09-03 08:57:32 -04:00
testing.go replacing handwritten client in several controllers 2016-01-31 15:42:02 -08:00
util.go replacing handwritten client in several controllers 2016-01-31 15:42:02 -08:00
util_test.go Move pkg/util.Time to pkg/api/unversioned.Time 2015-09-17 17:51:27 -07:00
volume.go replacing handwritten client in several controllers 2016-01-31 15:42:02 -08:00
volume_linux.go replacing handwritten client in several controllers 2016-01-31 15:42:02 -08:00
volume_unsupported.go Move manageVolumeOwnership to pkg/volume/volume.go 2016-01-13 10:36:59 -05:00