Skip to content

Commit

Permalink
Replace secrets, node acceptance, and CA hash with join tokens
Browse files Browse the repository at this point in the history
Implement the swarmkit parts of the flow described in
moby/moby#24430.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
  • Loading branch information
aaronlehmann committed Jul 19, 2016
1 parent 60115ea commit 26dda2a
Show file tree
Hide file tree
Showing 30 changed files with 1,280 additions and 964 deletions.
4 changes: 2 additions & 2 deletions agent/agent_test.go
Expand Up @@ -58,7 +58,7 @@ func TestAgent(t *testing.T) {
}

func TestAgentStartStop(t *testing.T) {
tc := testutils.NewTestCA(t, testutils.AcceptancePolicy(true, true, ""))
tc := testutils.NewTestCA(t)
defer tc.Stop()

agentSecurityConfig, err := tc.NewNodeConfig(ca.AgentRole)
Expand Down Expand Up @@ -137,7 +137,7 @@ func TestHandleSessionMessage(t *testing.T) {

func agentTestEnv(t *testing.T) (*Agent, func()) {
var cleanup []func()
tc := testutils.NewTestCA(t, testutils.AcceptancePolicy(true, true, ""))
tc := testutils.NewTestCA(t)
cleanup = append(cleanup, func() { tc.Stop() })

agentSecurityConfig, err := tc.NewNodeConfig(ca.AgentRole)
Expand Down
6 changes: 3 additions & 3 deletions agent/node.go
Expand Up @@ -46,8 +46,8 @@ type NodeConfig struct {
// CAHash to be used on the first certificate request.
CAHash string

// Secret to be used on the first certificate request.
Secret string
// JoinToken is the token to be used on the first certificate request.
JoinToken string

// ExternalCAs is a list of CAs to which a manager node
// will make certificate signing requests for node certificates.
Expand Down Expand Up @@ -220,7 +220,7 @@ func (n *Node) run(ctx context.Context) (err error) {
}()

certDir := filepath.Join(n.config.StateDir, "certificates")
securityConfig, err := ca.LoadOrCreateSecurityConfig(ctx, certDir, n.config.CAHash, n.config.Secret, csrRole, picker.NewPicker(n.remotes), issueResponseChan)
securityConfig, err := ca.LoadOrCreateSecurityConfig(ctx, certDir, n.config.JoinToken, csrRole, picker.NewPicker(n.remotes), issueResponseChan)
if err != nil {
return err
}
Expand Down
64 changes: 33 additions & 31 deletions api/ca.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion api/ca.proto
Expand Up @@ -34,8 +34,12 @@ message NodeCertificateStatusResponse {
}

message IssueNodeCertificateRequest {
NodeRole role = 1;
// DEPRECATED: Role is now selected based on which secret is matched.
NodeRole role = 1 [deprecated=true];

// CSR is the certificate signing request.
bytes csr = 2 [(gogoproto.customname) = "CSR"];

// Secret represents a user-provided string that is necessary for new
// nodes to join the cluster
string secret = 3;
Expand Down

0 comments on commit 26dda2a

Please sign in to comment.