Skip to content

Commit

Permalink
WIP: catch token revoke failures
Browse files Browse the repository at this point in the history
  • Loading branch information
andreaso committed Mar 31, 2024
1 parent 23a12fe commit 9ae457d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions vault_oidc_ssh_cert_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ def _set_error_message(title: str, message: str) -> None:
print(f"::error title={title}::{message}")


def _set_warning_message(title: str, message: str) -> None:
print(f"::warning title={title}::{message}")


def _determine_audience(input_audience: str, vault_server: str) -> str:
if input_audience:
return input_audience
Expand Down Expand Up @@ -138,5 +142,10 @@ def revoke_token() -> None:
revoke_url = f"{vault_server}/v1/auth/token/revoke-self"
headers = {"X-Vault-Token": vault_token}

response = requests.post(revoke_url, headers=headers, timeout=10)
response.raise_for_status()
try:
response = requests.post(revoke_url, headers=headers, timeout=10)
response.raise_for_status()
except requests.exceptions.RequestException as request_error:
title = "Vault token revoke failure"
message = f"{type(request_error).__name__}: {str(request_error)}"
_set_warning_message(title, message)

0 comments on commit 9ae457d

Please sign in to comment.