Skip to content

Commit

Permalink
Abandoning in case of server auth errors
Browse files Browse the repository at this point in the history
Details:

* When the HMC userid cannot log on to the HMC because the password is invalid
  or expired, or because the maximum number of sessions has been reached, the
  exporter no longer retries the logon but abandons. The previous retrying has
  lead to disabling the userid after some unsuccessful retries. (issue #493)

Signed-off-by: Andreas Maier <[email protected]>
  • Loading branch information
andy-maier committed Apr 2, 2024
1 parent 32b28d5 commit ad77792
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
5 changes: 5 additions & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ will also work with the prior version of the file (but not vice versa).
* The safety run for all dependencies now must succeed when the test workflow
is run for a release (i.e. branch name 'release_...').

* When the HMC userid cannot log on to the HMC because the password is invalid
or expired, or because the maximum number of sessions has been reached, the
exporter no longer retries the logon but abandons. The previous retrying has
lead to disabling the userid after some unsuccessful retries. (issue #493)

**Cleanup:**

* Increased versions of GitHub Actions plugins to increase node.js runtime
Expand Down
18 changes: 11 additions & 7 deletions zhmc_prometheus_exporter/zhmc_prometheus_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1687,6 +1687,13 @@ def collect(self):
try:
metrics_object = retrieve_metrics(self.context)
except zhmcclient.HTTPError as exc:
if exc.http_status == 400 and exc.reason in (13, 45):
# 400.13: Logon: Max sessions reached for user
# 400.45: Logon: Password expired
logprint(logging.ERROR, PRINT_ALWAYS,
"Abandoning after HTTP status {}.{}: {}".
format(exc.http_status, exc.reason, exc))
raise
if exc.http_status == 404 and exc.reason == 1:
logprint(logging.WARNING, PRINT_ALWAYS,
"Recreating the metrics context after HTTP "
Expand All @@ -1708,13 +1715,10 @@ def collect(self):
time.sleep(RETRY_SLEEP_TIME)
continue
except zhmcclient.ServerAuthError as exc:
http_exc = exc.details # zhmcclient.HTTPError
logprint(logging.WARNING, PRINT_ALWAYS,
"Retrying after server authentication error with "
"HTTP status {}.{}".
format(http_exc.http_status, http_exc.reason))
time.sleep(RETRY_SLEEP_TIME)
continue
logprint(logging.ERROR, PRINT_ALWAYS,
"Abandoning after server authentication error: {}".
format(exc))
raise
except zhmcclient.ClientAuthError as exc:
logprint(logging.ERROR, PRINT_ALWAYS,
"Abandoning after client authentication error: {}".
Expand Down

0 comments on commit ad77792

Please sign in to comment.