Skip to content

Commit cf9833a

Browse files
brettmthompsondbasunag
authored andcommitted
now yielding TimeoutSampler get_pods_by_isvc_label func output and handling raised ResourceNotFoundError (opendatahub-io#237)
Signed-off-by: Brett Thompson <196701379+brettmthompson@users.noreply.github.com>
1 parent 737b07e commit cf9833a

File tree

1 file changed

+10
-5
lines changed
  • tests/model_serving/model_server/serverless

1 file changed

+10
-5
lines changed

tests/model_serving/model_server/serverless/utils.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
from typing import Any
22

33
from kubernetes.dynamic import DynamicClient
4+
from kubernetes.dynamic.exceptions import ResourceNotFoundError
45
from ocp_resources.inference_service import InferenceService
6+
from ocp_resources.utils.constants import DEFAULT_CLUSTER_RETRY_EXCEPTIONS
57
from simple_logger.logger import get_logger
68
from timeout_sampler import TimeoutSampler
79
from timeout_sampler import TimeoutExpiredError
@@ -30,17 +32,20 @@ def verify_no_inference_pods(client: DynamicClient, isvc: InferenceService) -> N
3032
pods = []
3133

3234
try:
33-
pods = TimeoutSampler(
35+
for pods in TimeoutSampler(
3436
wait_timeout=Timeout.TIMEOUT_4MIN,
3537
sleep=5,
38+
exceptions_dict=DEFAULT_CLUSTER_RETRY_EXCEPTIONS,
3639
func=get_pods_by_isvc_label,
3740
client=client,
3841
isvc=isvc,
39-
)
40-
if not pods:
41-
return
42+
):
43+
if not pods:
44+
return
4245

43-
except TimeoutError:
46+
except TimeoutExpiredError as e:
47+
if isinstance(e.last_exp, ResourceNotFoundError):
48+
return
4449
LOGGER.error(f"{[pod.name for pod in pods]} were not deleted")
4550
raise
4651

0 commit comments

Comments
 (0)