Browse code

Re-vendor swarmkit to a version which does not require all cluster updates to include an external CA certificate when updating external CAs.

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

Ying Li authored on 2017/04/13 06:49:55
Showing 3 changed files
... ...
@@ -105,7 +105,7 @@ github.com/docker/containerd 9048e5e50717ea4497b757314bad98ea3763c145
105 105
 github.com/tonistiigi/fifo 1405643975692217d6720f8b54aeee1bf2cd5cf4
106 106
 
107 107
 # cluster
108
-github.com/docker/swarmkit d5232280c510d70755ab11305d46a5704735371a
108
+github.com/docker/swarmkit 6a6f38c02f1c96b1d3c548e45927349656ae37a1
109 109
 github.com/gogo/protobuf 8d70fb3182befc465c4a1eac8ad4d38ff49778e2
110 110
 github.com/cloudflare/cfssl 7fb22c8cba7ecaf98e4082d22d65800cf45e042a
111 111
 github.com/google/certificate-transparency d90e65c3a07988180c5b1ece71791c0b6506826e
... ...
@@ -148,14 +148,16 @@ func validateHasAtLeastOneExternalCA(ctx context.Context, externalCAs map[string
148 148
 
149 149
 // validates that the list of external CAs have valid certs associated with them, and produce a mapping of subject/pubkey:external
150 150
 // for later validation of required external CAs
151
-func getNormalizedExtCAs(caConfig *api.CAConfig) (map[string][]*api.ExternalCA, error) {
151
+func getNormalizedExtCAs(caConfig *api.CAConfig, normalizedCurrentRootCACert []byte) (map[string][]*api.ExternalCA, error) {
152 152
 	extCAs := make(map[string][]*api.ExternalCA)
153 153
 
154 154
 	for _, extCA := range caConfig.ExternalCAs {
155
-		if len(extCA.CACert) == 0 {
156
-			return nil, grpc.Errorf(codes.InvalidArgument, "must specify CA certificate for each external CA")
155
+		associatedCert := normalizedCurrentRootCACert
156
+		// if no associated cert is provided, assume it's the current root cert
157
+		if len(extCA.CACert) > 0 {
158
+			associatedCert = ca.NormalizePEMs(extCA.CACert)
157 159
 		}
158
-		certKey := string(ca.NormalizePEMs(extCA.CACert))
160
+		certKey := string(associatedCert)
159 161
 		extCAs[certKey] = append(extCAs[certKey], extCA)
160 162
 	}
161 163
 
... ...
@@ -191,12 +193,12 @@ func validateCAConfig(ctx context.Context, securityConfig *ca.SecurityConfig, cl
191 191
 		return nil, grpc.Errorf(codes.InvalidArgument, "if a signing CA key is provided, the signing CA cert must also be provided")
192 192
 	}
193 193
 
194
-	extCAs, err := getNormalizedExtCAs(newConfig) // validate that the list of external CAs is not malformed
194
+	normalizedRootCA := ca.NormalizePEMs(cluster.RootCA.CACert)
195
+	extCAs, err := getNormalizedExtCAs(newConfig, normalizedRootCA) // validate that the list of external CAs is not malformed
195 196
 	if err != nil {
196 197
 		return nil, err
197 198
 	}
198 199
 
199
-	normalizedRootCA := ca.NormalizePEMs(cluster.RootCA.CACert)
200 200
 	var oldCertExtCAs []*api.ExternalCA
201 201
 	if !hasSigningKey(&cluster.RootCA) {
202 202
 		oldCertExtCAs, err = validateHasAtLeastOneExternalCA(ctx, extCAs, securityConfig, normalizedRootCA, "current")
... ...
@@ -297,8 +297,9 @@ func (g *Orchestrator) reconcileServices(ctx context.Context, serviceIDs []strin
297 297
 	updates := make(map[*api.Service][]orchestrator.Slot)
298 298
 
299 299
 	_, err := g.store.Batch(func(batch *store.Batch) error {
300
-		var updateTasks []orchestrator.Slot
301 300
 		for _, serviceID := range serviceIDs {
301
+			var updateTasks []orchestrator.Slot
302
+
302 303
 			if _, exists := nodeTasks[serviceID]; !exists {
303 304
 				continue
304 305
 			}
... ...
@@ -352,7 +353,6 @@ func (g *Orchestrator) reconcileServices(ctx context.Context, serviceIDs []strin
352 352
 	for service, updateTasks := range updates {
353 353
 		g.updater.Update(ctx, g.cluster, service, updateTasks)
354 354
 	}
355
-
356 355
 }
357 356
 
358 357
 // updateNode updates g.nodes based on the current node value