Skip to content

Commit

Permalink
Feat: Make exception raised by external command authenticator more ac…
Browse files Browse the repository at this point in the history
…tionable (flyteorg#2594)

Signed-off-by: Fabio Grätz <fabiogratz@googlemail.com>
Co-authored-by: Fabio Grätz <fabiogratz@googlemail.com>
  • Loading branch information
2 people authored and Mecoli1219 committed Jul 27, 2024
1 parent ad42af6 commit 928c951
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions flytekit/clients/auth/authenticator.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,15 @@ def refresh_credentials(self):
This function is used when the configuration value for AUTH_MODE is set to 'external_process'.
It reads an id token generated by an external process started by running the 'command'.
"""
logging.debug("Starting external process to generate id token. Command {}".format(self._cmd))
cmd_joined = " ".join(self._cmd)
logging.debug("Starting external process to generate id token. Command `{}`".format(" ".join(cmd_joined)))
try:
output = subprocess.run(self._cmd, capture_output=True, text=True, check=True)
except subprocess.CalledProcessError as e:
logging.error("Failed to generate token from command {}".format(self._cmd))
raise AuthenticationError("Problems refreshing token with command: " + str(e))
except subprocess.CalledProcessError:
logging.error("Failed to generate token from command `{}`".format(cmd_joined))
raise AuthenticationError(
f"Failed to refresh token with command `{cmd_joined}`. Please execute this command in your terminal to debug."
)
self._creds = Credentials(output.stdout.strip())


Expand Down

0 comments on commit 928c951

Please sign in to comment.