-
Notifications
You must be signed in to change notification settings - Fork 95
job log retrieval: configurable success condition #7052
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
Open
oliver-sanders
wants to merge
2
commits into
cylc:master
Choose a base branch
from
oliver-sanders:job-log-retrieval.configurable-success-condition
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+177
−17
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Make the list of files used to determine the success of job log retrieval | ||
| commands configurable. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,6 +32,7 @@ | |
| INFO, | ||
| getLevelName, | ||
| ) | ||
| import logging | ||
| import os | ||
| from pathlib import Path | ||
| import shlex | ||
|
|
@@ -224,6 +225,7 @@ def log_task_job_activity( | |
| point: 'str | PointBase', | ||
| name: str, | ||
| submit_num: str | int | None = None, | ||
| level: int | None = None, | ||
| ): | ||
| """Log an activity for a task job.""" | ||
| ctx_str = str(ctx) | ||
|
|
@@ -241,9 +243,11 @@ def log_task_job_activity( | |
| # selection command causes a submission failure, or if a waiting task | ||
| # expires before a job log directory is otherwise needed. | ||
| # (Don't log the exception content, it looks like a bug). | ||
| LOG.info(ctx_str) | ||
| level = logging.INFO | ||
| if ctx.cmd and ctx.ret_code: | ||
| LOG.error(ctx_str) | ||
| level = logging.ERROR | ||
| if level is not None: | ||
| LOG.log(level, ctx_str) | ||
|
|
||
|
|
||
| class EventData(Enum): | ||
|
|
@@ -1184,6 +1188,15 @@ def _process_job_logs_retrieval( | |
| # get a host to run retrieval on | ||
| try: | ||
| platform = get_platform(ctx.platform_name) | ||
| except PlatformLookupError: | ||
| log_platform_event( | ||
| 'Unable to retrieve job logs.', | ||
| {'name': ctx.platform_name}, | ||
| level='warning', | ||
| ) | ||
| return | ||
|
|
||
| try: | ||
| host = get_host_from_platform(platform, bad_hosts=self.bad_hosts) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Split this (see the before part of the diff) |
||
| except NoHostsError: | ||
| # All of the platforms hosts have been found to be uncontactable. | ||
|
|
@@ -1202,13 +1215,6 @@ def _process_job_logs_retrieval( | |
| for id_key in id_keys: | ||
| self.unset_waiting_event_timer(id_key) | ||
| return | ||
| except PlatformLookupError: | ||
| log_platform_event( | ||
| 'Unable to retrieve job logs.', | ||
| {'name': ctx.platform_name}, | ||
| level='warning', | ||
| ) | ||
| return | ||
|
|
||
| # construct the retrieval command | ||
| ssh_str = str(platform["ssh command"]) | ||
|
|
@@ -1237,26 +1243,33 @@ def _process_job_logs_retrieval( | |
| # Local target | ||
| cmd.append(get_workflow_run_job_dir(schd.workflow) + "/") | ||
|
|
||
| expected_log_files = platform['retrieve job log expected files'] | ||
|
|
||
| # schedule command | ||
| self.proc_pool.put_command( | ||
| SubProcContext( | ||
| ctx, cmd, env=dict(os.environ), id_keys=id_keys, host=host | ||
| ), | ||
| bad_hosts=self.bad_hosts, | ||
| callback=self._job_logs_retrieval_callback, | ||
| callback_args=[schd], | ||
| callback_255=self._job_logs_retrieval_callback_255 | ||
| callback_args=[schd, expected_log_files], | ||
| callback_255=self._job_logs_retrieval_callback_255, | ||
| ) | ||
|
|
||
| def _job_logs_retrieval_callback_255(self, proc_ctx, schd) -> None: | ||
| def _job_logs_retrieval_callback_255(self, proc_ctx, *args) -> None: | ||
| """Call back when log job retrieval fails with a 255 error.""" | ||
| self.bad_hosts.add(proc_ctx.host) | ||
| for _ in proc_ctx.cmd_kwargs["id_keys"]: | ||
| for key in proc_ctx.cmd_kwargs['id_keys']: | ||
| timer = self._event_timers[key] | ||
| timer.reset() | ||
|
|
||
| def _job_logs_retrieval_callback(self, proc_ctx, schd) -> None: | ||
| def _job_logs_retrieval_callback( | ||
| self, | ||
| proc_ctx, | ||
| schd, | ||
| expected_log_files, | ||
| ) -> None: | ||
| """Call back when log job retrieval completes.""" | ||
| if ( | ||
| (proc_ctx.ret_code and LOG.isEnabledFor(DEBUG)) | ||
|
|
@@ -1271,6 +1284,7 @@ def _job_logs_retrieval_callback(self, proc_ctx, schd) -> None: | |
| with suppress(TypeError): | ||
| if id_key.event not in 'succeeded': | ||
| fnames.append(JOB_LOG_ERR) | ||
| fnames.extend(expected_log_files or []) | ||
| fname_oks = {} | ||
| for fname in fnames: | ||
| fname_oks[fname] = os.path.exists(get_task_job_log( | ||
|
|
@@ -1304,6 +1318,9 @@ def _job_logs_retrieval_callback(self, proc_ctx, schd) -> None: | |
| id_key.tokens['cycle'], | ||
| id_key.tokens['task'], | ||
| id_key.tokens['job'], | ||
| # ensure the list of remaining files to retrieve is logged | ||
| # for deubging | ||
| level=logging.DEBUG | ||
| ) | ||
| except KeyError as exc: | ||
| LOG.exception(exc) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ChrisPaulBennett
With this PR, the condition we use to determine whether job log retrieval has completed can also take into account these configured files. The
cylc cat-loglogic should also respect this.