mirror of
https://github.com/kemko/nomad.git
synced 2026-01-05 09:55:44 +03:00
Disambiguate auto_join from auto_register, rename reg to auto_advertise.
Provide an option that describes the value to the user vs the operation performed by the software. Momentarily introducing `auto_join`
This commit is contained in:
@@ -134,7 +134,7 @@ func DefaultConfig() *Config {
|
||||
ConsulConfig: &config.ConsulConfig{
|
||||
ServerServiceName: "nomad",
|
||||
ClientServiceName: "nomad-client",
|
||||
AutoRegister: true,
|
||||
AutoAdvertise: true,
|
||||
Timeout: 5 * time.Second,
|
||||
},
|
||||
LogOutput: os.Stderr,
|
||||
|
||||
@@ -76,7 +76,7 @@ func NewAgent(config *Config, logOutput io.Writer) (*Agent, error) {
|
||||
|
||||
// The Nomad Agent runs the consul.Syncer regardless of whether or not the
|
||||
// Agent is running in Client or Server mode (or both), and regardless of
|
||||
// the consul.auto_register parameter. The Client and Server both reuse the
|
||||
// the consul.auto_advertise parameter. The Client and Server both reuse the
|
||||
// same consul.Syncer instance. This Syncer task periodically executes
|
||||
// callbacks that update Consul. The reason the Syncer is always running is
|
||||
// because one of the callbacks is attempts to self-bootstrap Nomad using
|
||||
@@ -230,6 +230,12 @@ func (a *Agent) serverConfig() (*nomad.Config, error) {
|
||||
conf.HeartbeatGrace = dur
|
||||
}
|
||||
|
||||
if a.config.Consul.AutoAdvertise && a.config.Consul.ServerServiceName == "" {
|
||||
return nil, fmt.Errorf("server_service_name must be set when auto_advertise is enabled")
|
||||
}
|
||||
|
||||
// conf.ConsulConfig = a.config.Consul
|
||||
|
||||
return conf, nil
|
||||
}
|
||||
|
||||
@@ -333,6 +339,10 @@ func (a *Agent) clientConfig() (*clientconfig.Config, error) {
|
||||
conf.Version = fmt.Sprintf("%s%s", a.config.Version, a.config.VersionPrerelease)
|
||||
conf.Revision = a.config.Revision
|
||||
|
||||
if a.config.Consul.AutoAdvertise && a.config.Consul.ClientServiceName == "" {
|
||||
return nil, fmt.Errorf("client_service_name must be set when auto_advertise is enabled")
|
||||
}
|
||||
|
||||
conf.ConsulConfig = a.config.Consul
|
||||
|
||||
conf.StatsCollectionInterval = a.config.Client.StatsConfig.collectionInterval
|
||||
@@ -360,7 +370,7 @@ func (a *Agent) setupServer() error {
|
||||
a.server = server
|
||||
|
||||
// Create the Nomad Server services for Consul
|
||||
if a.config.Consul.AutoRegister && a.config.Consul.ServerServiceName != "" {
|
||||
if a.config.Consul.AutoAdvertise {
|
||||
httpServ := &structs.Service{
|
||||
Name: a.config.Consul.ServerServiceName,
|
||||
PortLabel: a.serverHTTPAddr,
|
||||
@@ -413,7 +423,7 @@ func (a *Agent) setupClient() error {
|
||||
a.client = client
|
||||
|
||||
// Create the Nomad Client services for Consul
|
||||
if a.config.Consul.AutoRegister && a.config.Consul.ClientServiceName != "" {
|
||||
if a.config.Consul.AutoAdvertise {
|
||||
httpServ := &structs.Service{
|
||||
Name: a.config.Consul.ClientServiceName,
|
||||
PortLabel: a.clientHTTPAddr,
|
||||
|
||||
@@ -362,7 +362,7 @@ func DevConfig() *Config {
|
||||
conf.DevMode = true
|
||||
conf.EnableDebug = true
|
||||
conf.DisableAnonymousSignature = true
|
||||
conf.Consul.AutoRegister = true
|
||||
conf.Consul.AutoAdvertise = true
|
||||
if runtime.GOOS == "darwin" {
|
||||
conf.Client.NetworkInterface = "lo0"
|
||||
} else if runtime.GOOS == "linux" {
|
||||
@@ -393,7 +393,7 @@ func DefaultConfig() *Config {
|
||||
Consul: &config.ConsulConfig{
|
||||
ServerServiceName: "nomad",
|
||||
ClientServiceName: "nomad-client",
|
||||
AutoRegister: true,
|
||||
AutoAdvertise: true,
|
||||
Timeout: 5 * time.Second,
|
||||
},
|
||||
Client: &ClientConfig{
|
||||
|
||||
@@ -600,7 +600,7 @@ func parseConsulConfig(result **config.ConsulConfig, list *ast.ObjectList) error
|
||||
valid := []string{
|
||||
"address",
|
||||
"auth",
|
||||
"auto_register",
|
||||
"auto_advertise",
|
||||
"ca_file",
|
||||
"cert_file",
|
||||
"client_auto_join",
|
||||
|
||||
@@ -24,9 +24,10 @@ type ConsulConfig struct {
|
||||
// clients with Consul
|
||||
ClientServiceName string `mapstructure:"client_service_name"`
|
||||
|
||||
// AutoRegister determines if Nomad will register the Nomad client and
|
||||
// server agents with Consul
|
||||
AutoRegister bool `mapstructure:"auto_register"`
|
||||
// AutoAdvertise determines if this Nomad Agent will advertise its
|
||||
// services via Consul. When true, Nomad Agent will register
|
||||
// services with Consul.
|
||||
AutoAdvertise bool `mapstructure:"auto_advertise"`
|
||||
|
||||
// Addr is the address of the local Consul agent
|
||||
Addr string `mapstructure:"address"`
|
||||
@@ -76,8 +77,8 @@ func (a *ConsulConfig) Merge(b *ConsulConfig) *ConsulConfig {
|
||||
if b.ClientServiceName != "" {
|
||||
result.ClientServiceName = b.ClientServiceName
|
||||
}
|
||||
if b.AutoRegister {
|
||||
result.AutoRegister = true
|
||||
if b.AutoAdvertise {
|
||||
result.AutoAdvertise = true
|
||||
}
|
||||
if b.Addr != "" {
|
||||
result.Addr = b.Addr
|
||||
|
||||
Reference in New Issue
Block a user