Commit 29f5b04b authored by Sigmund Augdal's avatar Sigmund Augdal

Revert "Use etcd locking to prevent races between neighbor monitors on the different routers"

This reverts commit bb87bfd9.

This doesn't seem to work, so try another approach
parent d12590cc
......@@ -58,33 +58,32 @@ def main():
next
mac = entry.key.split("/")[-1].lower()
if not mac in nics:
with neighbors.lock(etcd_client):
if not args.noop:
neighbors.remove_mac(etcd_client, mac)
for addrtype in (neighbors.V4, neighbors.V6_LL, neighbors.V6_PUB):
ipaddr = neighbors.get_ipaddress_from_mac(etcd_client, mac, addrtype)
if ipaddr is not None:
if not args.noop:
if addrtype == neighbors.V6_LL:
continue
dns_rr.reset_ptr(pdns_url, ipaddr, addrtype != neighbors.V4)
if not args.noop:
neighbors.remove_mac(etcd_client, mac)
for addrtype in (neighbors.V4, neighbors.V6_LL, neighbors.V6_PUB):
ipaddr = neighbors.get_ipaddress_from_mac(etcd_client, mac, addrtype)
if ipaddr is not None:
if not args.noop:
if addrtype == neighbors.V6_LL:
continue
dns_rr.reset_ptr(pdns_url, ipaddr, addrtype != neighbors.V4)
else:
logging.info("Would have removed address {} from mac {}".format(ipaddr, mac))
if addrtype == neighbors.V6_LL:
continue
if addrtype == neighbors.V6_PUB:
logging.info("Would have cleaned DNS PTR records for address {}".format(ipaddr))
ptr_record = dns_rr.get_ptr_record(pdns_url, ipaddr, addrtype != neighbors.V4)
if ptr_record:
logging.info("Would have cleaned record: {}".format(ptr_record))
else:
logging.info("Would have removed address {} from mac {}".format(ipaddr, mac))
if addrtype == neighbors.V6_LL:
continue
if addrtype == neighbors.V6_PUB:
logging.info("Would have cleaned DNS PTR records for address {}".format(ipaddr))
ptr_record = dns_rr.get_ptr_record(pdns_url, ipaddr, addrtype != neighbors.V4)
if ptr_record:
logging.info("Would have cleaned record: {}".format(ptr_record))
else:
# Remove DNS PTR record
logging.info("Resetting DNS PTR record for address {}".format(ipaddr))
ptr_record = dns_rr.get_ptr_record(pdns_url, ipaddr, addrtype != neighbors.V4)
logging.info("Would have updates record: {}".format(ptr_record))
if ptr_record:
ptr_record['content'] = dns_rr.generate_ptr(ipaddr)
logging.info("New name: {}".format(ptr_record['content']))
# Remove DNS PTR record
logging.info("Resetting DNS PTR record for address {}".format(ipaddr))
ptr_record = dns_rr.get_ptr_record(pdns_url, ipaddr, addrtype != neighbors.V4)
logging.info("Would have updates record: {}".format(ptr_record))
if ptr_record:
ptr_record['content'] = dns_rr.generate_ptr(ipaddr)
logging.info("New name: {}".format(ptr_record['content']))
else:
logging.debug("found owner for mac {}".format(mac))
......
......@@ -64,26 +64,25 @@ class NeighborCache(object):
def new(self, mac, ipaddr, addrtype):
mac = mac.lower()
with neighbors.lock(self.etcd_client):
old_address = neighbors.get_ipaddress_from_mac(self.etcd_client, mac, addrtype)
if not old_address is None:
if old_address == ipaddr:
return
else:
log.info("%s changed address from %s to %s",
mac, old_address, ipaddr)
neighbors.remove_pair(self.etcd_client, mac, old_address, addrtype)
orig_mac = neighbors.get_mac_from_ipaddress(self.etcd_client, ipaddr, addrtype)
if orig_mac is not None:
log.warning("Duplicate address detected."
" %s tries to take %s from %s",
mac, ipaddr, orig_mac)
old_address = neighbors.get_ipaddress_from_mac(self.etcd_client, mac, addrtype)
if not old_address is None:
if old_address == ipaddr:
return
else:
log.info("New host %s: %s", mac, ipaddr)
neighbors.add_pair(self.etcd_client, mac, ipaddr, addrtype)
log.info("%s changed address from %s to %s",
mac, old_address, ipaddr)
neighbors.remove_pair(self.etcd_client, mac, old_address, addrtype)
orig_mac = neighbors.get_mac_from_ipaddress(self.etcd_client, ipaddr, addrtype)
if orig_mac is not None:
log.warning("Duplicate address detected."
" %s tries to take %s from %s",
mac, ipaddr, orig_mac)
return
else:
log.info("New host %s: %s", mac, ipaddr)
neighbors.add_pair(self.etcd_client, mac, ipaddr, addrtype)
def process_event(self, np):
if np['event'] == 'RTM_NEWNEIGH':
......
......@@ -12,10 +12,6 @@ def etcd_key(mac, addrtype):
return "nova/iaas/instances/{}/{}".format(mac, addrtype)
def lock(etcd_client, ttl=15):
return etcd_client.get_lock("/nova/neighbors", ttl=ttl)
def get_ipaddress_from_mac(etcd_client, mac, addrtype):
mac = mac.lower()
try:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment