Skip to content

Fix copying of volumes by using the name of the volume - #2934

Merged
shin- merged 1 commit into
docker:masterfrom
dnephin:fix_volume_copy
Feb 17, 2016
Merged

shin- merged 1 commit into
docker:masterfrom
dnephin:fix_volume_copy

Conversation

@dnephin

@dnephin dnephin commented Feb 16, 2016

Copy link
Copy Markdown

Fixes #2912

This is a long overdue fix, that unfortunately caused a bug due to a change we made in 1.6.0. In 1.6.0 we stopped copying host volumes from previous containers (because it's redundant).

However, the "copy volume" logic made any copied volumes appear as if they were host volumes instead of named volumes, which meant that on the second recreate we'd lose the volumes (and new ones would be created).

This wasn't found by tests because we never recreated twice.

This fixes the 1.6.0, and should make this logic more resilient going forward. Instead of using the host path, we use the name (which didn't exist when this "copy volume" logic was first added). By using the name it's exactly like we're using a named volume.

@dnephin

dnephin commented Feb 16, 2016

Copy link
Copy Markdown
Author

I'm actually surprised this wasn't found until now (and there have only been 2 reports so far). It makes me believe that most people are using Compose for CI (where you always rm -vf everything) and not really relying on the copy-volume-on-recreate logic.

Comment thread tests/integration/service_test.py Outdated
volume_path = orig_container.get_mount('/etc')['Source']

# Do this twice to reproduce the bug
for _ in xrange(2):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Doesn't exist in python 3. Just use range(2) instead - we probably have enough RAM for those 12 bytes.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Oops, right!

@shin-

shin- commented Feb 17, 2016

Copy link
Copy Markdown

LGTM!

shin- added a commit that referenced this pull request Feb 17, 2016
Fix copying of volumes by using the name of the volume
@shin-
shin- merged commit 706062a into docker:master Feb 17, 2016
@romankonz

Copy link
Copy Markdown

I just want to mention that i ran into this bug today with an (non-critical) application in production.
So, not everyone is using compose only for CI ;)

Thanks for fixing this!

@dnephin
dnephin deleted the fix_volume_copy branch February 17, 2016 22:28
@pwaller

pwaller commented Feb 22, 2016

Copy link
Copy Markdown

Also to comment, we've hit upon it here too, but I found the existing bug report so didn't refile it or add a 👍, I just subscribed. Glad to see this fixed and sitting tight for 1.6.1!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DOC: Unexpected data loss when recreate containers

5 participants