Skip to content

Proposal: Container device add/remove CLI/API documentation#8826

Closed
imain wants to merge 1 commit intomoby:masterfrom
imain:modify_docs_only
Closed

Proposal: Container device add/remove CLI/API documentation#8826
imain wants to merge 1 commit intomoby:masterfrom
imain:modify_docs_only

Conversation

@imain
Copy link
Copy Markdown
Contributor

@imain imain commented Oct 28, 2014

Device add/remove CLI and API documentation. This is being proposed as
the new API and CLI to see how people like it.

Co-Authored-By: Chris Alfonso [email protected] (github: calfonso)
Docker-DCO-1.1-Signed-off-by: Ian Main [email protected] (github: imain)

@imain
Copy link
Copy Markdown
Contributor Author

imain commented Oct 28, 2014

In response to #8348 I have created this PR.

@shykes, @crosbymichael, @timthelion, @ibuildthecloud, @calfonso, @ewindisch, see what you guys make of it.

I almost hate to bring it up but we should also decide if it's a good idea to update the hostConfig with changes to the container.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Rather than having an "arguments" paramater, why not have "host-path", "container-path" and "permissions" parameters separately?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is the format that 'ParseDevice' expects so it's actually easier to pass it in as the string. We could break it up though if that makes more sense long term. Right now we're relying on the format matching the internal parsing.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I disagree with that claim. I specifically placed ParseDevice on the client side to make it so we never see the command line syntax as a "native" format. You shouldn't be using ParseDevice anywhere but rather directly creating a DeviceMapping https://github.com/docker/docker/blob/f98a1f1f7d9b3ef10c13fc3b6438c978b4d6aa78/runconfig/hostconfig.go#L31 struct as we store in the hostconfig. https://github.com/docker/docker/blob/master/runconfig/hostconfig.go#L54

Having multiple arguments is easier for people writting clients to the API. We don't want anyone worying about escaping the : character.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

OK cool, I will update this, thanks @timthelion. I'm at the openstack summit so I'm a bit slow to respond.

@timthelion
Copy link
Copy Markdown
Contributor

As for writing to the host config, I am personally undecided. To me "/dev/sdb" is not a thing. It is a temporary name. Almost a pronoun of sorts. There is a reason why the ubuntu folks decided to make the move to using UUIDs in /etc/fstab, even though it was a seriously breaking change. However, not all devices have UUIDs, so that fix wouldn't help us unfortunately. Similarly though, other devices like /dev/ttyACM* are strongly ephemeral.

@timthelion
Copy link
Copy Markdown
Contributor

However, I think that devices added with --device are already added to hostconfig. So my arguments, while valid, don't hold as much weight as they might otherwise.

@timthelion
Copy link
Copy Markdown
Contributor

What is the behavior with exec? Can we use exec as a role model in deciding on the hostconfig question?

@SvenDowideit
Copy link
Copy Markdown
Contributor

needs a man page entry too :)

@timthelion
Copy link
Copy Markdown
Contributor

@SvenDowideit , yeah yeah, there is also no implementation ;).  This PR is
basically just a proposal to get the UX down.  So no man page yet, till we
decide how this thing will actually work.  No need to write the docs twice
if we're going to re-write over and over again anyways.

---------- Původní zpráva ----------
Od: Sven Dowideit [email protected]
Komu: docker/docker [email protected]
Datum: 29. 10. 2014 2:36:25
Předmět: Re: [docker] Container device add/remove CLI/API documentation RFC
(#8826)

"

needs a man page entry too :)


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

"=

@thaJeztah
Copy link
Copy Markdown
Member

From a UX perspective, also note the issue I created on consistent naming/format for the CLI (and API); #8829

@SvenDowideit
Copy link
Copy Markdown
Contributor

ah, roger, changing the title to reflect that.

@SvenDowideit SvenDowideit changed the title Container device add/remove CLI/API documentation RFC Proposal: Container device add/remove CLI/API documentation Oct 30, 2014
@imain
Copy link
Copy Markdown
Contributor Author

imain commented Oct 31, 2014

@timthelion Yeah I'm not sure on the hostConfig either. I'll be spending some time with Eric Windisch soon so maybe we can come up with some reasonable answer.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

"Modify a container's devices"?

@vbatts vbatts added the UX label Nov 13, 2014
@dims
Copy link
Copy Markdown
Contributor

dims commented Dec 3, 2014

@imain please take a look at this gist - https://gist.github.com/dims/0d1ac1a5598e0b8a72e0 i've an alternative API there

@imain
Copy link
Copy Markdown
Contributor Author

imain commented Dec 4, 2014

Thanks for the input @dims. I modified my proposal with input from your API.

@imain imain force-pushed the modify_docs_only branch 2 times, most recently from a4fd1b0 to 22ae192 Compare December 5, 2014 01:28
@imain
Copy link
Copy Markdown
Contributor Author

imain commented Dec 5, 2014

OK, good discussion on IRC @dims. I'm going to steal your idea wholesale then; I like it. :)

The new changes make a complete add/remove/list API and CLI that uses unique ID's for each device. We should be able to remove the device using only the ID as we store the information for removal in the AllowedDevices list for the container.

@dims
Copy link
Copy Markdown
Contributor

dims commented Dec 5, 2014

@imain lgtm+1

@imain
Copy link
Copy Markdown
Contributor Author

imain commented Dec 7, 2014

@timthelion what do you think?

@timthelion
Copy link
Copy Markdown
Contributor

Using Ids is a good idea. It is important, however, to understand that these
are not device Ids but device mapping Ids. This should be clear in the docs
as well. I would suggest that the docs(and the unit tests, when it comes
time) include the following example.

Imagine a container has the following device mappings:

[{"Id":"1", 
"PathOnHost":"/dev/sda1", 
"PathInContainer":"/dev/xvd1", 
"CgroupPermissions":"mrw" 
}, 
{"Id":"2", 
"PathOnHost":"/dev/sda1", 
"PathInContainer":"/dev/xvd2", 
"CgroupPermissions":"mr" 
} 
] 

And you do:

docker devices remove 1 <container-id>

The container still has read only permission to access /dev/sda1. And in
order to get rid of those permissions entirely, the user must remove device
mapping 2 as well.

Note 1: How are these device mapping Ids generated? If they are random, how
will Docker, and projects outside of Docker, write unit tests? Can they be
generated as a deterministic hash? Or as natural numbers counting upwards?

@imain
Copy link
Copy Markdown
Contributor Author

imain commented Dec 8, 2014

@timthelion - the container is 'happy_bell' in the add case. Actually in remove we should probably specify the container.

I was planning to do random IDs. We could do a deterministic hash.. we could even just use a hash of the in-container device name as that should be unique per-container.

You know I hadn't considered the example above. That could be tricky as we'll have to go through the allowed devices and make sure there's not a second use for them.

Devices add/remove/ls CLI and API documentation.  This is being proposed as
the new API and CLI to see how people like it.

Co-Authored-By: Chris Alfonso <[email protected]> (github: calfonso)
Docker-DCO-1.1-Signed-off-by: Ian Main <[email protected]> (github: imain)
@imain
Copy link
Copy Markdown
Contributor Author

imain commented Dec 8, 2014

Fixed remove and ls.

@timthelion
Copy link
Copy Markdown
Contributor

When you go through the list of allowed devices looking for duplicates make
sure you match against. Major,minor number pairs and not paths as two device
nodes can actually refer to the same device on the host as well I think.

maybe it would be better to not have ids for device mappings, but to refer
to devices by their major,minor number pairs. This would mean that, in my
example, the only possibe action would be to remove both pairs at the same
time.

@imain
Copy link
Copy Markdown
Contributor Author

imain commented Dec 10, 2014

@crosbymichael what do you think?

@coolljt0725
Copy link
Copy Markdown
Contributor

+1 for this

@tiborvass
Copy link
Copy Markdown
Contributor

I'm +1 for the proposal, but I don't see us merging this anytime soon until we agreed on #8829.

I'm going to close this for now, which does NOT mean we don't want this feature. We can always reopen it later.

We know we've been slow on design discussions, and we are working on improving that bottleneck. Thanks for your contribution.

@jacknlliu
Copy link
Copy Markdown

+1 for this proposal

@kstromeiraos
Copy link
Copy Markdown

+1 for this

1 similar comment
@leo-orellana
Copy link
Copy Markdown

+1 for this

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.