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

App exit code fix #95

Merged
merged 2 commits into from
Dec 5, 2024
Merged
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
15 changes: 9 additions & 6 deletions agent/worker/task_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ def main_step(self):

logs_cnt = self.process_logs()
if logs_cnt == 0:
self.logger.warn("No logs received from the container")# check if bug occurred
self.logger.warn("No logs received from the container") # check if bug occurred

self.drop_container_and_check_status()
except:
Expand Down Expand Up @@ -834,8 +834,7 @@ def _decode(bytes: bytes):
for log_part in _decode(log_line_arr).splitlines():
yield log_part


def process_logs(self, logs_arr = None):
def process_logs(self, logs_arr=None):
result_logs = logs_arr
logs_cnt = 0

Expand Down Expand Up @@ -865,7 +864,6 @@ def process_logs(self, logs_arr = None):

return logs_cnt


def _stop_wait_container(self):
if self.is_isolate():
return super()._stop_wait_container()
Expand All @@ -880,6 +878,11 @@ def exec_stop(self):
else:
return

def get_exit_status(self):
exec_info = self._docker_api.api.exec_inspect(self._exec_id)
exit_code = exec_info["ExitCode"]
return exit_code

def _drop_container(self):
if self.is_isolate():
super()._drop_container()
Expand All @@ -888,7 +891,7 @@ def _drop_container(self):

def drop_container_and_check_status(self):
self._container.reload()
status = self._container.attrs["State"]["ExitCode"]
status = self.get_exit_status()

if self.is_isolate():
self._drop_container()
Expand All @@ -902,7 +905,7 @@ def drop_container_and_check_status(self):
self.logger.debug("Founded error report.", extra=last_report)

instance_type = self.info.get("instance_type", "")
timeout = self.info.get("activeDeadlineSeconds", None)
timeout = self.info.get("activeDeadlineSeconds", 0)
if timeout > 0 and (status == 124 or status == 137):
msg = f"Task deadline exceeded. This task is only allowed to run for {timeout} seconds."
if instance_type == "community":
Expand Down
Loading