Skip to content

Commit

Permalink
Added retry in case of ResourceNotFoundError to collect_pod_container…
Browse files Browse the repository at this point in the history
…_rpm_package method

Signed-off-by: Amrita Mahapatra <[email protected]>
  • Loading branch information
amr1ta committed Oct 7, 2024
1 parent 492a4af commit 1cfa5e4
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion ocs_ci/ocs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@
get_submariner_operator_version,
get_volsync_operator_version,
)

from ocs_ci.ocs.exceptions import (
ResourceNotFoundError,
)
from ocs_ci.ocs.resources.pod import wait_for_pods_to_be_running

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -1778,6 +1781,13 @@ def collect_pod_container_rpm_package(dir_name):
ocp_obj = OCP(namespace=cluster_namespace)
for pod_obj in pods:
pod_object = pod_obj.get()
# avoid resource not found error when pod got respinned inbetween
retry(ResourceNotFoundError, tries=2, delay=2, backoff=2)(
wait_for_pods_to_be_running
)(
pods=pod.get_all_pods(namespace=cluster_namespace),
raise_pod_not_found_error=True,
)
pod_containers = pod_object.get("spec").get("containers")
ocp_pod_obj = OCP(kind=constants.POD, namespace=cluster_namespace)
pod_status = ocp_pod_obj.get_resource_status(pod_obj.name)
Expand Down

0 comments on commit 1cfa5e4

Please sign in to comment.