Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"docker swarm init --force-new-cluster" use limit #34881

Merged
merged 1 commit into from
Sep 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions daemon/cluster/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ const (

// errSwarmCertificatesExpired is returned if docker was not started for the whole validity period and they had no chance to renew automatically.
errSwarmCertificatesExpired notAvailableError = "Swarm certificates have expired. To replace them, leave the swarm and join again."

// errSwarmNotManager is returned if the node is not a swarm manager.
errSwarmNotManager notAvailableError = "This node is not a swarm manager. Worker nodes can't be used to view or modify cluster state. Please run this command on a manager node or promote the current node to a manager."
)

type notFoundError struct {
Expand Down
4 changes: 4 additions & 0 deletions daemon/cluster/swarm.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@ func (c *Cluster) Init(req types.InitRequest) (string, error) {
defer c.controlMutex.Unlock()
if c.nr != nil {
if req.ForceNewCluster {

// Take c.mu temporarily to wait for presently running
// API handlers to finish before shutting down the node.
c.mu.Lock()
if !c.nr.nodeState.IsManager() {
return "", errSwarmNotManager
}
c.mu.Unlock()

if err := c.nr.Stop(); err != nil {
Expand Down