Force worker to use the local controller when running in combined mode (#429)

pull/431/head
Jeff Mitchell 6 years ago committed by GitHub
parent 19bee0b3bc
commit 10a41c914e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -172,7 +172,7 @@ func (c *Command) Run(args []string) int {
}
// Perform controller-specific listener checks here before setup
var foundCluster bool
var clusterAddr string
var foundApi bool
var foundProxy bool
for _, lnConfig := range c.Config.Listeners {
@ -185,7 +185,10 @@ func (c *Command) Run(args []string) int {
purpose := lnConfig.Purpose[0]
switch purpose {
case "cluster":
foundCluster = true
clusterAddr = lnConfig.Address
if clusterAddr == "" {
clusterAddr = "127.0.0.1:9201"
}
case "api":
foundApi = true
case "proxy":
@ -205,7 +208,7 @@ func (c *Command) Run(args []string) int {
c.UI.Error(`Config activates controller but no listener with "api" purpose found`)
return 1
}
if !foundCluster {
if clusterAddr == "" {
c.UI.Error(`Config activates controller but no listener with "cluster" purpose found`)
return 1
}
@ -215,6 +218,20 @@ func (c *Command) Run(args []string) int {
c.UI.Error(`Config activates worker but no listener with "proxy" purpose found`)
return 1
}
if c.Config.Controller != nil {
switch len(c.Config.Worker.Controllers) {
case 0:
case 1:
if c.Config.Worker.Controllers[0] == clusterAddr {
break
}
fallthrough
default:
c.UI.Error(`When running a combined controller and worker, it's invalid to specify a "controllers" key in the worker block with any value other than the controller cluster address`)
return 1
}
c.Config.Worker.Controllers = []string{clusterAddr}
}
}
if err := c.SetupListeners(c.UI, c.Config.SharedConfig, []string{"api", "cluster", "proxy"}); err != nil {
c.UI.Error(err.Error())

Loading…
Cancel
Save