Skip to content

Commit

Permalink
update common exceptions in manager (ansible#453)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex-Izquierdo committed Nov 15, 2023
1 parent c887cd7 commit 93e885c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/aap_eda/services/activation/engine/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ def start(self, request: ContainerRequest, logger: LogHandler) -> str:
try:
# Implementation
...
except SpeficicImagePullError as e:
raise exceptions.ContainerImagePullError(e) from e
except Exception as e:
raise exceptions.ContainerStartError(e) from e

Expand All @@ -123,8 +125,6 @@ def stop(self, container_id: str, logger: LogHandler) -> None:
try:
# Implementation
...
except SpeficicImagePullError as e:
raise exceptions.ContainerImagePullError(e) from e
except Exception as e:
raise exceptions.ContainerStopError(e) from e

Expand Down
8 changes: 4 additions & 4 deletions src/aap_eda/services/activation/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
from django.core.exceptions import ObjectDoesNotExist
from django.db import transaction
from django.db.utils import IntegrityError
from django.utils import timezone

from aap_eda.api.serializers.activation import is_activation_valid
from aap_eda.core import models
from aap_eda.core.enums import ActivationStatus
from aap_eda.services.activation import exceptions
from aap_eda.services.activation.engine import exceptions as engine_exceptions
from aap_eda.services.activation.engine.common import (
AnsibleRulebookCmdLine,
ContainerRequest,
Expand Down Expand Up @@ -240,10 +240,10 @@ def _start_activation_instance(self):
self.container_engine.update_logs(container_id, log_handler)

# note(alex): we may need to catch explicit exceptions
# ActivationImagePullError might need to be handled differently
# ContainerImagePullError might need to be handled differently
# because it can be an error network and we might want to retry
# so, activation should be in FAILED state to be handled by the monitor
except exceptions.ActivationException as exc:
except engine_exceptions.ContainerEngineError as exc:
msg = (
f"Activation {self.db_instance.id} failed to start. "
f"Reason: {exc}"
Expand Down Expand Up @@ -275,7 +275,7 @@ def _is_in_status(self, status: ActivationStatus) -> bool:
container_status = None
latest_instance = self.latest_instance

with contextlib.suppress(exceptions.ActivationPodNotFound):
with contextlib.suppress(engine_exceptions.ContainerNotFoundError):
container_status = self.container_engine.get_status(
container_id=latest_instance.activation_pod_id,
)
Expand Down

0 comments on commit 93e885c

Please sign in to comment.