From a1a74aca4853b380fea93875a0035ccf3cdc47a2 Mon Sep 17 00:00:00 2001 From: Erik Reid <erik.reid@geant.org> Date: Fri, 19 Jul 2019 09:32:28 +0200 Subject: [PATCH] more redis current/next debug output --- inventory_provider/tasks/common.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/inventory_provider/tasks/common.py b/inventory_provider/tasks/common.py index 5328815c..df62f1f8 100644 --- a/inventory_provider/tasks/common.py +++ b/inventory_provider/tasks/common.py @@ -72,11 +72,15 @@ def latch_db(config): def _get_redis(config, dbid=None): if dbid is None: - logger.debug('no db specified, using minimum as first guess') dbid = min(config['redis-databases']) + logger.debug( + '_get_redis[1], no db specified, ' + 'using minimum as first guess: {}'.format(dbid)) if dbid not in config['redis-databases']: - logger.error('tried to connect to unknown db id: {}'.format(dbid)) + logger.error( + '_get_redis[2], tried to connect to unknown db id: {}, ' + 'using minimum: {}'.format(dbid, min(config['redis-databases']))) dbid = min(config['redis-databases']) kwargs = { @@ -106,8 +110,12 @@ def get_current_redis(config): logger.warning("can't determine current db") return r if latch['this'] == latch['current']: + logger.debug( + 'get_current_redis[1], using first latch: {}'.format(latch)) return r else: + logger.debug( + 'get_current_redis[2], using current latch: {}'.format(latch)) return _get_redis(config, latch['current']) @@ -115,13 +123,17 @@ def get_next_redis(config): r = _get_redis(config) latch = get_latch(r) if latch and latch['this'] == latch['next']: + logger.debug('get_next_redis[1], using first latch: {}'.format(latch)) return r if latch and latch['next'] in config['redis-databases']: + logger.debug('get_next_redis[2], using next latch: {}'.format(latch)) next_id = latch['next'] else: - logger.warning("next db not configured, deriving default value") db_ids = sorted(set(config['redis-databases'])) next_id = db_ids[0] if len(db_ids) == 1 else db_ids[1] + logger.debug( + 'get_next_redis[3], next db not configured, ' + 'derived next id: {}'.format(next_id)) return _get_redis(config, next_id) -- GitLab