Pārlūkot izejas kodu

cluster: Refuse swarm spec not named "default"

If, using the API, a user submits an init request with a spec that has a
name other than "default", the engine will rename the "default" cluster
object. Some parts of swarmkit depend on having a cluster object named
"default". Reject any specs that use other names.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
Aaron Lehmann 8 gadi atpakaļ
vecāks
revīzija
e374126ed1
1 mainītis faili ar 3 papildinājumiem un 0 dzēšanām
  1. 3 0
      daemon/cluster/cluster.go

+ 3 - 0
daemon/cluster/cluster.go

@@ -2,6 +2,7 @@ package cluster
 
 import (
 	"encoding/json"
+	stdliberrors "errors"
 	"fmt"
 	"io/ioutil"
 	"net"
@@ -1322,6 +1323,8 @@ func validateAndSanitizeInitRequest(req *types.InitRequest) error {
 	// provide sane defaults instead of erroring
 	if spec.Name == "" {
 		spec.Name = "default"
+	} else if spec.Name != "default" {
+		return stdliberrors.New(`swarm spec must be named "default"`)
 	}
 	if spec.Raft.SnapshotInterval == 0 {
 		spec.Raft.SnapshotInterval = defaultSpec.Raft.SnapshotInterval