From 1e9fa644a4aab702016a66824bb566a726f33d9f Mon Sep 17 00:00:00 2001 From: Diptanu Choudhury Date: Thu, 7 Apr 2016 13:25:38 -0700 Subject: [PATCH 1/2] removing interfaces from config --- command/agent/agent.go | 30 ++------------------------- command/agent/config.go | 37 --------------------------------- command/agent/config_parse.go | 39 ----------------------------------- 3 files changed, 2 insertions(+), 104 deletions(-) diff --git a/command/agent/agent.go b/command/agent/agent.go index 4814c567c0e..db54da2876d 100644 --- a/command/agent/agent.go +++ b/command/agent/agent.go @@ -127,29 +127,10 @@ func (a *Agent) serverConfig() (*nomad.Config, error) { } if addr := a.config.Addresses.RPC; addr != "" { conf.RPCAddr.IP = net.ParseIP(addr) - } else if device := a.config.Interfaces.RPC; device != "" { - ip, err := ipOfDevice(device) - if err != nil { - return nil, err - } - conf.RPCAddr.IP = ip } + if addr := a.config.Addresses.Serf; addr != "" { conf.SerfConfig.MemberlistConfig.BindAddr = addr - } else if device := a.config.Interfaces.Serf; device != "" { - ip, err := ipOfDevice(device) - if err != nil { - return nil, err - } - conf.SerfConfig.MemberlistConfig.BindAddr = ip.String() - } - - if device := a.config.Interfaces.HTTP; device != "" && a.config.Addresses.HTTP == "" { - ip, err := ipOfDevice(device) - if err != nil { - return nil, err - } - a.config.Addresses.HTTP = ip.String() } // Set up the ports @@ -232,18 +213,11 @@ func (a *Agent) clientConfig() (*clientconfig.Config, error) { // Setting the proper HTTP Addr httpAddr := fmt.Sprintf("%s:%d", a.config.BindAddr, a.config.Ports.HTTP) - if a.config.Addresses.HTTP != "" && a.config.AdvertiseAddrs.HTTP == "" && a.config.Interfaces.HTTP == "" { + if a.config.Addresses.HTTP != "" && a.config.AdvertiseAddrs.HTTP == "" { httpAddr = fmt.Sprintf("%s:%d", a.config.Addresses.HTTP, a.config.Ports.HTTP) if _, err := net.ResolveTCPAddr("tcp", httpAddr); err != nil { return nil, fmt.Errorf("error resolving http addr: %v:", err) } - } else if a.config.Interfaces.HTTP != "" && a.config.AdvertiseAddrs.HTTP == "" { - ip, err := ipOfDevice(a.config.Interfaces.HTTP) - if err != nil { - return nil, fmt.Errorf("error finding ip address from interface %q: %v", a.config.Interfaces.HTTP, err) - } - a.config.Addresses.HTTP = ip.String() - httpAddr = fmt.Sprintf("%s:%d", ip.String(), a.config.Ports.HTTP) } else if a.config.AdvertiseAddrs.HTTP != "" { addr, err := net.ResolveTCPAddr("tcp", a.config.AdvertiseAddrs.HTTP) if err != nil { diff --git a/command/agent/config.go b/command/agent/config.go index e6e173db1e1..6137ea4f00c 100644 --- a/command/agent/config.go +++ b/command/agent/config.go @@ -46,10 +46,6 @@ type Config struct { // Addresses is used to override the network addresses we bind to. Addresses *Addresses `mapstructure:"addresses"` - // Interfaces is used to override the network addresses we bind to by - // providing device names - Interfaces *Interfaces `mapstructure:"interfaces"` - // AdvertiseAddrs is used to control the addresses we advertise. AdvertiseAddrs *AdvertiseAddrs `mapstructure:"advertise"` @@ -259,14 +255,6 @@ type Addresses struct { Serf string `mapstructure:"serf"` } -// Interfaces provides an alternative to the Addresses configuration. We pick an -// ip configured on the devide specified and use that to bind. -type Interfaces struct { - HTTP string `mapstructure:"http"` - RPC string `mapstructure:"rpc"` - Serf string `mapstructure:"serf"` -} - // AdvertiseAddrs is used to control the addresses we advertise out for // different network services. Not all network services support an // advertise address. All are optional and default to BindAddr. @@ -378,7 +366,6 @@ func DefaultConfig() *Config { Serf: 4648, }, Addresses: &Addresses{}, - Interfaces: &Interfaces{}, AdvertiseAddrs: &AdvertiseAddrs{}, Atlas: &AtlasConfig{}, Client: &ClientConfig{ @@ -509,14 +496,6 @@ func (c *Config) Merge(b *Config) *Config { result.Addresses = result.Addresses.Merge(b.Addresses) } - // Apply the interfaces config - if result.Interfaces == nil && b.Interfaces != nil { - interfaces := *b.Interfaces - result.Interfaces = &interfaces - } else if b.Interfaces != nil { - result.Interfaces = result.Interfaces.Merge(b.Interfaces) - } - // Apply the advertise addrs config if result.AdvertiseAddrs == nil && b.AdvertiseAddrs != nil { advertise := *b.AdvertiseAddrs @@ -696,22 +675,6 @@ func (a *Addresses) Merge(b *Addresses) *Addresses { return &result } -// Merge is used to merge two interfaces configs together. -func (i *Interfaces) Merge(b *Interfaces) *Interfaces { - result := *i - - if b.HTTP != "" { - result.HTTP = b.HTTP - } - if b.RPC != "" { - result.RPC = b.RPC - } - if b.Serf != "" { - result.Serf = b.Serf - } - return &result -} - // Merge merges two advertise addrs configs together. func (a *AdvertiseAddrs) Merge(b *AdvertiseAddrs) *AdvertiseAddrs { result := *a diff --git a/command/agent/config_parse.go b/command/agent/config_parse.go index e9d23767802..99bd06f072c 100644 --- a/command/agent/config_parse.go +++ b/command/agent/config_parse.go @@ -130,13 +130,6 @@ func parseConfig(result *Config, list *ast.ObjectList) error { } } - // Parse interfaces - if o := list.Filter("interfaces"); len(o.Items) > 0 { - if err := parseInterfaces(&result.Interfaces, o); err != nil { - return multierror.Prefix(err, "interfaces ->") - } - } - // Parse advertise if o := list.Filter("advertise"); len(o.Items) > 0 { if err := parseAdvertise(&result.AdvertiseAddrs, o); err != nil { @@ -253,38 +246,6 @@ func parseAddresses(result **Addresses, list *ast.ObjectList) error { return nil } -func parseInterfaces(result **Interfaces, list *ast.ObjectList) error { - list = list.Elem() - if len(list.Items) > 1 { - return fmt.Errorf("only one 'interfaces' block allowed") - } - - // Get our interfaces object - listVal := list.Items[0].Val - - // Check for the invalid keys - valid := []string{ - "http", - "rpc", - "serf", - } - if err := checkHCLKeys(listVal, valid); err != nil { - return err - } - - var m map[string]interface{} - if err := hcl.DecodeObject(&m, listVal); err != nil { - return err - } - - var interfaces Interfaces - if err := mapstructure.WeakDecode(m, &interfaces); err != nil { - return err - } - *result = &interfaces - return nil -} - func parseAdvertise(result **AdvertiseAddrs, list *ast.ObjectList) error { list = list.Elem() if len(list.Items) > 1 { From bed0f2b08c0004e4a30829eefa035abaa0cd01de Mon Sep 17 00:00:00 2001 From: Diptanu Choudhury Date: Thu, 7 Apr 2016 13:31:32 -0700 Subject: [PATCH 2/2] Removing the interfaces block from docs --- website/source/docs/agent/config.html.md | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/website/source/docs/agent/config.html.md b/website/source/docs/agent/config.html.md index 041bf31c8f4..bd59acec7c2 100644 --- a/website/source/docs/agent/config.html.md +++ b/website/source/docs/agent/config.html.md @@ -144,22 +144,6 @@ nodes, unless otherwise specified: server nodes from the same datacenter if possible. Used only on server nodes. -* `interfaces`: Provides an alternative to the - `addresses` configuration. Operators can provide network device names to which - Nomad binds individual network services. Nomad looks for the first IPv4 - address configured for the device and uses it, and if no IPv4 address is - present then it looks for an IPv6 address. The value is a map of device names of - network interfaces and supports the following keys: -
- * `http`: The device name the HTTP server is bound to. Applies to both clients and servers. - * `rpc`: The device name to bind the internal RPC interfaces to. Should be exposed - only to other cluster members if possible. Used only on server nodes, but - must be accessible from all agents. - * `serf`: The device name used to bind the gossip layer to. Both a TCP and UDP - listener will be exposed on this address. Should be restricted to only - server nodes from the same datacenter if possible. Used only on server - nodes. - * `advertise`: Controls the advertise address for individual network services. This can be used to advertise a different address to the peers of a server node to support more complex network configurations such as NAT. This