Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ocp_resources/benchmark.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ocp_resources.constants import NOT_FOUND_ERROR_EXCEPTION_DICT
from ocp_resources.constants import NOT_FOUND_ERROR_EXCEPTION_DICT, TIMEOUT_30SEC
from ocp_resources.resource import NamespacedResource
from timeout_sampler import TimeoutSampler

Expand Down Expand Up @@ -35,7 +35,7 @@ def _wait_for_instance_key(self, parent, key):
str or None: Value of key if found, otherwise None
"""
samples = TimeoutSampler(
wait_timeout=30,
wait_timeout=TIMEOUT_30SEC,
sleep=1,
func=lambda: getattr(self.instance, parent, None),
exceptions_dict=NOT_FOUND_ERROR_EXCEPTION_DICT,
Expand Down
2 changes: 2 additions & 0 deletions ocp_resources/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
PROTOCOL_ERROR_EXCEPTION_DICT: Dict[type[Exception], List[str]] = {ProtocolError: []}
NOT_FOUND_ERROR_EXCEPTION_DICT: Dict[type[Exception], List[str]] = {NotFoundError: []}

TIMEOUT_5SEC: int = 5
TIMEOUT_10SEC: int = 10
TIMEOUT_30SEC: int = 30
TIMEOUT_1MINUTE: int = 60
TIMEOUT_2MINUTES: int = 2 * 60
TIMEOUT_4MINUTES: int = 4 * 60
Expand Down
6 changes: 3 additions & 3 deletions ocp_resources/pod.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import kubernetes

from ocp_resources.constants import TIMEOUT_4MINUTES
from ocp_resources.constants import TIMEOUT_4MINUTES, TIMEOUT_5SEC
from ocp_resources.node import Node
from ocp_resources.resource import NamespacedResource
from timeout_sampler import TimeoutWatch
Expand Down Expand Up @@ -111,8 +111,8 @@ def execute(self, command, timeout=60, container=None, ignore_rc=False):
if rcstring is None:
raise ExecOnPodError(command=command, rc=-1, out="", err=stream_closed_error)

stdout = resp.read_stdout(timeout=5)
stderr = resp.read_stderr(timeout=5)
stdout = resp.read_stdout(timeout=TIMEOUT_5SEC)
stderr = resp.read_stderr(timeout=TIMEOUT_5SEC)

if rcstring == "Success" or ignore_rc:
return stdout
Expand Down
16 changes: 12 additions & 4 deletions ocp_resources/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
TIMEOUT_1MINUTE,
TIMEOUT_4MINUTES,
TIMEOUT_10SEC,
TIMEOUT_30SEC,
TIMEOUT_5SEC,
)
from ocp_resources.event import Event
from timeout_sampler import (
Expand Down Expand Up @@ -876,12 +878,16 @@ def update_replace(self, resource_dict: Dict[str, Any]) -> None:

@staticmethod
def retry_cluster_exceptions(
func, exceptions_dict: Dict[type[Exception], List[str]] = DEFAULT_CLUSTER_RETRY_EXCEPTIONS, **kwargs: Any
func,
exceptions_dict: Dict[type[Exception], List[str]] = DEFAULT_CLUSTER_RETRY_EXCEPTIONS,
timeout: int = TIMEOUT_10SEC,
sleep_time: int = 1,
**kwargs: Any,
) -> Any:
try:
sampler = TimeoutSampler(
wait_timeout=TIMEOUT_10SEC,
sleep=1,
wait_timeout=timeout,
sleep=sleep_time,
func=func,
print_log=False,
exceptions_dict=exceptions_dict,
Expand Down Expand Up @@ -1050,7 +1056,7 @@ def api_request(self, method: str, action: str, url: str, **params: Any) -> Dict
def wait_for_conditions(self) -> None:
timeout_watcher = TimeoutWatch(timeout=30)
for sample in TimeoutSampler(
wait_timeout=30,
wait_timeout=TIMEOUT_30SEC,
sleep=1,
func=lambda: self.exists,
):
Expand Down Expand Up @@ -1539,4 +1545,6 @@ def _apply_patches_sampler(self, patches: Dict[Any, Any], action_text: str, acti
patches=patches,
action_text=action_text,
action=action,
timeout=TIMEOUT_30SEC,
sleep_time=TIMEOUT_5SEC,
)