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-11-28 17:19:29 -08:00
parent 60e72ea379
commit 9dba9e3248
1 changed files with 6 additions and 0 deletions

View File

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