Skip to content
This repository has been archived by the owner on Nov 9, 2020. It is now read-only.

Serialize attach/detach ops for the same vm #808

Merged
merged 1 commit into from
Dec 8, 2016

Conversation

brunotm
Copy link
Contributor

@brunotm brunotm commented Dec 8, 2016

This is a simple change that fixes concurrency on the same docker host. It adds a per vm lock on attach/detach ops.

Fixes #809

//CC @msterin

before:

=== RUN   TestSanity
Running tests on  tcp://vsc02:2375 (may take a while)...
Running create/delete parallel tests on tcp://vsc02:2375 and tcp://vsc02:2375 (may take a while)...
--- FAIL: TestSanity (3.66s)
	sanity_test.go:190: Successfully connected to tcp://vsc02:2375
	sanity_test.go:190: Successfully connected to tcp://vsc02:2375
	sanity_test.go:196: Creating vol=DefaultTestVol on client tcp://vsc02:2375.
	sanity_test.go:90: Running cmd=&[touch /mnt/testvol/DefaultTestVol/file_to_touch] with vol=DefaultTestVol on client tcp://vsc02:2375
	sanity_test.go:90: Running cmd=&[stat /mnt/testvol/DefaultTestVol/file_to_touch] with vol=DefaultTestVol on client tcp://vsc02:2375
	sanity_test.go:262: Parallel test failed, err: Error response from daemon: create volTestP10: VolumeDriver.Create: Another task is already in progress.
FAIL
Makefile:319: recipe for target 'test-vm' failed
make[1]: *** [test-vm] Error 1

after:

=== RUN   TestSanity
Running tests on  tcp://vsc02:2375 (may take a while)...
Running create/delete parallel tests on tcp://vsc02:2375 and tcp://vsc02:2375 (may take a while)...
Running clone parallel tests (may take a while)...
--- PASS: TestSanity (17.83s)
	sanity_test.go:190: Successfully connected to tcp://vsc02:2375
	sanity_test.go:190: Successfully connected to tcp://vsc02:2375
	sanity_test.go:196: Creating vol=DefaultTestVol on client tcp://vsc02:2375.
	sanity_test.go:90: Running cmd=&[touch /mnt/testvol/DefaultTestVol/file_to_touch] with vol=DefaultTestVol on client tcp://vsc02:2375
	sanity_test.go:90: Running cmd=&[stat /mnt/testvol/DefaultTestVol/file_to_touch] with vol=DefaultTestVol on client tcp://vsc02:2375
PASS
make[1]: Leaving directory '/usr/share/go-1.6/src/github.com/vmware/docker-volume-vsphere/vmdk_plugin'

elif cmd == "detach":
response = detachVMDK(vmdk_path, vm_uuid)
with lockManager.get_lock(vm_uuid):
response = detachVMDK(vmdk_path, vm_uuid)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The client plugin also has a lock (per docker-host), do we need one more lock in the ESX service? The disk level locks are good?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disk level locks are good. :)
The error comes from already having a reconfig task running for the same VM. (different volumes)
I didn't investigated why the mutex in the plugin driver is not protecting this situation, but serialization for attach/detach is really needed on the esx part. I might be missing something, but in the plugin we need to protect the refcount part only?

@brunotm brunotm changed the title Serialize attach/detach ops per vm Serialize attach/detach ops for the same vm Dec 8, 2016
@govint
Copy link
Contributor

govint commented Dec 8, 2016 via email

@msterin
Copy link
Contributor

msterin commented Dec 8, 2016

@govint writes

...Two reconfgs can't happen for the same VM in parallel but the host may sequence those I guess.

They can if there are 2 docker requests for different volumes issued in parallel on the same VM - which the test output in the description of this PR demonstrates

@kerneltime kerneltime merged commit 38877b4 into vmware-archive:master Dec 8, 2016
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Attach/detach ops needs serialization for the same vm
4 participants