Skip to content

Output network attachment task information #35246

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

Merged
merged 2 commits into from
May 23, 2018

Conversation

dperny
Copy link
Contributor

@dperny dperny commented Oct 18, 2017

- What I did
Network attachment tasks are phony tasks created in swarmkit to deal with unmanaged containers attached to swarmkit. Before this change, attempting docker inspect on the task id of a network attachment task would result in an empty task object. After this change, a full task object is returned

Fixes #26548 the correct way.
Fixes #36498

- How I did it
Adds functionality to parse and return network attachment spec information.

- How to verify it

  1. Create a network like docker network create --driver overlay --attachable testnet
  2. Attach a container like docker run -d --network testnet nginx
  3. Try to delete the network docker network rm testnet. Note that it will return an error because the network is in use, and that error will include a task id.
  4. docker inspect the task id from the previous spec.

Before this change, the output of the inspect will be an empty task.
After this change, the output will be a full task object, including the ID of the container that this task represents.

- Description for the changelog

Running docker inspect on network attachment tasks now returns a full task object

@dperny dperny force-pushed the attachment-inspect branch 4 times, most recently from 82d615f to d03df03 Compare October 23, 2017 17:39
@dperny
Copy link
Contributor Author

dperny commented Oct 23, 2017

Failure are unrelated to the PR.

@dperny
Copy link
Contributor Author

dperny commented Oct 24, 2017

🎉 It's green 🎉

// AttachmentSpec will be used when the `Runtime` field is set to `attachment`
ContainerSpec *ContainerSpec `json:",omitempty"`
PluginSpec *runtime.PluginSpec `json:",omitempty"`
NetworkAttachmentSpec *NetworkAttachmentSpec `json:",omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

I think we may need to error out on swarm create/update if it includes a NetworkAttachmentSpec?

Copy link
Member

Choose a reason for hiding this comment

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

Should we have a separate type for inspect vs create? I know we're reusing some types at various locations (sometimes resulting in information being shown that happens to be there, but is not needed)

Copy link
Member

Choose a reason for hiding this comment

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

I don't think a separate type is such a good idea. This is the task spec, having the task spec in the inspect output I think is hugely important.

@cpuguy83
Copy link
Member

Putting this in design review as it's an API change with a few potential implications.

@thaJeztah
Copy link
Member

@dperny would it be possible to have the error message show the container id instead of the task if it's a container that's attached to the network?

@thaJeztah
Copy link
Member

Discussing with @cpuguy83 and @vieux, and moving to code review again

@thaJeztah
Copy link
Member

Also needs an update to the swagger.yml

@dperny
Copy link
Contributor Author

dperny commented Oct 30, 2017

Does not need an update for creation and deletion, because it will already fail with an appropriate error, see: https://github.com/moby/moby/blob/master/daemon/cluster/convert/service.go#L202-L203

@dperny dperny force-pushed the attachment-inspect branch from d03df03 to f0710f2 Compare October 30, 2017 20:14
@dperny
Copy link
Contributor Author

dperny commented Oct 30, 2017

@cpuguy83 updated to prevent write operations with network attachment runtime specs. Also fixed some edge cases in runtime type conversion in the process.

@dperny dperny force-pushed the attachment-inspect branch from f0710f2 to 8a9f230 Compare October 30, 2017 20:29
@thaJeztah
Copy link
Member

CI failing on a godoc;

20:38:37 daemon/cluster/convert/service.go:20:2:warning: comment on exported var ErrMismatchedRuntime should be of the form "ErrMismatchedRuntime ..." (golint)

@dperny dperny force-pushed the attachment-inspect branch 2 times, most recently from 9f220c7 to bce0158 Compare November 1, 2017 18:10
@GordonTheTurtle GordonTheTurtle removed the dco/no Automatically set by a bot when one of the commits lacks proper signature label Nov 6, 2017
@dperny
Copy link
Contributor Author

dperny commented Nov 6, 2017

rebased.

}
case types.RuntimeNetworkAttachment:
// agree to parse this runtime type, but it's not actually valid to
// create a service with this runtime type. but that logic is someone
Copy link
Member

Choose a reason for hiding this comment

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

whose responsibility is it? do we check for this situation? (because this looks to be the code you referred to to produce a proper error in #35246 (comment))

Copy link
Member

Choose a reason for hiding this comment

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

ping @dperny ^^

@dperny
Copy link
Contributor Author

dperny commented Nov 22, 2017

Thanks for the reminder @thaJeztah. I've fixed your comment and rebased. Sorry about the poor attention.

@dperny dperny force-pushed the attachment-inspect branch 2 times, most recently from 31369fd to 6718b44 Compare November 22, 2017 20:12
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, but can you also add a note in the API version history; https://github.com/moby/moby/blob/master/docs/api/version-history.md ?

Adds functionality to parse and return network attachment spec
information. Network attachment tasks are phony tasks created in
swarmkit to deal with unmanaged containers attached to swarmkit. Before
this change, attempting `docker inspect` on the task id of a network
attachment task would result in an empty task object. After this change,
a full task object is returned

Fixes moby#26548 the correct way.

Signed-off-by: Drew Erny <drew.erny@docker.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
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.

Saw some other nits; let me rebase this one, and make those changes

@@ -56,10 +56,12 @@ type Task struct {

// TaskSpec represents the spec of a task.
type TaskSpec struct {
// ContainerSpec and PluginSpec are mutually exclusive.
// ContainerSpec, AttachmentSpec and PluginSpec are mutually exclusive.
Copy link
Member

Choose a reason for hiding this comment

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

s/AttachmentSpec/NetworkAttachmentSpec/`

// PluginSpec will only be used when the `Runtime` field is set to `plugin`
ContainerSpec *ContainerSpec `json:",omitempty"`
PluginSpec *runtime.PluginSpec `json:",omitempty"`
// AttachmentSpec will be used when the `Runtime` field is set to `attachment`
Copy link
Member

Choose a reason for hiding this comment

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

s/AttachmentSpec/NetworkAttachmentSpec/`

api/swagger.yaml Outdated
@@ -2683,6 +2683,13 @@ definitions:
- "default"
- "process"
- "hyperv"
NetworkAttachmentSpec:
description: "Read-only spec type for non-swarm containers attached to swarm overlay networks"
Copy link
Member

Choose a reason for hiding this comment

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

Think we can use a common description for these being mutually exclusive (let me add a commit to address that)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah thaJeztah force-pushed the attachment-inspect branch from 6718b44 to 3682703 Compare May 22, 2018 21:39
> **Note**: ContainerSpec, NetworkAttachmentSpec, and PluginSpec are
> mutually exclusive. PluginSpec is only used when the Runtime field
> is set to `plugin`. NetworkAttachmentSpec is used when the Runtime
> field is set to `attachment`.
Copy link
Member

Choose a reason for hiding this comment

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

@dperny I took this description from the type godoc; let me know if you think these look correct

@thaJeztah
Copy link
Member

Arf... Windows cleanup script before CI started hung

21:40:19 INFO: Nuke-Everything...
21:40:19 INFO: Container count on control daemon to delete is 0
01:00:14 Build timed out (after 200 minutes). Marking the build as failed.

Copy link
Member

@boaz0 boaz0 left a comment

Choose a reason for hiding this comment

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

Code LGTM

@codecov
Copy link

codecov bot commented May 23, 2018

Codecov Report

Merging #35246 into master will increase coverage by <.01%.
The diff coverage is 72.72%.

@@            Coverage Diff             @@
##           master   #35246      +/-   ##
==========================================
+ Coverage   35.04%   35.05%   +<.01%     
==========================================
  Files         615      615              
  Lines       45813    45829      +16     
==========================================
+ Hits        16057    16066       +9     
- Misses      27646    27651       +5     
- Partials     2110     2112       +2

@thaJeztah
Copy link
Member

oh... hm, just realised the API version itself wasn't bumped yet 😓 - there's a couple PR's adding new things to the API (#36914, #37043, #36720), so it would be a race which one got merged first 😂 - given that this one's green now, I can also do it in a follow-up

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'ing because I addressed my earlier comments, but I'm obviously biased now, so need other reviewers 😂

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.

SGTM 🐯
On the API update, we're probably gonna bump the API number on an external PR 👼

Copy link
Member

@cpuguy83 cpuguy83 left a comment

Choose a reason for hiding this comment

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

LGTM

@cpuguy83 cpuguy83 merged commit 5a68e26 into moby:master May 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
8 participants