Skip to content

Allow raising a custom exception when stop_status is reached within wait_for_status #2512

@sheltoncyril

Description

@sheltoncyril

Is your feature request related to a problem? Please describe.
Pod.wait_for_status raises a TimeoutExpiredException when the stop_status is reached. This is not differentiated from reaching the end of the timeout.

Describe the solution you'd like
There are two ways to solve this IMO, one is to define a new exception which is raised when this state is reached eg. StopStatusReachedException
OR
Allow the user to specify what exception is thrown when the stop status is reached

pod.wait_for_status(Pod.Status.SUCCEEDED, timeout=10, stop_status=Pod.Status.FAILED(I know this is default), sleep=1, stop_status_exc=PodFailedException)

Describe alternatives you've considered
My current solution is to try except the wait_for_status to handle the TimeoutExpiredException during pod failure but it cannot be differentiated from when the timeout is actually reached.

Additional context
Add any other context or screenshots about the feature request here.
One of my implementations of this https://github.com/opendatahub-io/opendatahub-tests/pull/532/files#diff-a85e4ce9f4e7c1f5f284567ab65433b8ed9cc19bf07740e7fb037895f4359a8bR104-R107

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions