Skip to content

Conversation

@rhvgoyal
Copy link
Contributor

Fixes issue #13197

Export image metadata stored in graph driver. Right now two fields "Device ID"
and "Device Size" are being exported from devicemapper. Other graph drivers can
export fields as they seem fit.

This data can be used to mount the thin device outside of docker and tools
can look into image and do some kind of inspection.

Signed-off-by: Vivek Goyal vgoyal@redhat.com

@rhvgoyal
Copy link
Contributor Author

@rhatdan @vbatts Thoughts?

@rhatdan
Copy link
Contributor

rhatdan commented May 14, 2015

I agree that long term, docker volumes or libgraphdriver are the right solution, but we need something now.

@rhvgoyal
Copy link
Contributor Author

I just mounted an image and then tried deleting it using docker. Deletion succeeded. Actual thin device and associated metadata file deletion failed in graph driver but top layers do not care for the error code.
func (graph *Graph) Delete(name string) error {
// Remove rootfs data from the driver
graph.driver.Remove(id)
}

Side affect of this is that when you try to pull delete image again, it fails as graph driver metadata file with same id still exists. And one needs to first delete that file.

I am thinking that how about extending this to containers and allow directly mounting container roots. That way we could quickly do following.

  • docker create <image_of_interest>
  • mount container root.

Now one should not be able to delete an image as container is using it. And container deletion will fail as device is already mounted. I have already cleaned up the container deletion path so that we will end up with a "Dead" container if container deletion fails.

At least for this use case, this should be relatively race free path.

@rhvgoyal
Copy link
Contributor Author

Another advantage of first creating a container and mounting it is that it can be mounted read/write without any risk of any accidental changes ever showing up in image. So it is safer that way too.

@rhatdan
Copy link
Contributor

rhatdan commented May 14, 2015

func (graph *Graph) Delete(name string) error {
// Remove rootfs data from the driver
graph.driver.Remove(id)
}

Isn't this a bug?

return graph.driver.Remove(id)

Or doesn't this return an error?

@rhvgoyal
Copy link
Contributor Author

graph.driver.Remove() does return an error.

Yes it is a bug. Just that I am not sure how would you fix this bug. In an image deletion there are so many things which can go wrong. As we don't have the notion of rollback, if error happens on any step, we are in a bad state. We need something like an image state, like containers where we can mark image as "Dead". So that one can try to clean it up later but nobody can launch a container using that image.

@rhvgoyal rhvgoyal force-pushed the extend-docker-inspect branch from 24962d8 to 6f8838a Compare May 14, 2015 21:36
@rhvgoyal
Copy link
Contributor Author

Refreshed the patch. This time also exported graphdriver data for containers. Now same graphdriver data should be available both for images and containers using docker inspect.

@rhvgoyal
Copy link
Contributor Author

For the curious, I am writing some poof of concept scripts here to mount/unmount docker images.

https://github.com/rhvgoyal/docker-mount

@rhvgoyal
Copy link
Contributor Author

@crosbymichael ping.

How do I make progress on this pull request. Can we reach some sort of conclusion on this?

@vbatts
Copy link
Contributor

vbatts commented May 27, 2015

not sure what to say about the windows CI. It's failed 3 different ways for 3 rebuilds.

@rhvgoyal
Copy link
Contributor Author

docker folks please have a look at this pull request. I think it is a very reasonable addition and allows us to take this metadata information about images/containers and build more tools on top. (mount/unmount).

I don't want it to miss 1.7 release window.

@rhatdan
Copy link
Contributor

rhatdan commented May 27, 2015

We really want to move forward on this, since we need an easy way to examine containers for vulnerabilities.

@baude
Copy link

baude commented May 27, 2015

I am working on a vulnerability scanner for containers ... I have been testing this patch with the git repo and it works as expected.

@rhvgoyal rhvgoyal force-pushed the extend-docker-inspect branch from 6f8838a to 0cd05fa Compare May 27, 2015 22:13
@rhvgoyal
Copy link
Contributor Author

Refreshed the patch one more time. This time made use of interface{} for graph driver data. That way I can easily access data using docker templates.

Ex.

docker inspect --format='{{.GraphDriver.Name}}' fedora
docker inspect --format='{{.GraphDriver.Data.DeviceId}}' fedora
docker inspect --format='{{printf "%0.f" .GraphDriver.Data.DeviceSize}}' fedora

@vbatts
Copy link
Contributor

vbatts commented May 28, 2015

@tiborvass @icecrime can we please review this? I really thought there would be a feedback for the 1.7 release :-\

@thaJeztah
Copy link
Member

To speed up the process; IIUC, this adds extra information to the output of docker inspect; please update the example response in the documentation to match the new output.

also ping @jfrazelle; she likes cherry-picking :-)

@rhvgoyal rhvgoyal force-pushed the extend-docker-inspect branch from 0cd05fa to 71da693 Compare June 1, 2015 12:54
@rhvgoyal
Copy link
Contributor Author

rhvgoyal commented Jun 1, 2015

@thaJeztah updated the patch and updated the docker-inspect man page.

@jfrazelle can you have a look at this one.

@calavera
Copy link
Contributor

calavera commented Jun 1, 2015

@rhvgoyal In general, it's a bad practice to use interface{}. You should declare a type interface that other drivers can implement and return that interface.

@calavera
Copy link
Contributor

calavera commented Jun 1, 2015

This is not going into 1.7. It's passed the feature freeze, sorry about that.

@rhvgoyal
Copy link
Contributor Author

rhvgoyal commented Jun 2, 2015

@calavera

Different backend can return different type of information. So may be instead of interface{} I can force them to return a map[string]string. And then graph drivers can decide what strings they want to return. (like docker info). Will that work?

I wished this had got some attention earlier and had got into 1.7.

@rhatdan
Copy link
Contributor

rhatdan commented Jun 2, 2015

SGTM

@rhvgoyal rhvgoyal force-pushed the extend-docker-inspect branch from 71da693 to c063c8c Compare June 2, 2015 15:14
@rhvgoyal
Copy link
Contributor Author

rhvgoyal commented Jun 2, 2015

@calavera

Refreshed the patch. This time using map[string]string instead of interface{}.

One can still acess the fields using docker template as follows.

docker inspect --format='{{.GraphDriver.Name}}' fedora
docker inspect --format='{{.GraphDriver.Data.DeviceId}}' fedora
docker inspect --format='{{.GraphDriver.Data.DeviceSize}}' fedora

@rhvgoyal
Copy link
Contributor Author

rhvgoyal commented Jun 2, 2015

This is how the additional exported information look like in docker-inspect.

"GraphDriver": {
    "Name": "devicemapper",
    "Data": {
        "DeviceId": "3",
        "DeviceSize": "10737418240"
    }
}

@rhatdan
Copy link
Contributor

rhatdan commented Jun 2, 2015

Having examples from overlayfs and other back ends might help to move this along? What do you think @jfrazelle @tianon @crosbymichael

@vbatts
Copy link
Contributor

vbatts commented Jun 2, 2015

I looked into this for btrfs, but none of stats and usage is plumbed yet in
the docker driver, and not sure that we could give clear container specific
info. At best it just be the path on disk that the container is set up at.
On Jun 2, 2015 12:10, "Daniel J Walsh" notifications@github.com wrote:

Having examples from overlayfs and other back ends might help to move this
along? What do you think @jfrazelle https://github.com/jfrazelle @tianon
https://github.com/tianon @crosbymichael
https://github.com/crosbymichael


Reply to this email directly or view it on GitHub
#13198 (comment).

@rhvgoyal
Copy link
Contributor Author

rhvgoyal commented Jun 2, 2015

For vfs we might be done with simply exporting directory of container.

For things like overlayfs, I think just exporting container directory might not be sufficient. Somebody will have to setup container mount point with proper lower and upper directories and that should happen in caller. So we might have to export this upper and lower dir information too.

@calavera
Copy link
Contributor

calavera commented Jun 2, 2015

A map looks more appropriate, thanks for changing that.

Copy link
Contributor

Choose a reason for hiding this comment

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

why is this lock here? The devices struct is not used after locking.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I can get rid of devives.Lock() as I am not making use of it.

@calavera
Copy link
Contributor

calavera commented Jun 2, 2015

Having some tests would be great!

@rhvgoyal
Copy link
Contributor Author

rhvgoyal commented Jun 2, 2015

@calavera

Ok, I will look into adding test.

@rhvgoyal rhvgoyal force-pushed the extend-docker-inspect branch from c063c8c to ed08580 Compare June 5, 2015 19:20
@rhvgoyal
Copy link
Contributor Author

rhvgoyal commented Jun 5, 2015

@calavera

Pushed patch one more time. This time added 2 new tests and extended 1 existing one. Also got rid of devices.lock.

my test have run against "vfs" locally. Not sure How to force running tests against "devicemapper" graphdriver. I tried "export DOCKER_GRAPHDRIVER=devicemapper; make test-integration-cli" and that fails very early.

@thaJeztah thaJeztah added this to the 1.8.0 milestone Jun 5, 2015
@thaJeztah
Copy link
Member

Added this to the 1.8 milestone; let's work on getting it into that release! (And the experimental builds?)

@rhvgoyal
Copy link
Contributor Author

rhvgoyal commented Jun 6, 2015

@thaJeztah Given that it can't make 1.7, I can live with 1.8.

What's experimental builds?

@thaJeztah
Copy link
Member

@rhvgoyal not sure if this applies to this PR, but starting with the 1.7 release, Docker will have three "release channels";

The experimental release includes new features that are being worked on and hidden behind an EXPERIMENTAL build-flag. (For example, the network API, #13441). Basically an "incubation" period for testing new features, giving them more exposure and testers, and allows further tweaking.

Features in experimental builds are not guaranteed to end up in an official release; this allows the team to "pull the plug" on them (hopefully not, of course), without the headaches of breaking production setups.

@rhvgoyal rhvgoyal force-pushed the extend-docker-inspect branch from ed08580 to f6c3899 Compare June 9, 2015 20:03
@rhvgoyal
Copy link
Contributor Author

rhvgoyal commented Jun 9, 2015

Refreshed patch one more time. This time added another field "DeviceName". This exports the name of the dm device docker will use for image/container.

@calavera
Copy link
Contributor

calavera commented Jun 9, 2015

LGTM

…ata related to graph driver

Export image/container metadata stored in graph driver. Right now 3 fields
DeviceId, DeviceSize and DeviceName are being exported from devicemapper.
Other graph drivers can export fields as they see fit.

This data can be used to mount the thin device outside of docker and tools
can look into image/container and do some kind of inspection.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
@rhvgoyal rhvgoyal force-pushed the extend-docker-inspect branch from f6c3899 to 407a626 Compare June 15, 2015 18:09
@rhvgoyal
Copy link
Contributor Author

Refreshed the patch on top of latest code.

@vbatts
Copy link
Contributor

vbatts commented Jun 16, 2015

LGTM

vbatts added a commit that referenced this pull request Jun 16, 2015
docker-inspect: Extend docker inspect to export image metadata related to graph driver
@vbatts vbatts merged commit e69df25 into moby:master Jun 16, 2015
@rhatdan
Copy link
Contributor

rhatdan commented Jun 17, 2015

WooHoo

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.

8 participants