From 1a6082fda17448db60e17d8d8d71466fef5c7dbb Mon Sep 17 00:00:00 2001 From: Radhika Pai Date: Thu, 18 Mar 2021 17:45:58 +0000 Subject: [PATCH] [fix] Openstack exporter update This ps updates the logic to clear the token when it receives authorization error from keystone. This is a special case of 401. When the exporter receives a 401 error from the keystone and the application is not placement, we reset the token value such that on the next retry it reinitialize the parameters. Change-Id: I0c4bcb17aa420e31591405b6000a2db2821e2428 --- prometheus-openstack-exporter/exporter/check_os_api.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/prometheus-openstack-exporter/exporter/check_os_api.py b/prometheus-openstack-exporter/exporter/check_os_api.py index a5a05c98..b6e1bf21 100644 --- a/prometheus-openstack-exporter/exporter/check_os_api.py +++ b/prometheus-openstack-exporter/exporter/check_os_api.py @@ -96,6 +96,10 @@ class CheckOSApi(OSBase): name, status_code, check['expect']) ) status = self.FAIL + if status_code == 401 and name != 'placement': + self.osclient.clear_token() + logger.info( + "Received 401 authorization error. Resetting the token.") else: status = self.OK