Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch openstack auth issues #364

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,17 @@ def func_with_catch_errors(self: "GithubRunnerCharm", event: EventT) -> None:
except TokenError as err:
logger.exception("Issue with GitHub token")
self.unit.status = BlockedStatus(str(err))
except OpenStackUnauthorizedError:
logger.exception("Unauthorized OpenStack connection")
self.unit.status = BlockedStatus(
"Unauthorized OpenStack connection. Check credentials."
)
except MissingRunnerBinaryError:
logger.exception("Missing runner binary")
self.unit.status = MaintenanceStatus(
"GitHub runner application not downloaded; the charm will retry download on "
"reconcile interval"
)
except OpenStackUnauthorizedError:
logger.exception("Unauthorized OpenStack connection")
self.unit.status = BlockedStatus(
"Unauthorized OpenStack connection. Check credentials."
)
except MissingMongoDBError as err:
logger.exception("Missing integration data")
self.unit.status = WaitingStatus(str(err))
Expand Down
4 changes: 2 additions & 2 deletions src/openstack_cloud/openstack_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from openstack.network.v2.security_group import SecurityGroup as OpenstackSecurityGroup
from paramiko.ssh_exception import NoValidConnectionsError

from errors import KeyfileError, OpenStackError, SSHError
from errors import KeyfileError, OpenStackError, OpenStackUnauthorizedError, SSHError
from utilities import retry

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -120,7 +120,7 @@ def _get_openstack_connection(
# pylint thinks this isn't an exception, but does inherit from Exception class.
except openstack.exceptions.HttpException as exc: # pylint: disable=bad-exception-cause
logger.exception("OpenStack API call failure")
raise OpenStackError("Failed OpenStack API call") from exc
raise OpenStackUnauthorizedError("Failed OpenStack API call") from exc


class OpenstackCloud:
Expand Down
Loading