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

Misc fixes #5741

Merged
merged 2 commits into from
Aug 1, 2023
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
21 changes: 16 additions & 5 deletions avocado/core/task/statemachine.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,24 @@ def __repr__(self):
)

async def _send_finished_tasks_message(self, terminate_tasks, reason):
"""Sends messages related to timeout to status repository.
When the task is terminated, it is necessary to send a finish message to status
repository to close logging. This method will send log message with timeout
information and finish message with right fail reason.
"""Sends messages related to tasks being terminated to status repository.

:param terminate_tasks: runtime_tasks which were terminated
On normal conditions, the "avocado-runner-*" will produce messages
finishing each task. But, under some conditions (such as timeouts,
interruptions requested by users, etc), it's necessary to do this on
the runner's behalf.

When a task is terminated, it is necessary to send a "finish" message
with the correct fail reason to the status repository, which will close
logging. This method will also send a "log" message with the reason
(timeout, user interruption, etc).

:param terminate_tasks: runtime_tasks which were terminated and need
to have messages sent on their behalf
:type terminate_tasks: list
:param reason: a description of what caused the task interruption (timeout, user
requested interruption, etc).
:type reason: str
"""
for terminated_task in terminate_tasks:
task_id = str(terminated_task.task.identifier)
Expand Down
6 changes: 3 additions & 3 deletions avocado/utils/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def safe_kill(pid, signal): # pylint: disable=W0621
:param signal: Signal number.
"""
if get_owner_id(int(pid)) == 0:
kill_cmd = f"kill -{int(int(signal))} {int(int(pid))}"
kill_cmd = f"kill -{int(signal)} {int(pid)}"
try:
run(kill_cmd, sudo=True)
return True
Expand Down Expand Up @@ -304,7 +304,7 @@ def process_in_ptree_is_defunct(ppid):
except CmdError: # Process doesn't exist
return True
for pid in pids:
cmd = f"ps --no-headers -o cmd {int(int(pid))}"
cmd = f"ps --no-headers -o cmd {int(pid)}"
proc_name = system_output(cmd, ignore_status=True, verbose=False)
if "<defunct>" in proc_name:
defunct = True
Expand Down Expand Up @@ -795,7 +795,7 @@ def send_signal(self, sig):
pids = get_children_pids(self.get_pid())
pids.append(self.get_pid())
for pid in pids:
kill_cmd = f"kill -{int(int(sig))} {int(pid)}"
kill_cmd = f"kill -{int(sig)} {int(pid)}"
with contextlib.suppress(Exception):
run(kill_cmd, sudo=True)
else:
Expand Down
Loading