From 9dba9e3248f8476d15242ce3ec0bf6d6d50c1a76 Mon Sep 17 00:00:00 2001 From: Aaron Lehmann Date: Mon, 28 Nov 2016 17:19:29 -0800 Subject: [PATCH] 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 --- daemon/cluster/cluster.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/daemon/cluster/cluster.go b/daemon/cluster/cluster.go index eb4dc78c14..8ad376e5a0 100644 --- a/daemon/cluster/cluster.go +++ b/daemon/cluster/cluster.go @@ -1825,6 +1825,12 @@ func validateAndSanitizeInitRequest(req *types.InitRequest) error { return fmt.Errorf("invalid ListenAddr %q: %v", req.ListenAddr, err) } + if req.Spec.Annotations.Name == "" { + req.Spec.Annotations.Name = "default" + } else if req.Spec.Annotations.Name != "default" { + return errors.New(`swarm spec must be named "default"`) + } + return nil }