Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PR #3924/27d66481 backport][3.29] Taught monitor_task_group fixture to respond better to fatal errors. #4172

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES/3923.misc
@@ -0,0 +1 @@
Fixed possible infinite-wait in monitor_task_group fixture.
10 changes: 9 additions & 1 deletion pulpcore/tests/functional/__init__.py
Expand Up @@ -818,12 +818,20 @@ def _monitor_task(task_href):
@pytest.fixture(scope="session")
def monitor_task_group(task_groups_api_client):
def _monitor_task_group(task_group_href):
def tasks_open(tg):
return (tg.waiting + tg.running + tg.canceling) > 0

task_group = task_groups_api_client.read(task_group_href)

while not task_group.all_tasks_dispatched or (task_group.waiting + task_group.running) > 0:
# Wait until there are no tasks left to run
# Note: if the *tasking system* has a bug that leaves a task (somehow)
# in run/wait/canceling, we're going to be stuck in this loop forever.
# I don't see a reliable way to avoid that. TaskingSystemBugs: Just Say No! :)
while tasks_open(task_group):
sleep(SLEEP_TIME)
task_group = task_groups_api_client.read(task_group_href)

# If ANYTHING went wrong, throw an error
if (task_group.failed + task_group.skipped + task_group.canceled) > 0:
raise PulpTaskGroupError(task_group=task_group)

Expand Down