Skip to content

Commit

Permalink
Merge pull request #1189 from aaronlehmann/join-tokens
Browse files Browse the repository at this point in the history
Replace secrets, node acceptance, and CA hash with join tokens
  • Loading branch information
diogomonica committed Jul 20, 2016
2 parents eacedad + dd9a504 commit d74b236
Show file tree
Hide file tree
Showing 40 changed files with 1,380 additions and 1,886 deletions.
8 changes: 0 additions & 8 deletions Godeps/Godeps.json

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

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
17 changes: 3 additions & 14 deletions agent/node.go
Expand Up @@ -43,11 +43,8 @@ type NodeConfig struct {
// remote managers and certificates.
StateDir string

// 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 All @@ -73,9 +70,6 @@ type NodeConfig struct {
// HeartbeatTick defines the amount of ticks between each
// heartbeat sent to other members for health-check purposes
HeartbeatTick uint32

// todo: temporary to bypass promotion not working yet
IsManager bool
}

// Node implements the primary node functionality for a member of a swarm
Expand Down Expand Up @@ -193,11 +187,6 @@ func (n *Node) run(ctx context.Context) (err error) {
}
}

csrRole := n.role
if n.config.IsManager { // todo: temporary
csrRole = ca.ManagerRole
}

// Obtain new certs and setup TLS certificates renewal for this node:
// - We call LoadOrCreateSecurityConfig which blocks until a valid certificate has been issued
// - We retrieve the nodeID from LoadOrCreateSecurityConfig through the info channel. This allows
Expand All @@ -220,7 +209,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, ca.ManagerRole, picker.NewPicker(n.remotes), issueResponseChan)
if err != nil {
return err
}
Expand Down
94 changes: 48 additions & 46 deletions api/ca.pb.go

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

10 changes: 7 additions & 3 deletions api/ca.proto
Expand Up @@ -34,11 +34,15 @@ 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

// Token represents a user-provided string that is necessary for new
// nodes to join the cluster
string secret = 3;
string token = 3;
}

message IssueNodeCertificateResponse {
Expand Down

0 comments on commit d74b236

Please sign in to comment.