Skip to content

Commit

Permalink
Change default host for etcd connections from localhost to 127.0.0.1
Browse files Browse the repository at this point in the history
On RHEL7, and with eventlet < 0.17, and if python-dns is installed, it
doesn't work for a program that uses eventlet to connect to
'localhost'.  This is because:

- RHEL7's /etc/hosts file maps 'localhost' to ::1 as well as to
  127.0.0.1.

- eventlet monkey patches DNS resolution (using python-dns, so that it
  doesn't block all eventlet threads) but the <0.17 code does this in
  a way that doesn't support IPv6 addresses.

The result is that affected systems see an error like this:

2016-03-01 12:09:49.270 10887 TRACE etcd.client MaxRetryError:
HTTPConnectionPool(host='localhost', port=4001): Max retries exceeded
with url: /v2/keys/calico/openstack/v1/neutron_election (Caused by
ProtocolError('Connection aborted.', gaierror(-9, 'Address family for
hostname not supported')))

The RHEL7 Juno repository has eventlet 0.15.2, and current Calico
depends on python-etcd 0.4.3, which in turn depends on python-dns.  So
a Calico install with Juno on RHEL7 is affected by this.
Specifically, the Neutron server hits the above error when the Calico
mechanism driver connects to etcd.

The Calico DHCP agent would also hit a similar error if we used it
with a Juno release.  Currently the Calico DHCP agent is incompatible
with Juno for other reasons; but we plan to address those reasons, so
it makes sense to fix this 'localhost' problem in the Calico DHCP
agent code too.

In both cases, the pragmatic fix is to change 'localhost' to
'127.0.0.1', so that name resolution is not needed.

Change-Id: Ia96d509f4e2a4d49419557aee3f85b8ab9f2518c
Sem-Ver: bugfix
  • Loading branch information
Neil Jerram authored and Neil Jerram committed Mar 2, 2016
1 parent ec7a01c commit 6047195
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
networking-calico (1:1.1.3) trusty; urgency=low

* Change default host for etcd connections from localhost to 127.0.0.1

-- Neil Jerram <Neil.Jerram@metaswitch.com> Wed, 02 Mar 2016 14:08:51 +0000

networking-calico (1:1.1.2) trusty; urgency=low

* Improve workaround for requests/urllib3 vendoring issue
Expand Down
2 changes: 1 addition & 1 deletion debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

export PBR_VERSION=1.1.2
export PBR_VERSION=1.1.3

%:
dh $@ --with python2
4 changes: 2 additions & 2 deletions networking_calico/agent/dhcp_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def _empty_network(self):

def __init__(self, agent):
super(CalicoEtcdWatcher, self).__init__(
'localhost:4001',
'127.0.0.1:4001',
dir_for_host(socket.gethostname()) + "/workload"
)
self.agent = agent
Expand Down Expand Up @@ -413,7 +413,7 @@ def on_dir_delete(self, response, *args, **kwargs):
class SubnetWatcher(EtcdWatcher):

def __init__(self, endpoint_watcher):
super(SubnetWatcher, self).__init__('localhost:4001', SUBNET_DIR)
super(SubnetWatcher, self).__init__('127.0.0.1:4001', SUBNET_DIR)
self.endpoint_watcher = endpoint_watcher
self.register_path(
SUBNET_DIR + "/<subnet_id>",
Expand Down
2 changes: 1 addition & 1 deletion networking_calico/plugins/ml2/drivers/calico/t_etcd.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
# Register Calico-specific options.
calico_opts = [
# etcd connection information.
cfg.StrOpt('etcd_host', default='localhost',
cfg.StrOpt('etcd_host', default='127.0.0.1',
help="The hostname or IP of the etcd node/proxy"),
cfg.IntOpt('etcd_port', default=4001,
help="The port to use for the etcd node/proxy"),
Expand Down
7 changes: 5 additions & 2 deletions rpm/networking-calico.spec
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
Name: networking-calico
Summary: Project Calico networking for OpenStack/Neutron
Epoch: 1
Version: 1.1.2
Release: 2%{?dist}
Version: 1.1.3
Release: 1%{?dist}
License: Apache-2
URL: http://docs.openstack.org/developer/networking-calico/
Source0: networking-calico-%{version}.tar.gz
Expand Down Expand Up @@ -161,6 +161,9 @@ rm -rf $RPM_BUILD_ROOT


%changelog
* Wed Mar 02 2016 Neil Jerram <Neil.Jerram@metaswitch.com> 1:1.1.3-1
- Change default host for etcd connections from localhost to 127.0.0.1

* Tue Mar 01 2016 Neil Jerram <Neil.Jerram@metaswitch.com> 1:1.1.2-2
- Make networking-calico package depend on python-pbr

Expand Down

0 comments on commit 6047195

Please sign in to comment.