mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #34881 from ityangchen/test-moby
"docker swarm init --force-new-cluster" use limit
This commit is contained in:
commit
0b968f9195
2 changed files with 7 additions and 0 deletions
|
@ -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 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."
|
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 {
|
type notFoundError struct {
|
||||||
|
|
|
@ -26,9 +26,13 @@ func (c *Cluster) Init(req types.InitRequest) (string, error) {
|
||||||
defer c.controlMutex.Unlock()
|
defer c.controlMutex.Unlock()
|
||||||
if c.nr != nil {
|
if c.nr != nil {
|
||||||
if req.ForceNewCluster {
|
if req.ForceNewCluster {
|
||||||
|
|
||||||
// Take c.mu temporarily to wait for presently running
|
// Take c.mu temporarily to wait for presently running
|
||||||
// API handlers to finish before shutting down the node.
|
// API handlers to finish before shutting down the node.
|
||||||
c.mu.Lock()
|
c.mu.Lock()
|
||||||
|
if !c.nr.nodeState.IsManager() {
|
||||||
|
return "", errSwarmNotManager
|
||||||
|
}
|
||||||
c.mu.Unlock()
|
c.mu.Unlock()
|
||||||
|
|
||||||
if err := c.nr.Stop(); err != nil {
|
if err := c.nr.Stop(); err != nil {
|
||||||
|
|
Loading…
Add table
Reference in a new issue