Skip to content

Commit d0e5b36

Browse files
committed
Add missing timeout when calling entity with timeout (#1311)
I found this issue while working on a Robottelo upgrade scenario refactor. I found that a test syncing the RHEL 7 server RPMs repo was consistently timing out after 300 seconds, though the `enable_sync_redhat_repo` API factory method uses a timeout of 1500 seconds by default. Eventually, I found that `nailgun.entity_mixins.call_entity_with_timeout()` was invoking the entity callable without specifically passing the timeout. After the repo sync was initiated, `nailgun.entity_mixins._poll_task()` was being called with no timeout value specified, causing the `timeout` variable to be set to the `TASK_TIMEOUT` constant defined in the entity_mixins module, which has a value of 300 seconds. My repo sync was completing in ~360 seconds, so the test was consistently failing. This PR adds a `timeout` keyword argument to the `entity_callable()` in `call_entity_with_timeout()` and, in the repository `sync()` entity method, changes the `timeout` argument in the call to `_handle_response()` from a keywork argument to a positional argument.
1 parent 8d1e003 commit d0e5b36

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

nailgun/entities.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6265,7 +6265,7 @@ def sync(self, synchronous=True, timeout=None, **kwargs):
62656265
kwargs = kwargs.copy() # shadow the passed-in kwargs
62666266
kwargs.update(self._server_config.get_client_kwargs())
62676267
response = client.post(self.path('sync'), **kwargs)
6268-
return _handle_response(response, self._server_config, synchronous, timeout)
6268+
return _handle_response(response, self._server_config, synchronous, timeout=timeout)
62696269

62706270

62716271
class ProductBulkAction(Entity):

nailgun/entity_mixins.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def call_entity_method_with_timeout(entity_callable, timeout=300, **kwargs):
7373
original_task_timeout = TASK_TIMEOUT
7474
TASK_TIMEOUT = timeout
7575
try:
76-
entity_callable(**kwargs)
76+
entity_callable(timeout=timeout, **kwargs)
7777
finally:
7878
TASK_TIMEOUT = original_task_timeout
7979

0 commit comments

Comments
 (0)