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

Remove swarm inspect and use info instead #24492

Closed
wants to merge 1 commit into from

Conversation

vdemeester
Copy link
Member

@vdemeester vdemeester commented Jul 10, 2016

Remove the docker swarm inspect command and use docker info instead to display swarm information if the current node is a manager 🐮.

This only change the cli side and the return of /info but not the /swarm/inspect endpoint. The attribute used in the info endpoint is Swarm.Cluster and is populated only when the node is a manager.

$ docker info
# […]
Swarm: active
 NodeID: b1n3yqwdmvgpbhgmiv4xh48xy
 Is Manager: true
 ClusterID: d3aen0t7fkdw6kq1y4e3w4vv6
 Managers: 1
 Nodes: 1
 Name: default
 Orchestration:
  Task History Retention: 10
 Raft:
  Snapshot interval: 10000
  Heartbeat tick: 1
  Election tick: 3
 Dispatcher:
  Heartbeat period: 5 seconds
 CA configuration:
  Expiry duration: 3 months
# […]

I did not add all the thing displayed by swarm inspect but they are available through the API.

  • Complete attribute displayed ?
  • Remove /swarm/inspect endpoint ?

I'll create a engine-api if this pass design-review 😉

Closes #24148

/cc @aluzzardi @tiborvass @stevvooe @tonistiigi

Signed-off-by: Vincent Demeester vincent@sbr.pm

fmt.Fprintf(dockerCli.Out(), " Acceptance Policies:\n")
for _, policy := range info.Swarm.Cluster.Spec.AcceptancePolicy.Policies {
fmt.Fprintf(dockerCli.Out(), " %s:\n", policy.Role)
fmt.Fprintf(dockerCli.Out(), " auto-accept: %t\n", policy.Autoaccept)
Copy link
Member

Choose a reason for hiding this comment

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

I feel Auto-acceptance and Secret are better for consistency

Copy link
Member Author

Choose a reason for hiding this comment

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

@AkihiroSuda you're right 👍

@icecrime
Copy link
Contributor

A few remarks about acceptance policies:

  • I don't think we should display the secret: people copy/paste this in GitHub issues 😇
  • We can probably condense the output (e.g., Auto-accept: (manager|worker|none)).

@icecrime icecrime added the status/failing-ci Indicates that the PR in its current state fails the test suite label Jul 12, 2016
@vdemeester
Copy link
Member Author

Rebased and hopefully, tests fixed 👼

@icecrime

I don't think we should display the secret: people copy/paste this in GitHub issues 😇

docker swarm inspect did display it but I'm ok with not displaying in docker info (it will still be present in the json)

We can probably condense the output (e.g., Auto-accept: (manager|worker|none)).

That's an idea, I'll look into it.

@vdemeester
Copy link
Member Author

Hum, removing /swarm/inspectmeans removing client.SwarmInspect (from engine-api) and means making swarm update call the /info endpoint instead.

I'm not sure we should remove it, just adding Cluster information in /info.

@thaJeztah @icecrime wdyt ?

@thaJeztah
Copy link
Member

Perhaps we can keep the inspect endpoint for now, if that simplifies things

@tiborvass
Copy link
Contributor

@vdemeester sorry but would you mind linking where swarm update calls /swarm (inspect) ?

@vdemeester
Copy link
Member Author

@icecrime
Copy link
Contributor

I think it's ok for swarm update to call the /info endpoint as long as the SwarmSpec is a nested element of the result, and not something that I need to construct myself for the purpose of calling /swarm/update.

@icecrime
Copy link
Contributor

Also 😉

11:22:56 FAIL: docker_cli_swarm_test.go:15: DockerSwarmSuite.TestSwarmUpdate
11:22:56 
11:22:56 [d66998809] waiting for daemon to start
11:22:56 [d66998809] daemon started
11:22:56 docker_cli_swarm_test.go:24:
11:22:56     c.Assert(err, checker.IsNil, check.Commentf("out: %v", out))
11:22:56 ... value *exec.ExitError = &exec.ExitError{ProcessState:(*os.ProcessState)(0xc822f77080), Stderr:[]uint8(nil)} ("exit status 1")
11:22:56 ... out: Error response from daemon: page not found

@vdemeester
Copy link
Member Author

@icecrime ok, I'll update and prepare a PR for engine-api. The test failure is related to that 😉

@vdemeester vdemeester removed the status/failing-ci Indicates that the PR in its current state fails the test suite label Jul 14, 2016
@vdemeester
Copy link
Member Author

Updated, fixed test failures and created a PR in engine-api (docker/engine-api#318) — vendor is expected to fail 👼.

@tiborvass
Copy link
Contributor

tiborvass commented Jul 15, 2016

@vdemeester let's keep the API unchanged and have inspect make multiple calls for now. Not sure if you would still need docker/engine-api#318 then.

@vdemeester
Copy link
Member Author

@tiborvass you mean info 👼

@vdemeester
Copy link
Member Author

Updated 👼

@vieux
Copy link
Contributor

vieux commented Jul 19, 2016

@vdemeester docker_cli_swarm_test.go uses docker swarm inspect

@vdemeester
Copy link
Member Author

@vieux ah damn.. revert the wrong file… I'll fix 👼

@vdemeester vdemeester force-pushed the 24148-swarm-inspect-info branch 5 times, most recently from 56e8729 to 8eb3f97 Compare July 22, 2016 10:37
@tiborvass
Copy link
Contributor

@vdemeester some updates we need on this one:

  • Rebase :)
  • Update description to show the new information, since the result from the swarm API has changed (no more acceptance policy, CAhash, etc.)
  • Make sure we DO NOT display join tokens (because they are returned by the API)
  • Make only 1 API call to /info, and gather all the swarm information server side.
  • Having Cluster: and Swarm: makes no sense, they are synonyms, they should be merged, and ID be renamed to ClusterID.
  • Remove Version from Cluster:
  • Heartbeat period should use human formatting for duration

@tiborvass tiborvass self-assigned this Jul 23, 2016
@kencochrane
Copy link
Contributor

Can we add an IsLeader field to show if this node is the lead manager. I'm currently using swarm inspect for this, but if swarm inspect is going away, then I need another way to get that value.

Another question. Will Cluster:Id be available on the worker nodes as well as the manager nodes? It isn't today and that would be very helpful. It is an easy way to see what swarm a node is in for logging and analytics/metrics gathering for nodes by cluster.

@vdemeester
Copy link
Member Author

vdemeester commented Jul 23, 2016

Make only 1 API call to /info, and gather all the swarm information server side.

Ok this mean I need to make a PR in engine-api 👼

Make sure we DO NOT display join tokens (because they are returned by the API)

Removing only in cli right ? (will stay in the /info api response)

@aluzzardi
Copy link
Member

Hey Ken, regarding IsLeader, I think you can grab that from docker node
inspect self -f "{{ something something }}"

I do agree it'd be useful in docker info regardless so +1 for that request

On Saturday, July 23, 2016, Vincent Demeester notifications@github.com
wrote:

Make only 1 API call to /info, and gather all the swarm information server
side.

Ok this mean I need to make a PR in engine-api 👼


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#24492 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAK9Lw_GdCh3gr-72PmrXCud3YXN8VH7ks5qYk-CgaJpZM4JI3dy
.

@kencochrane
Copy link
Contributor

@aluzzardi thanks for the work around. The one issue with docker node is that it only works for manager nodes, where as docker info works for all mode types.

@aluzzardi
Copy link
Member

Indeed - but for your use case, you can assume that if it's not a manager
node then it's probably not the leader :)

However I do still agree with you that this information should be available
on docker info - just pointing out a workaround

On Saturday, July 23, 2016, Ken Cochrane notifications@github.com wrote:

@aluzzardi https://github.com/aluzzardi thanks for the work around. The
one issue with docker node is that it only works for manager nodes, where
as docker info works for all mode types.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#24492 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAK9L3EO3jswn-gSR1qJqmr0kjvx2HJpks5qYodVgaJpZM4JI3dy
.

Remove the swarm inspect command and use docker info instead to display
swarm information if the current node is a manager.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
@tiborvass
Copy link
Contributor

@vdemeester I was thinking about not returning join tokens via the /info API at all not just CLI

@tiborvass
Copy link
Contributor

Carried in #25042

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.

None yet

10 participants