Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move responsibility of ls/inspect to volume driver#16534

Merged
merged 1 commit into from
Jan 5, 2016

Conversation

cpuguy83
Copy link
Member

Makes docker volume ls and docker volume inspect ask the volume
drivers rather than only using what is cached locally.

Previously in order to use a volume from an external driver, one would
either have to use docker volume create or have a container that is
already using that volume for it to be visible to the other volume
API's.

For keeping uniqueness of volume names in the daemon, names are bound to
a driver on a first come first serve basis. If two drivers have a volume
with the same name, the first one is chosen, and a warning is logged
about the second one.

Adds 2 new methods to the plugin API, List and Get.
If a plugin does not implement these endpoints, a user will not be able
to find the specified volumes as well requests go through the drivers.

Fixes #15997
Closes #16513
Closes #16473

ping @calavera @srust @thaJeztah @lukemarsden

return nil, ErrNoSuchVolume
}
return vc.Volume, nil

logrus.Debugf("Propbing all volume drivers for volume with name: %s", name)
Copy link
Contributor

Choose a reason for hiding this comment

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

"Probing all volume drivers"...

@cpuguy83 cpuguy83 force-pushed the make_volume_drivers_responsible branch 2 times, most recently from fe76583 to d7b0e5e Compare September 24, 2015 01:11
ext = NewVolumeDriver(p.Name, p.Client)
drivers.extensions[p.Name] = ext
}
ds = append(ds, ext)
Copy link
Contributor

Choose a reason for hiding this comment

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

check plugin status with Activate() here?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is done in plugins.GetAll(), or am I missing something?

Copy link
Contributor

Choose a reason for hiding this comment

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

sorry, I missed that :(

@cpuguy83 cpuguy83 force-pushed the make_volume_drivers_responsible branch from d7b0e5e to c960a90 Compare September 24, 2015 02:05
s.mu.Unlock()
return v, nil
<-vc.waitCreate
if vc.Volume != nil && (vc.Volume.DriverName() == driverName || driverName == volume.DefaultDriverName) {
Copy link
Contributor

Choose a reason for hiding this comment

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

driverName="local" vc.Volume.DriverName() = "test" will return true
driverName="" vc.Volume.DriverName() = "local" will return false

Copy link
Contributor

Choose a reason for hiding this comment

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

@cpuguy83 Don't understand the logic driverName == volume.DefaultDriverName. Does it mean if the
vc.Volume.DriverName() is convoy, but the driverName is local and then return the volume?

And one question, from what I understand VolumeStore only store the volumes which has been reference by
containers, so there is the situation, a volume exists in external volume driver but not stored in VolumeStore, so the Create will create a volume has the same name with these volumes. So we can't ensure the volume has a unique name. I think it's better to check if the volume is exist in external volume driver, but anyway, this may take long time to create a volume. Am I missing something?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is correct, but also doesn't get passed in that way... but I will update to ensure it's never a problem.

Copy link
Member Author

Choose a reason for hiding this comment

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

@coolljt0725 This means that if the passed in driver name is the default driver name, but the one that we already have is for some other driver (like convoy), then we will assume that the user wanted convoy and not something from the default driver.
This is really a problem due to --volume-driver on docker run.

@cpuguy83 cpuguy83 force-pushed the make_volume_drivers_responsible branch from c960a90 to 007a166 Compare September 24, 2015 02:10
if err != nil {
return nil, err
}

v, err := vd.Create(name, opts)
v, err = vd.Create(name, opts)
if err != nil {
return nil, err
Copy link
Contributor

Choose a reason for hiding this comment

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

if err != nil {
vc.Volume = v
return v, nil
}
create() succeessfully, should return v?

Copy link
Member Author

Choose a reason for hiding this comment

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

if the err is not nil, then we need to return the error.

@cpuguy83
Copy link
Member Author

I'm going to close this for now.
The current VolumeStore implementation has just become too complex to suppor the finer grained locking that's needed as well as these enhancements.
I've got some other stuff in mind, stay tuned!

@cpuguy83 cpuguy83 closed this Sep 24, 2015
@thaJeztah
Copy link
Member

Doh! Just got back from London and started to read up on this, LOL. I'll watch for the replacement PR 👍

@cpuguy83 cpuguy83 reopened this Sep 28, 2015
@cpuguy83 cpuguy83 force-pushed the make_volume_drivers_responsible branch 5 times, most recently from a80d41b to 5587a9a Compare September 28, 2015 18:11
@cpuguy83
Copy link
Member Author

This is now updated.

As a side note, I've found the current implementation using singletons for plugins and volume extpoints makes unit tests rather difficult
Also slow for unit tests testing drivers that are non-existant/missing.
This is not fixed but would make a good follow-up.

Also found that the integration tests for the external volume drivers, while passing, were passing due to a bug in the implementation of the plugin driver in that test file. This is fixed.

@cpuguy83 cpuguy83 force-pushed the make_volume_drivers_responsible branch from 5587a9a to ff2572f Compare September 28, 2015 18:52
s.nameLocker.Unlock(v.Name())
}
s.mu.Unlock()
return vols, warnings, nil
Copy link
Contributor

Choose a reason for hiding this comment

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

return out?

Copy link
Member Author

Choose a reason for hiding this comment

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

doh! will fix.

@cpuguy83 cpuguy83 force-pushed the make_volume_drivers_responsible branch 5 times, most recently from b0ec3ae to ba81fa1 Compare September 30, 2015 01:42
@erikh
Copy link
Contributor

erikh commented Dec 15, 2015

Just allow me to turn it off and I'll be happy.

@erikh
Copy link
Contributor

erikh commented Dec 15, 2015

More accurately, I'd really like to avoid introducing a THIRD distributed database to manage my ceph volumes. I would really not like this behavior to cloud what I have that's already working reliably, so I can fight docker's etcd implementation too.

This is also really easy to get wrong (I've been doing it for the last 3-4 months now) and I would strongly caution you against doing it if you're not comfortable implementing crash recovery.

@cpuguy83
Copy link
Member Author

@thaJeztah The user also gets a warning in this case.
@erikh Definitely not implementing distributed K/V store in this PR at the very very least :)

@erikh
Copy link
Contributor

erikh commented Dec 15, 2015

Ah ok! :)

On 15 Dec 2015, at 11:26, Brian Goff wrote:

@thaJeztah The user also gets a warning in this case.
@erikh Definitely not implementing distributed K/V store in this PR at
the very very least :)


Reply to this email directly or view it on GitHub:
#16534 (comment)

@thaJeztah
Copy link
Member

PR review session; moving to code review. We'll have a separate discussion about storing information about volumes or not.

@cpuguy83 cpuguy83 force-pushed the make_volume_drivers_responsible branch from f769e3f to 8136da9 Compare December 19, 2015 15:02
@thaJeztah
Copy link
Member

@cpuguy83 tests fail; could it be because no such volume now is No such volume (with a capital)?

docker_cli_start_volume_driver_unix_test.go:433:
    c.Assert(out, checker.Contains, "no such volume")
... obtained string = "" +
...     "[]\n" +
...     "Error: No such volume: dummy\n"
... substring string = "no such volume"

@cpuguy83 cpuguy83 force-pushed the make_volume_drivers_responsible branch from 8136da9 to b61d658 Compare December 28, 2015 19:19
@cpuguy83
Copy link
Member Author

@thaJeztah Thanks.
Fixed and rebased.

@thaJeztah
Copy link
Member

ping @calavera @runcom could you review this? Let's see if we can get this moving 👍

@calavera
Copy link
Contributor

LGTM

@thaJeztah
Copy link
Member

ping @cpuguy83, needs another rebase, sorry 😢


// GetAll returns all the plugins for the specified implementation
func GetAll(imp string) ([]*Plugin, error) {
pluginNames, err := Scan()
Copy link
Member

Choose a reason for hiding this comment

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

the only nit I have is this scan and activation of all plugins prior to checking if they implement what we're interested in (plugins may be many?).. I guess there's no solution right now.. (maybe using subdirs for specific plugins - /volumes, /network to narrow down the list? 😄 not related to this PR only)

@runcom
Copy link
Member

runcom commented Jan 5, 2016

LGTM, before the rebase :) I'll make sure to have another look after :)

@cpuguy83 cpuguy83 force-pushed the make_volume_drivers_responsible branch from b61d658 to 6a3a7ba Compare January 5, 2016 21:27
Makes `docker volume ls` and `docker volume inspect` ask the volume
drivers rather than only using what is cached locally.

Previously in order to use a volume from an external driver, one would
either have to use `docker volume create` or have a container that is
already using that volume for it to be visible to the other volume
API's.

For keeping uniqueness of volume names in the daemon, names are bound to
a driver on a first come first serve basis. If two drivers have a volume
with the same name, the first one is chosen, and a warning is logged
about the second one.

Adds 2 new methods to the plugin API, `List` and `Get`.
If a plugin does not implement these endpoints, a user will not be able
to find the specified volumes as well requests go through the drivers.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
@cpuguy83 cpuguy83 force-pushed the make_volume_drivers_responsible branch from 6a3a7ba to d3eca44 Compare January 5, 2016 21:28
@cpuguy83
Copy link
Member Author

cpuguy83 commented Jan 5, 2016

Rebased

@estesp
Copy link
Contributor

estesp commented Jan 5, 2016

LGTM - also note that Windows passed CI but failed on a technicality related to cleanup scripts 😿

@thaJeztah
Copy link
Member

as discussed on IRC, there will be some docs changes in docs/extend/plugins_volume.md, but those will be in a separate PR. We want this merged because it's long overdue and it's better to have it merged before the API is moved to docker/engine-api :)

estesp added a commit that referenced this pull request Jan 5, 2016
Move responsibility of ls/inspect to volume driver
@estesp estesp merged commit 55137c1 into moby:master Jan 5, 2016
@cpuguy83 cpuguy83 deleted the make_volume_drivers_responsible branch January 6, 2016 02:08
@cpuguy83
Copy link
Member Author

cpuguy83 commented Jan 6, 2016

🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
impact/changelog status/needs-attention Calls for a collective discussion during a review session status/2-code-review
Projects
None yet
Development

Successfully merging this pull request may close these issues.