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>
This commit is contained in:
Aaron Lehmann 2016-12-05 14:38:25 -08:00
parent 560d0d25c1
commit e374126ed1
1 changed files with 3 additions and 0 deletions

View File

@ -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