kubernetes/pkg/util
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
..
atomic Update highwatermark 2015-12-14 16:47:47 +08:00
bandwidth Fix: deal properly with tc qdisc show returning "noqueue" 2016-01-03 23:44:18 -05:00
chmod FSGroup implementation 2015-10-22 16:40:59 -04:00
chown FSGroup implementation 2015-10-22 16:40:59 -04:00
config Cleanup deprecated Forever function 2015-08-24 10:31:59 +08:00
dbus Bump cadvisor to fix interface stats bugs & improve performance 2015-12-21 17:07:21 +00:00
deployment Add kubectl rollout history 2016-02-01 15:32:43 -08:00
errors Add utility function for errors that runs multiple functions that errors 2015-10-05 22:43:19 +00:00
exec Improve error reporting a little in ingress e2e. 2016-01-06 15:25:04 -08:00
flushwriter Make copyright ownership statement generic 2015-05-01 17:49:56 -04:00
hash Use hashutil to hold hash tools 2016-01-06 22:28:58 +08:00
httpstream Replace runtime reference by pkg 2016-02-01 21:06:44 +08:00
intstr Add protobuf preparation objects, guarded by proto tag 2015-12-05 18:15:48 -05:00
io Remove all instances of "/tmp" from unit tests and replace with a common 2016-01-27 16:11:22 -08:00
iptables Enable iptables kube-proxy by default in master 2015-11-13 18:38:01 -08:00
jsonpath Update tests to handle codec changes 2016-01-22 13:27:26 -05:00
keymutex fixed spelling typo 2016-01-22 00:15:07 -05:00
labels Add rollback subresource; add rollback logic to deployment controller 2016-01-30 16:00:34 -08:00
limitwriter Support extended pod logging options 2015-09-21 15:39:32 -04:00
mount Fixed races in Cinder volume attach/detach. 2016-02-02 14:38:49 +01:00
net update proxy server 2016-01-28 15:46:40 -08:00
node run gofmt on everything we touched 2015-08-05 17:52:56 -07:00
oom Ensure kubelet pid is not moved to system container 2016-01-29 09:30:20 +00:00
parsers Move parsers into util 2015-11-29 22:15:11 -08:00
pod Move pod template hash and label adding util functions to their packages. 2016-01-12 16:11:00 -08:00
procfs Refactor an interface for style 2015-11-13 15:56:27 -08:00
proxy Use networking to hold network related pkgs 2016-01-15 13:46:16 +08:00
rand Backoff and Randomness additions for use in client utilities 2015-11-25 00:01:06 -05:00
runtime Replace runtime reference by pkg 2016-02-01 21:06:44 +08:00
selinux Bump cadvisor to fix interface stats bugs & improve performance 2015-12-21 17:07:21 +00:00
sets Updage auto-generated files 2016-01-01 11:47:29 +01:00
slice Move pkg/util.Time to pkg/api/unversioned.Time 2015-09-17 17:51:27 -07:00
strategicpatch Implement conflict detection in strategic merge patch. 2015-12-06 17:54:32 -08:00
strings Add strings pkg to hold strings utils 2016-01-15 12:37:50 +08:00
sysctl Refactor an interface for style 2015-11-13 15:56:27 -08:00
testing Remove all instances of "/tmp" from unit tests and replace with a common 2016-01-27 16:11:22 -08:00
validation Validate uids and gids for securitycontext 2016-01-11 15:17:25 +08:00
wait Provide a RetryOnConflict helper for client libraries 2016-01-20 22:58:16 -05:00
workqueue rewrite go imports 2015-08-05 17:30:03 -07:00
wsstream Replace runtime reference by pkg 2016-02-01 21:06:44 +08:00
yaml Update tests to handle codec changes 2016-01-22 13:27:26 -05:00
backoff_test.go Backoff and Randomness additions for use in client utilities 2015-11-25 00:01:06 -05:00
backoff.go Backoff and Randomness additions for use in client utilities 2015-11-25 00:01:06 -05:00
bool_flag.go Make "BoolFlag" booleans not require =true 2016-01-14 09:07:00 -05:00
cache_test.go Add cache with multiple shards to decrease lock contention 2015-05-11 15:07:50 +02:00
cache.go Add cache with multiple shards to decrease lock contention 2015-05-11 15:07:50 +02:00
clock_test.go back off restarts of crashlooping containers 2015-08-24 21:43:17 +10:00
clock.go Add event correlation to client 2015-11-06 16:59:38 -05:00
configuration_map.go Make copyright ownership statement generic 2015-05-01 17:49:56 -04:00
crlf.go edit: Windows fixes 2015-10-24 17:06:49 +02:00
crypto.go Use self-signed cert as CA for local-up-cluster.sh 2015-07-24 07:16:07 -07:00
deadlock-detector_test.go Refactor the deadlock detector for testing. Add a test. 2015-11-20 09:35:40 -08:00
deadlock-detector.go Refactor the deadlock detector for testing. Add a test. 2015-11-20 09:35:40 -08:00
diff.go Make copyright ownership statement generic 2015-05-01 17:49:56 -04:00
doc.go Make copyright ownership statement generic 2015-05-01 17:49:56 -04:00
env_test.go Add GetEnvOr() feature to utils Package 2016-01-25 16:08:35 +05:30
env.go Add GetEnvOr() feature to utils Package 2016-01-25 16:08:35 +05:30
flags.go Use pflag functions instead of ours. 2015-08-20 15:00:55 -07:00
line_delimiter_test.go Fix up alignment of columns w/ namespaces. 2015-07-09 08:59:32 -07:00
line_delimiter.go Fix up alignment of columns w/ namespaces. 2015-07-09 08:59:32 -07:00
logs.go Cleanup deprecated Forever function 2015-08-24 10:31:59 +08:00
resource_container_linux.go Ensure kubelet pid is not moved to system container 2016-01-29 09:30:20 +00:00
resource_container_unsupported.go flag controlled RLIMIT_NOFILE for kubelet. 2015-09-22 15:18:34 -07:00
runner_test.go Make copyright ownership statement generic 2015-05-01 17:49:56 -04:00
runner.go Make copyright ownership statement generic 2015-05-01 17:49:56 -04:00
ssh_test.go Move pkg/util.Time to pkg/api/unversioned.Time 2015-09-17 17:51:27 -07:00
ssh.go Replace runtime reference by pkg 2016-02-01 21:06:44 +08:00
string_flag.go Replace the auth config file with a kubeconfig file when 2015-05-13 01:03:28 -07:00
template_test.go Make copyright ownership statement generic 2015-05-01 17:49:56 -04:00
template.go Make copyright ownership statement generic 2015-05-01 17:49:56 -04:00
throttle_test.go Rate limiter: Add Saturation() method 2015-12-03 08:39:35 -08:00
throttle.go Rate limiter: Add Saturation() method 2015-12-03 08:39:35 -08:00
trace.go Add very simple tracing mechanism for easier debugging of slow requests. 2015-05-26 16:17:18 +02:00
umask_windows.go util: Add util.Umask wrapper 2015-08-06 11:39:29 +02:00
umask.go util: Add util.Umask wrapper 2015-08-06 11:39:29 +02:00
util_test.go Replace runtime reference by pkg 2016-02-01 21:06:44 +08:00
util.go Replace runtime reference by pkg 2016-02-01 21:06:44 +08:00
uuid.go Speed up UUID generation. 2016-01-27 15:39:23 +01:00