Skip to content

Propagate TLS Info in swarm info and node info REST endpoints#32875

Merged
thaJeztah merged 1 commit intomoby:masterfrom
cyli:root-ca-info-in-api
May 10, 2017
Merged

Propagate TLS Info in swarm info and node info REST endpoints#32875
thaJeztah merged 1 commit intomoby:masterfrom
cyli:root-ca-info-in-api

Conversation

@cyli
Copy link
Contributor

@cyli cyli commented Apr 27, 2017

Propagate the swarm cluster and node TLS info provided by the swarm
objects into the REST API responses. In the CLI, display only
whether the nodes' TLS info matches the cluster's TLS info, or
whether the node needs cert rotation.

Signed-off-by: Ying Li ying.li@docker.com

This is useful to see whether a root rotation is in progress, and which nodes have yet to have their certs rotated.

cc @diogomonica @aaronlehmann

If there is no TLS info for a node, for instance if it's an old node, docker node inspect looks something like:

[
    {
        "ID": "vec1ht0gf5vkp26iqff2u0d8u",
        ...
        "Description": {
            ....
            "TLSInfo": {}
        },
        ...
    }
]

But will have the TLS info if it's been reported back on a newer node.

docker node ls will look something like:

$  bundles/17.06.0-dev/dynbinary-client/docker node ls
ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS      TLS STATUS
vec1ht0gf5vkp26iqff2u0d8u *   moby                Ready               Active              Leader              Ready

If the TLS certificate is signed by the current root. If it isn't, it'd way "Needs Rotation"

cute

@cyli cyli mentioned this pull request Apr 27, 2017
10 tasks
@cyli cyli changed the title WIP - Propagate TLS Info in swarm info and node info REST endpoints Propagate TLS Info in swarm info and node info REST endpoints Apr 27, 2017
@aaronlehmann
Copy link

Can we hide the TLS STATUS column behind a flag? Or only display it if at least one node has a TLS status other than "ready"? There's a lot of information already shown, and the certificate rotation state will seldom be relevant.

@diogomonica
Copy link
Contributor

@aaronlehmann @cyli I'm fine with not adding it to the output of node ls, and just have it on node inspect and node inspect --pretty.

@cyli to see if a rotation is in progress, maybe we could add something to docker info?

@cyli
Copy link
Contributor Author

cyli commented Apr 28, 2017

@diogomonica It seems more useful on node ls if there is a root rotation outstanding, because you can see which nodes are causing the issues. I was thinking about outputting this information under the rotation CLI progress bar itself, but if there are a lot of nodes that could be problematic to display.

Can totally hide it with a flag or only display if a root rotation was in progress, though.

@diogomonica Yes, I can add the boolean to docker info

@diogomonica
Copy link
Contributor

@cyli totally fine with just showing that column if there is a rotation currently in progress. I assume that the json output of the node inspect will show what the current status of the node is w.r.t root rotation?

@cyli
Copy link
Contributor Author

cyli commented May 1, 2017

@diogomonica The JSON output shows the current CA cert trusted by the node, and the base64-encoded raw public key and raw subject of the issuer. Example in YAML format: https://github.com/moby/moby/pull/32875/files#diff-6822c0fe0233dff6af0bbadb1300458cR1756

@cyli
Copy link
Contributor Author

cyli commented May 2, 2017

Updated: here are some sample outputs (this is in the case of no root rotation, since we can't enable root rotation yet)

$ docker system info
...
Swarm: active
 NodeID: 6rv29rh4lg4bflx5tqq3sr99p
 Is Manager: true
 ClusterID: vsm0xtdcetezj9xbxs0iad04b
 Managers: 1
 Nodes: 1
 Orchestration:
  Task History Retention Limit: 5
 Raft:
  Snapshot Interval: 10000
  Number of Old Snapshots to Retain: 0
  Heartbeat Tick: 1
  Election Tick: 3
 Dispatcher:
  Heartbeat Period: 5 seconds
 CA Configuration:
  Expiry Duration: 3 months
 Root Rotation In Progress: false
 Node Address: 192.168.126.146
 Manager Addresses:
  192.168.126.146:2377
...

$ docker node ls
ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS
6rv29rh4lg4bflx5tqq3sr99p *   ubuntu              Ready               Active              Leader

$ docker node ls --format="{{json .}}"
{"Availability":"Active","Hostname":"ubuntu","ID":"6rv29rh4lg4bflx5tqq3sr99p","ManagerStatus":"Leader","Self":true,"Status":"Ready","TLSStatus":""}

$ docker node inspect self
[
    {
        "ID": "6rv29rh4lg4bflx5tqq3sr99p",
        ...
        "Description": {
            ...
            "TLSInfo": {
                "TrustRoot": "-----BEGIN CERTIFICATE-----\nMIIBazCCARCgAwIBAgIUOzgqU4tA2q5Yv1HnkzhSIwGyIBswCgYIKoZIzj0EAwIw\nEzERMA8GA1UEAxMIc3dhcm0tY2EwHhcNMTcwNTAyMDAyNDAwWhcNMzcwNDI3MDAy\nNDAwWjATMREwDwYDVQQDEwhzd2FybS1jYTBZMBMGByqGSM49AgEGCCqGSM49AwEH\nA0IABMbiAmET+HZyve35ujrnL2kOLBEQhFDZ5MhxAuYs96n796sFlfxTxC1lM/2g\nAh8DI34pm3JmHgZxeBPKUURJHKWjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMB\nAf8EBTADAQH/MB0GA1UdDgQWBBS3sjTJOcXdkls6WSY2rTx1KIJueTAKBggqhkjO\nPQQDAgNJADBGAiEAoeVWkaXgSUAucQmZ3Yhmx22N/cq1EPBgYHOBZmHt0NkCIQC3\nzONcJ/+WA21OXtb+vcijpUOXtNjyHfcox0N8wsLDqQ==\n-----END CERTIFICATE-----\n",
                "CertIssuerSubject": "MBMxETAPBgNVBAMTCHN3YXJtLWNh",
                "CertIssuerPublicKey": "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAExuICYRP4dnK97fm6OucvaQ4sERCEUNnkyHEC5iz3qfv3qwWV/FPELWUz/aACHwMjfimbcmYeBnF4E8pRREkcpQ=="
            }
        },
     ...
    }
]

$ docker node inspect self --pretty
...
TLS Info:
 TrustRoot:
-----BEGIN CERTIFICATE-----
MIIBazCCARCgAwIBAgIUOzgqU4tA2q5Yv1HnkzhSIwGyIBswCgYIKoZIzj0EAwIw
EzERMA8GA1UEAxMIc3dhcm0tY2EwHhcNMTcwNTAyMDAyNDAwWhcNMzcwNDI3MDAy
NDAwWjATMREwDwYDVQQDEwhzd2FybS1jYTBZMBMGByqGSM49AgEGCCqGSM49AwEH
A0IABMbiAmET+HZyve35ujrnL2kOLBEQhFDZ5MhxAuYs96n796sFlfxTxC1lM/2g
Ah8DI34pm3JmHgZxeBPKUURJHKWjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMB
Af8EBTADAQH/MB0GA1UdDgQWBBS3sjTJOcXdkls6WSY2rTx1KIJueTAKBggqhkjO
PQQDAgNJADBGAiEAoeVWkaXgSUAucQmZ3Yhmx22N/cq1EPBgYHOBZmHt0NkCIQC3
zONcJ/+WA21OXtb+vcijpUOXtNjyHfcox0N8wsLDqQ==
-----END CERTIFICATE-----

 Issuer Public Key:	MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAExuICYRP4dnK97fm6OucvaQ4sERCEUNnkyHEC5iz3qfv3qwWV/FPELWUz/aACHwMjfimbcmYeBnF4E8pRREkcpQ==
 Issuer Subject:	MBMxETAPBgNVBAMTCHN3YXJtLWNh

@aaronlehmann
Copy link

Design LGTM. pinging @thaJeztah for a sanity check on the design, particularly showing the TLS STATUS column only when it is applicable (which I like, but don't think has precedent).

@diogomonica
Copy link
Contributor

LGTM

@thaJeztah thaJeztah added this to the 17.06.0 milestone May 4, 2017
Copy link
Member

Choose a reason for hiding this comment

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

Do we want this to be shown by default in docker node ls? Or only in docker node inspect? Discussing with @ehazlett and @cpuguy83 and we think it may not be needed; but happy to hear about that

Copy link
Contributor Author

@cyli cyli May 4, 2017

Choose a reason for hiding this comment

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

I was thinking to show it in docker node ls, so if the root rotation is hanging, we can see which node(s) may be problematic and not able to renew. (#32993 is the root rotation CLI changes)

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 more generic ERROR column for that? (thinking out loud)

Copy link
Contributor Author

@cyli cyli May 5, 2017

Choose a reason for hiding this comment

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

Possibly - I'm not sure what other errors we should include, though. There's already an availability column, and likely the ones that are failing to renew are the down or unavailable ones, but it's possible that they went down after renewing.

The other option is to not include the TLS status here, but to include a list of nodes that need certificate renewals in the CLI in #32993 - I was just worried this list would be too long if the user had like 1000 nodes, and providing it in node ls allows the user to look at only the ones that need renewal.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

(heh, didn't read the entire discussion above, and see the same point came up above)

@thaJeztah
Copy link
Member

Ok, I overlooked that it's only shown in node ls if a rotation is actually in progress, so not "always"

design LGTM

@cpuguy83
Copy link
Member

cpuguy83 commented May 5, 2017

I really don't like a conditional column. It makes scripting really difficult.
If we can provide the column via the formatted I think it's likely enough.

@cyli
Copy link
Contributor Author

cyli commented May 5, 2017

Updated:

# docker node ls
ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS
6rv29rh4lg4bflx5tqq3sr99p *   ubuntu              Ready               Active              Leader
umall6tifty5ttyx9sg6axi7b     moby  

# docker node ls --format "table {{.ID}}\t{{.Hostname}}\t{{.TLSStatus}}"
ID                          HOSTNAME            TLS STATUS
6rv29rh4lg4bflx5tqq3sr99p   ubuntu              Ready
umall6tifty5ttyx9sg6axi7b   moby                Ready

# docker node ls --format "{{json .}}"
{"Availability":"Active","Hostname":"ubuntu","ID":"6rv29rh4lg4bflx5tqq3sr99p","ManagerStatus":"Leader","Self":true,"Status":"Ready","TLSStatus":"Ready"}
{"Availability":"Active","Hostname":"moby","ID":"umall6tifty5ttyx9sg6axi7b","ManagerStatus":"","Self":false,"Status":"Ready","TLSStatus":"Ready"}

No more conditional column, even if a root rotation is in progress.

@aaronlehmann
Copy link

I hate to bikeshed, but IMHO it's unfortunate that a user can't see which nodes are holding up the root rotation without passing a magic incantation to node ls. I can see the issue with a variable set of columns being inconvenient for scripting, but shouldn't scripts be passing --format to avoid this problem? It seems better than requiring humans to come up with a --format argument.

@cpuguy83
Copy link
Member

cpuguy83 commented May 5, 2017

@aaronlehmann How frequently do you think this would be used?
The list views should be important information at a glance, and the root rotation field would be only useful some of the time.

It's also not clear exactly how one would disable the column with --format when it's conditionally applied.

We can also always add it if people start asking for it, but we can't really take it away.

@cyli
Copy link
Contributor Author

cyli commented May 5, 2017

@cpuguy83 The TLS status info is only useful some of the time, but it would only be displayed during those times that it's useful (when a root rotation is in progress). You'd only need to exclude it if you really didn't want to see the TLS status even if a root rotation is going - otherwise it wouldn't appear.

Alternately, maybe we should provide a filter to filter by nodes whose TLS status is not "Ready", and we can display the info in the filtered view?

If there are nodes holding up the root rotation, it may be useful to see only the nodes that are holding things up, and not the nodes that are in good shape.

@cyli
Copy link
Contributor Author

cyli commented May 5, 2017

Also I assume this should be split into 2 PRs now

@cyli
Copy link
Contributor Author

cyli commented May 8, 2017

Hm... I think the filtering change would have to come in swarmkit because we'd have to tell whether the TLS status matches the desired cluster TLS status.

@cpuguy83 Is the concern that the user would see TLS status information during status information during a root rotation, but not want to see it?

@cyli
Copy link
Contributor Author

cyli commented May 8, 2017

Ok, have removed the CLI bits and put them in docker/cli#44. Does the API design look ok? If so, if this could be merged, would love to get #32993 in for 17.06 :)

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

@cyli
Copy link
Contributor Author

cyli commented May 9, 2017

Sorry to keep bothering folks :) Tests are all green - is this ok to merge or are there more API issues to address?

Choose a reason for hiding this comment

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

Please check the error value. It's not necessary to expose it, but I think we should avoid relying on the contents of issuerInfo if the function returns an error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point

@aaronlehmann
Copy link

Noted one thing, otherwise this looks fine. @thaJeztah: Does this PR need to go through docs-review?

@thaJeztah
Copy link
Member

Looking now 👍

@thaJeztah
Copy link
Member

Swagger output looks good to me;

screen shot 2017-05-10 at 19 34 51

Can you;

After docker/cli#44 is merged, we should update some example outputs for

objects into the REST API responses.  In the CLI, display only
whether the nodes' TLS info matches the cluster's TLS info, or
whether the node needs cert rotation.

Signed-off-by: Ying Li <ying.li@docker.com>
@cyli
Copy link
Contributor Author

cyli commented May 10, 2017

@thaJeztah Updated and also opened #33148 in preparation for the CLI PR to be merged :) Thanks

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.

docs LGTM, thanks!

@thaJeztah
Copy link
Member

I see @aaronlehmann's comment was addressed as well; all green, so I'll go ahead and merge 👍

@thaJeztah thaJeztah merged commit f02a5b5 into moby:master May 10, 2017
@cyli
Copy link
Contributor Author

cyli commented May 10, 2017

@thaJeztah Thanks!!

@cyli cyli deleted the root-ca-info-in-api branch May 10, 2017 22:36
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.

7 participants