Skip to content

Fix issue backporting mount spec to pre-1.13 obj#32821

Merged
thaJeztah merged 1 commit intomoby:masterfrom
cpuguy83:32613_fix_volspec_backport
May 15, 2017
Merged

Fix issue backporting mount spec to pre-1.13 obj#32821
thaJeztah merged 1 commit intomoby:masterfrom
cpuguy83:32613_fix_volspec_backport

Conversation

@cpuguy83
Copy link
Member

In some cases a mount spec would not be properly backported which could
lead to accidental removal of the underlying volume on container remove
(which should never happen with named volumes).

Adds unit tests for this as well. Unfortunately I had to add a daemon
depdency for the backport function due to looking up VolumesFrom
specs.

Fixes #32613

0b2ae20f3e1272496e3ecf9d4a17e996

@thaJeztah
Copy link
Member

@cpuguy83 tests are failing, and looks related

@thaJeztah thaJeztah added the status/failing-ci Indicates that the PR in its current state fails the test suite label Apr 28, 2017
@cpuguy83 cpuguy83 force-pushed the 32613_fix_volspec_backport branch 2 times, most recently from 7bc5580 to 6c4ec35 Compare May 1, 2017 17:59
@thaJeztah thaJeztah removed the status/failing-ci Indicates that the PR in its current state fails the test suite label May 1, 2017
@cpuguy83
Copy link
Member Author

cpuguy83 commented May 4, 2017

All green

@thaJeztah
Copy link
Member

ping @cpuguy83 looks like it needs a rebase 😢

@cpuguy83 cpuguy83 force-pushed the 32613_fix_volspec_backport branch from 6c4ec35 to 10ae0e7 Compare May 9, 2017 19:39
@cpuguy83
Copy link
Member Author

cpuguy83 commented May 9, 2017

rebased

@thaJeztah
Copy link
Member

ping @dnephin @stevvooe PTAL

Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

LGTM 🐯

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

left some questions ☺️

Copy link
Member

Choose a reason for hiding this comment

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

nit:lowercase Error ?

Copy link
Member

Choose a reason for hiding this comment

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

Looks like we should continue here, as we still try to use fromC even if we got an error

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes need continue (or something), nice catch.

Logged errors are typically capitalized.

Copy link
Member

Choose a reason for hiding this comment

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

In that case, capitalize the error at line 298 👍

Copy link
Member

Choose a reason for hiding this comment

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

perhaps remove the updated variable here, as it's easily mistaken for the updated output variable?

if daemon.backportMountSpec(fromC) {
    fromC.ToDisk()
}

Also, wondering if we should

Copy link
Member

Choose a reason for hiding this comment

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

"probably specified view the hostconfig.Mounts" - sorry, couldn't "grasp" what you tried to say there

Copy link
Member Author

Choose a reason for hiding this comment

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

hah, *via

Copy link
Member

Choose a reason for hiding this comment

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

Will this be an issue if both the container itself, and the --volumes-from container specify a volume for the same destination? (and the --volumes-from needs updating)

Copy link
Member Author

Choose a reason for hiding this comment

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

-volumes-from is lowest precedence.
Can't have two mountpoints with the same destination.

@cpuguy83 cpuguy83 force-pushed the 32613_fix_volspec_backport branch from 10ae0e7 to f482626 Compare May 10, 2017 14:57
Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

found a typo, and some questions 😅

Copy link
Member

Choose a reason for hiding this comment

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

typo s/unepxected/unexpected/

Copy link
Member

Choose a reason for hiding this comment

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

Wondering in what situation this would need an update; cm.Destination is only added to volumesFrom if we entered the for _, fromSpec := range container.HostConfig.VolumesFrom { loop below, in which case the needsUpdate() check is already performed.

Should this just be continue?

Copy link
Member Author

Choose a reason for hiding this comment

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

Let me just move this stuff up to make the code simpler.
I was trying to save some time and not process volumes-from if not-neccessary, but the code is very messy.

Copy link
Member

Choose a reason for hiding this comment

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

We no longer write updated mount-specs to disk for volumes-from containers, only in-memory, correct?

Copy link
Member Author

Choose a reason for hiding this comment

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

In this function yes, they are persisted to disk in the caller.
I can add a note to that in the docstring.

In some cases a mount spec would not be properly backported which could
lead to accidental removal of the underlying volume on container remove
(which should never happen with named volumes).

Adds unit tests for this as well. Unfortunately I had to add a daemon
depdency for the backport function due to looking up `VolumesFrom`
specs.

Signed-off-by: Brian Goff <[email protected]>
@cpuguy83 cpuguy83 force-pushed the 32613_fix_volspec_backport branch from f482626 to 3cf1859 Compare May 11, 2017 16:32
@cpuguy83
Copy link
Member Author

This is updated and green.

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM

@thaJeztah
Copy link
Member

All green! Checked with @vdemeester earlier, and this still looked good to him

for _, fromSpec := range container.HostConfig.VolumesFrom {
from, _, err := volume.ParseVolumesFrom(fromSpec)
if err != nil {
logrus.WithError(err).WithField("id", container.ID).Error("Error reading volumes-from spec during mount spec backport")
Copy link
Member

Choose a reason for hiding this comment

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

Missed this in my review; needs a continue (see #33207 (comment))

Copy link
Member Author

Choose a reason for hiding this comment

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

@thaJeztah
Copy link
Member

cherry-picked for 17.03.2 in #33207

@cpuguy83 cpuguy83 deleted the 32613_fix_volspec_backport branch September 20, 2017 16:54
kolyshkin pushed a commit to kolyshkin/moby that referenced this pull request May 4, 2020
Reuse existing structures and rely on json serialization to deep copy
Container objects.

Also consolidate all "save" operations on container.CheckpointTo, which
now both saves a serialized json to disk, and replicates state to the
ACID in-memory store.

Signed-off-by: Fabio Kung <[email protected]>
(cherry picked from commit edad527)
Signed-off-by: Kir Kolyshkin <[email protected]>

Conflicts:
 - daemon/container_operations.go: missing
   moby#30117
 - daemon/daemon.go: missing moby#32821
 - daemon/list.go: missing moby#27557,
   moby#33241 etc.
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.

4 participants