diff --git a/inventory_provider/tasks/common.py b/inventory_provider/tasks/common.py index ad929ed4677cee9750f0b9b52c2846ecc26584d1..9cfa8437a839502bcd9831adf32fce3ce64fa680 100644 --- a/inventory_provider/tasks/common.py +++ b/inventory_provider/tasks/common.py @@ -98,7 +98,7 @@ def update_latch_status(config, pending=False, failure=False): if not pending and not failure: if not latch['pending'] and not latch['failure']: logger.error( - 'updating latch for db {db} with pending=failure=True, ' + f'updating latch for db {db} with pending=True, ' f'but latch is already {latch}') latch['timestamp'] = now latch['pending'] = pending @@ -112,17 +112,21 @@ def set_latch(config, new_current, new_next, timestamp): new_current, new_next)) for db in config['redis-databases']: - latch = { - 'current': new_current, - 'next': new_next, - 'this': db, - 'pending': False, - 'failure': False, - 'timestamp': timestamp - } - r = _get_redis(config, dbid=db) - r.set('db:latch', json.dumps(latch)) + set_single_latch(r, db, new_current, new_next, timestamp) + + +def set_single_latch(r, db, new_current, new_next, timestamp): + + latch = { + 'current': new_current, + 'next': new_next, + 'this': db, + 'pending': False, + 'failure': False, + 'timestamp': timestamp + } + r.set('db:latch', json.dumps(latch)) def latch_db(config):