Fix account-reaper

As part of commit efb39a5, the account reaper grew a bind_port
attribute, but it wasn't being converted to int, so naturally "6002"
!= 6002, and it wouldn't reap anything.

The bind_port was only used for determining the local devices. Rather
than fix the code to call int(), this commit removes the need for
bind_port entirely by skipping the port check. If your rings have IPs,
this is the same behavior as pre-efb39a5, and if your rings have
hostnames, this still works.

Change-Id: I7bd18e9952f7b9e0d7ce2dce230ee54c5e23709a
This commit is contained in:
Samuel Merritt 2015-02-12 09:59:48 -08:00
parent 843ce7e301
commit a9b5982d52
2 changed files with 11 additions and 4 deletions

View File

@ -59,7 +59,6 @@ class AccountReaper(Daemon):
def __init__(self, conf, logger=None):
self.conf = conf
self.logger = logger or get_logger(conf, log_route='account-reaper')
self.bind_port = conf.get('bind_port', 6002)
self.devices = conf.get('devices', '/srv/node')
self.mount_check = config_true_value(conf.get('mount_check', 'true'))
self.interval = int(conf.get('interval', 3600))
@ -161,9 +160,8 @@ class AccountReaper(Daemon):
if not partition.isdigit():
continue
nodes = self.get_account_ring().get_part_nodes(int(partition))
if not is_local_device(self.myips, self.bind_port,
nodes[0]['ip'], nodes[0]['port']) or \
not os.path.isdir(partition_path):
if (not is_local_device(self.myips, None, nodes[0]['ip'], None)
or not os.path.isdir(partition_path)):
continue
for suffix in os.listdir(partition_path):
suffix_path = os.path.join(partition_path, suffix)

View File

@ -191,6 +191,15 @@ class TestUtils(unittest.TestCase):
self.assertTrue(is_local_device(my_ips, my_port,
"localhost",
my_port))
self.assertFalse(is_local_device(my_ips, my_port,
"localhost",
my_port + 1))
self.assertFalse(is_local_device(my_ips, my_port,
"127.0.0.2",
my_port))
# for those that don't have a local port
self.assertTrue(is_local_device(my_ips, None,
my_ips[0], None))
def test_validate_and_normalize_ip(self):
ipv4 = "10.0.0.1"