Skip to content

Commit

Permalink
fix(deployments): fix deployment wait command
Browse files Browse the repository at this point in the history
  • Loading branch information
smrutisenapati authored and pallabpain committed Sep 4, 2024
1 parent 64bc9e3 commit e0ef5ed
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 deletions.
1 change: 1 addition & 0 deletions riocli/deployment/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from munch import unmunchify
from rapyuta_io import Client
from rapyuta_io.clients.catalog_client import Package
from rapyuta_io.clients.deployment import DeploymentNotRunningException
from rapyuta_io.clients.package import ProvisionConfiguration, RestartPolicy
from rapyuta_io.clients.rosbag import (OverrideOptions, ROSBagCompression, ROSBagJob, ROSBagOnDemandUploadOptions,
ROSBagOptions, ROSBagTimeRange, ROSBagUploadTypes, TopicOverrideInfo,
Expand Down
8 changes: 6 additions & 2 deletions riocli/deployment/wait.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from riocli.config import new_v2_client
from riocli.constants import Colors, Symbols
from riocli.utils.spinner import with_spinner
from riocli.v2client.error import RetriesExhausted, DeploymentNotRunning
from riocli.v2client.error import RetriesExhausted, DeploymentNotRunning, ImagePullError


@click.command(
Expand All @@ -38,7 +38,7 @@ def wait_for_deployment(
try:
client = new_v2_client()
deployment = client.poll_deployment(deployment_name)
spinner.text = click.style('Deployment status: {}'.format(deployment.status.status), fg=Colors.GREEN)
spinner.text = click.style('Phase: Succeeded Status: {}'.format(deployment.status.status), fg=Colors.GREEN)
spinner.green.ok(Symbols.SUCCESS)
except RetriesExhausted as e:
spinner.write(click.style(str(e), fg=Colors.RED))
Expand All @@ -48,6 +48,10 @@ def wait_for_deployment(
spinner.text = click.style(str(e), fg=Colors.RED)
spinner.red.fail(Symbols.ERROR)
raise SystemExit(1)
except ImagePullError as e:
spinner.text = click.style(str(e), fg=Colors.RED)
spinner.red.fail(Symbols.ERROR)
raise SystemExit(1)
except Exception as e:
spinner.text = click.style(str(e), fg=Colors.RED)
spinner.red.fail(Symbols.ERROR)
Expand Down
2 changes: 2 additions & 0 deletions riocli/network/delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from rapyuta_io import Client
from riocli.network.model import Network


@click.command(
'delete',
cls=HelpColorsCommand,
Expand Down Expand Up @@ -112,6 +113,7 @@ def delete_network(
spinner.red.fail(Symbols.ERROR)
raise SystemExit(1) from e


def _apply_delete(client: Client, result: Queue, network: Network) -> None:
try:
client.delete_network(network_name=network.metadata.name)
Expand Down
12 changes: 5 additions & 7 deletions riocli/v2client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from rapyuta_io.utils.rest_client import HttpMethod, RestClient

from riocli.v2client.enums import DeploymentPhaseConstants
from riocli.v2client.error import RetriesExhausted, DeploymentNotRunning
from riocli.v2client.error import RetriesExhausted, DeploymentNotRunning, ImagePullError


class DeploymentNotFound(Exception):
Expand Down Expand Up @@ -1048,15 +1048,13 @@ def poll_deployment(
return deployment

if status.phase == DeploymentPhaseConstants.DeploymentPhaseProvisioning.value:
errors = status.error_codes or []
errors = status.get('error_codes', [])
if 'DEP_E153' in errors: # DEP_E153 (image-pull error) will persist across retries
return deployment
raise ImagePullError('Deployment not running. Phase: Provisioning Status: {}'.format(status.phase))
elif status.phase == DeploymentPhaseConstants.DeploymentPhaseSucceeded.value:
return deployment
elif status.phase in [DeploymentPhaseConstants.DeploymentPhaseFailedToUpdate.value,
DeploymentPhaseConstants.DeploymentPhaseFailedToStart.value,
DeploymentPhaseConstants.DeploymentPhaseStopped.value]:
raise DeploymentNotRunning('Deployment not running. Deployment status: {}'.format(status.phase))
elif status.phase == DeploymentPhaseConstants.DeploymentPhaseStopped.value:
raise DeploymentNotRunning('Deployment not running. Phase: Stopped Status: {}'.format(status.phase))

time.sleep(sleep_interval)
deployment = self.get_deployment(name)
Expand Down
4 changes: 4 additions & 0 deletions riocli/v2client/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,9 @@ def __init__(self, msg=None):


class DeploymentNotRunning(Exception):
def __init__(self, msg=None):
Exception.__init__(self, msg)

class ImagePullError(Exception):
def __init__(self, msg=None):
Exception.__init__(self, msg)

0 comments on commit e0ef5ed

Please sign in to comment.