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>
(cherry picked from commit 9dba9e3248f8476d15242ce3ec0bf6d6d50c1a76)
Signed-off-by: Victor Vieux <victorvieux@gmail.com>
| ... | ... |
@@ -1855,6 +1855,12 @@ func validateAndSanitizeInitRequest(req *types.InitRequest) error {
|
| 1855 | 1855 |
return fmt.Errorf("invalid ListenAddr %q: %v", req.ListenAddr, err)
|
| 1856 | 1856 |
} |
| 1857 | 1857 |
|
| 1858 |
+ if req.Spec.Annotations.Name == "" {
|
|
| 1859 |
+ req.Spec.Annotations.Name = "default" |
|
| 1860 |
+ } else if req.Spec.Annotations.Name != "default" {
|
|
| 1861 |
+ return errors.New(`swarm spec must be named "default"`) |
|
| 1862 |
+ } |
|
| 1863 |
+ |
|
| 1858 | 1864 |
return nil |
| 1859 | 1865 |
} |
| 1860 | 1866 |
|