Skip to content

ca: all managers will update their security configs when cluster root CA updated#1984

Merged
diogomonica merged 2 commits into
moby:masterfrom
cyli:managers-update-root-ca
Mar 1, 2017
Merged

ca: all managers will update their security configs when cluster root CA updated#1984
diogomonica merged 2 commits into
moby:masterfrom
cyli:managers-update-root-ca

Conversation

@cyli
Copy link
Copy Markdown
Contributor

@cyli cyli commented Feb 24, 2017

Rather than just the leader that is running the CA server. This way on root rotation, all managers will get root changes right away.

#1983 will actually update the TLS creds with the new root pool when the RootCA is updated

@cyli cyli force-pushed the managers-update-root-ca branch from 36ee1c9 to f66156e Compare February 24, 2017 05:25
@codecov-io
Copy link
Copy Markdown

codecov-io commented Feb 24, 2017

Codecov Report

Merging #1984 into master will increase coverage by 0.11%.
The diff coverage is 90%.

@@            Coverage Diff             @@
##           master    #1984      +/-   ##
==========================================
+ Coverage   53.61%   53.72%   +0.11%     
==========================================
  Files         109      109              
  Lines       18919    18923       +4     
==========================================
+ Hits        10144    10167      +23     
+ Misses       7541     7520      -21     
- Partials     1234     1236       +2

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 46bbd41...4d0ba73. Read the comment docs.

@cyli cyli changed the title ca: all managers will update their security configs when cluster root CA updated WIP: ca: all managers will update their security configs when cluster root CA updated Feb 24, 2017
@cyli cyli force-pushed the managers-update-root-ca branch from f66156e to 5e0ea96 Compare February 24, 2017 18:23
@cyli cyli changed the title WIP: ca: all managers will update their security configs when cluster root CA updated ca: all managers will update their security configs when cluster root CA updated Feb 24, 2017
Comment thread manager/manager_test.go Outdated
<-done
}

// If the root CA materia is updated in the memory store, a manager will update its own
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

material

(I don't get any pleasure out of pointing out typos, but if I don't do it, someone else will open a PR, and I prefer to preempt those.)

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.

I appreciate it! I tend to misspell a bunch of stuff. I wonder if we should add github.com/client9/misspell/cmd/misspell to the linter?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I don't know what the false positive rate is, but I guess it can't hurt to try.

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.

Looks like it wouldn't have caught this one anyway, I guess because materia is a real word, although latin).

Comment thread ca/server.go Outdated

// skipAutoUpdateRootCA, if set to true, causes the CA server to skip automatically updating
// the signing credentials based on changes in the memory store
skipAutoUpdateRootCA bool
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The auto-update functionality seems like it's only used for test cases. I'm curious how difficult/ugly it would be to completely remove this.

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.

We can add a cluster watch functionality to the test CA server. I put this in mainly because it seemed nice for the CA server to a be completely self-sufficient server, if necessary, if someone wanted to run one independently of the manager (which I agree, we are only only for tests, but the CA server would not be as usable otherwise).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'll trust your judgement on this. I didn't like having an option that's never enabled by the actual program, but it's basically enabling or disabling a function call, and the alternative is having the test harness do significantly more.

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.

Another option I was considering was to have a separate startable goroutine on the server that would watch the memory store and auto-update the RootCA. Then whomever is responsible for starting it would have to cancel it as well. Would this be more preferable? But again, this would only be used for the tests.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I still think it's better to move the s.UpdateRootCA call out of the CA server code, but I won't block the PR on this.

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, I don't feel super strongly about my position - it's more of a preference, so happy to address this.

@aaronlehmann
Copy link
Copy Markdown
Collaborator

aaronlehmann commented Feb 24, 2017 via email

@cyli cyli force-pushed the managers-update-root-ca branch 2 times, most recently from 143ceac to 747ed31 Compare February 27, 2017 22:43
…heir SecurityConfig's

RootCA upon a change in the cluster's RootCA configuration.

Signed-off-by: cyli <ying.li@docker.com>
@cyli cyli force-pushed the managers-update-root-ca branch from 747ed31 to 7d8f54f Compare February 27, 2017 22:43
@cyli cyli mentioned this pull request Feb 28, 2017
10 tasks
Comment thread manager/manager.go Outdated
if err := ca.UpdateSecurityConfigFromCluster(ctx, m.config.SecurityConfig, cluster); err != nil {
log.G(ctx).WithError(err).Error("updating Root CA failed")
}
m.caserver.UpdateJoinTokens(ctx, cluster)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It seems weird for a function called updateRootCA to be updating join tokens.

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.

Would a rename to something more appropriate be ok, or would you suggest having 2 watches on the cluster, one to update the root CA and one to update the join tokens? My preference is for the first, to make sure that both are updated in sync.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Just want a rename

Comment thread ca/server.go Outdated

// UpdateSecurityConfigFromCluster takes an api.Cluster object and updates the security config based on the changes
// in the RootCA and ExternalURLs from that cluster object.
func UpdateSecurityConfigFromCluster(ctx context.Context, s *SecurityConfig, cluster *api.Cluster) error {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe just UpdateSecurityConfig?

Would it make sense to make it a method on (*SecurityConfig)? and call it Update?

…entirely

Signed-off-by: cyli <ying.li@docker.com>
@cyli cyli force-pushed the managers-update-root-ca branch from 7d8f54f to 4d0ba73 Compare February 28, 2017 00:59
@aaronlehmann
Copy link
Copy Markdown
Collaborator

LGTM

@aaronlehmann
Copy link
Copy Markdown
Collaborator

ping @diogomonica

@diogomonica diogomonica merged commit 25387c0 into moby:master Mar 1, 2017
@cyli cyli deleted the managers-update-root-ca branch March 2, 2017 07:16
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.

4 participants