From 5a434d86f1e17f3586517587998fc5980decb036 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Wed, 20 Jan 2016 15:12:52 -0500 Subject: [PATCH] Fix for rax cache timeout issue 2.4.0 level of rax.py introduces a default cache timeout of 600s, this fixes that and includes a new rax.py inventory module that has been submitted upstream. --- awx/main/tasks.py | 1 + awx/plugins/inventory/rax.py | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/awx/main/tasks.py b/awx/main/tasks.py index 622c533333..5025e5b3d7 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -1194,6 +1194,7 @@ class RunInventoryUpdate(BaseTask): elif inventory_update.source == 'rax': env['RAX_CREDS_FILE'] = cloud_credential env['RAX_REGION'] = inventory_update.source_regions or 'all' + env['RAX_CACHE_MAX_AGE'] = 0 # Set this environment variable so the vendored package won't # complain about not being able to determine its version number. env['PBR_VERSION'] = '0.5.21' diff --git a/awx/plugins/inventory/rax.py b/awx/plugins/inventory/rax.py index 0028f54d20..4ac6b0f47e 100755 --- a/awx/plugins/inventory/rax.py +++ b/awx/plugins/inventory/rax.py @@ -355,9 +355,12 @@ def get_cache_file_path(regions): def _list(regions, refresh_cache=True): + cache_max_age = int(get_config(p, 'rax', 'cache_max_age', + 'RAX_CACHE_MAX_AGE', 600)) + if (not os.path.exists(get_cache_file_path(regions)) or refresh_cache or - (time() - os.stat(get_cache_file_path(regions))[-1]) > 600): + (time() - os.stat(get_cache_file_path(regions))[-1]) > cache_max_age): # Cache file doesn't exist or older than 10m or refresh cache requested _list_into_cache(regions)