Repository navigation
qa/workunit: register WatchedProcess to fail fast - #71030
Conversation
perezjosibm
left a comment
There was a problem hiding this comment.
LGTM, just some minor comments but I am not sure if apply, thanks
| if watchdog: | ||
| watched = WorkunitProcess(remote, role, workunit, | ||
| workunit_path) | ||
| ctx.ceph[cluster].watched_processes.append(watched) |
There was a problem hiding this comment.
I was wondering whether this list always exists, or we need to check it does?
There was a problem hiding this comment.
It always exists in watchdog implementation, please see:
ceph/qa/tasks/daemonwatchdog.py
Line 63 in 1c21110
| for line in self._remote.sh('ps -eo sess=,args=', quiet=True).splitlines(): | ||
| sess, _, args = line.strip().partition(' ') | ||
| if self._pattern in args and sess.isdigit() and sess != '0': | ||
| return sess |
There was a problem hiding this comment.
I'm guessing the PID of the process to be watched is saved somewhere else
| return | ||
| self._remote.run( | ||
| args=['sudo', 'pkill', '-KILL', '-s', sess], | ||
| check_status=False, |
There was a problem hiding this comment.
Stupid question: by killing the session do we always ensure we kill the underlying (remote) process PID? Unless the watchdog is the one that kills the (remote) PID 🤔
There was a problem hiding this comment.
Simply killing the script by PID is unfortunately not enough in this case, here is the full explanation: #71030 (comment)
| label="workunit test {workunit}".format(workunit=workunit) | ||
| ) | ||
| except Exception: | ||
| if watched is not None and watched.exception: |
There was a problem hiding this comment.
If I am understanding correctly, a test failure has precedence over a watchdog bark, right?
There was a problem hiding this comment.
We do not stop the workunit on a test failure. The test should keep on executing even if a test fails. The only case were we would want to stop is if a daemon aborts. In this case, continuing to run the tests is useless as the cluster itself is now broken.
| def _session(self): | ||
| """ | ||
| The session the workunit's ssh command runs in, or None if it has | ||
| already gone. This is needed to terminate the process session if | ||
| the watchdog barks. | ||
| """ | ||
| for line in self._remote.sh('ps -eo sess=,args=', quiet=True).splitlines(): | ||
| sess, _, args = line.strip().partition(' ') | ||
| if self._pattern in args and sess.isdigit() and sess != '0': | ||
| return sess | ||
| return None | ||
|
|
||
| def stop(self): | ||
| log.debug('Stopping %s: %s', self._name, self._exception) | ||
| sess = self._session() | ||
| if sess is None: | ||
| log.debug('%s has already gone', self._name) | ||
| return | ||
| self._remote.run( | ||
| args=['sudo', 'pkill', '-KILL', '-s', sess], | ||
| check_status=False, | ||
| ) |
There was a problem hiding this comment.
To stop execution, simply killing the script was not sufficient here due to the child processes being spawned by workunit, which inherit its stdout and stderr. The way to get around it, is by killing the process group. That is also not sufficient here as timeout(1) calls setpgid() which leaves the test binary in a group of its own. I verified this on a run:
PID PPID PGID SID STAT ARGS
37515 28778 37515 37515 Ss timeout 3h .../rados/test.sh --crimson
37542 37515 37515 37515 S bash .../rados/test.sh --crimson
37546 37542 37546 37515 S timeout 5400 ceph_test_rados_api_aio
37547 37546 37546 37515 Sl ceph_test_rados_api_aio
Session ID is common across the script and all its child processes and hence that is what is used to stop the script (and the child processes) in the event of a failure.
NitzanMordhai
left a comment
There was a problem hiding this comment.
@shraddhaag looks good! Just 1 note that I added that I think we should add before merging
| subdir=config.get('subdir'), | ||
| timeout=timeout, | ||
| cleanup=cleanup, | ||
| watchdog=watchdog, |
There was a problem hiding this comment.
i think that we also handle the client: all options. With the current changes, we will not send any watchdog to the client all option
There was a problem hiding this comment.
ah yes, I've taken care of that! Thanks Nitzan :)
6c8cfb3 to
bb08408
Compare
Before this commit, workunit did not implement WatchedProcess. If a daemon fails and watchdog barks, the workunit would still keep running against a broken cluster. This lead to long running jobs, which ideally should have been terminated as soon as the watchdog barked. This commit registers Workunit as a WatchedProcess. This is beneficial for the following reasons: 1. Watchdog can kill the registered workunit once it barks, thus failing fast incase of a failure. 2. The actual reason for the failure can be surfaced from within the workunit instead of an ambiguous failure reason. By default, all workunits have wactchdog disabled. This can be enabled by setting watchdog:true (and for cephadm: watchdog_setup:true). Signed-off-by: Shraddha Agrawal <[email protected]>
This commit enables watchdog in the workunit that runs rados_api_tests in the crimson-rados teuthology test suite. This is done such that if an OSD aborts and doesn't recover within the watchdog confirgured timeout (here: 300s), we can abort the test at that point, instead of continuing to run the rados_api_tests with their 5400s timeout per test. In case the tests fail and a daemon aborts, the tests now complete within 30 mins instead of running for 3 hours. Signed-off-by: Shraddha Agrawal <[email protected]>
bb08408 to
1d38a2c
Compare
|
This is an automated message by src/script/redmine-upkeep.py. I have resolved the following tracker ticket due to the merge of this PR: No backports are pending for the ticket. If this is incorrect, please update the tracker |
This commit enables the workunit's watchdog introduced in #71030 in all workunit tasks in crimson-raods suite. This will help these tasks fail fast in the event of a failure, instead of running for long hours, hogging resources. Signed-off-by: Shraddha Agrawal <[email protected]>
This commit enables the workunit's watchdog introduced in ceph#71030 in all workunit tasks in crimson-raods suite. This will help these tasks fail fast in the event of a failure, instead of running for long hours, hogging resources. Signed-off-by: Shraddha Agrawal <[email protected]>
This commit enables the workunit's watchdog introduced in ceph#71030 in all workunit tasks in crimson-raods suite. This will help these tasks fail fast in the event of a failure, instead of running for long hours, hogging resources. Signed-off-by: Shraddha Agrawal <[email protected]>
This commit enables the workunit's watchdog introduced in ceph#71030 in all workunit tasks in crimson-raods suite. This will help these tasks fail fast in the event of a failure, instead of running for long hours, hogging resources. Signed-off-by: Shraddha Agrawal <[email protected]>
Issue
Teuthology jobs that are implemented as a workunit keep running even after encountering a daemon failure for a long time (~ 3 hours per job). This is both time and resource intensive unnecessarily.
Solution
This PR registers a
Workunitas aWatchedProcess. This is beneficial for the following reasons:By default, all workunits have wactchdog disabled. This can be enabled by doing the following:
For cephadm tasks:
Scope
This PR enables the above setting for
rados_api_tests.yamlincrimson-radossuite. The above instrumentation can be used to enable this behaviour in all workunits spanning across different suites.Time Saved
Timing per job:
Fixes: https://tracker.ceph.com/issues/79644
Checklist
Show available Jenkins commands
jenkins test classic perfJenkins Job | Jenkins Job Definitionjenkins test crimson perfJenkins Job | Jenkins Job Definitionjenkins test signedJenkins Job | Jenkins Job Definitionjenkins test make checkJenkins Job | Jenkins Job Definitionjenkins test make check arm64Jenkins Job | Jenkins Job Definitionjenkins test submodulesJenkins Job | Jenkins Job Definitionjenkins test dashboardJenkins Job | Jenkins Job Definitionjenkins test dashboard cephadmJenkins Job | Jenkins Job Definitionjenkins test apiJenkins Job | Jenkins Job Definitionjenkins test docsReadTheDocs | Github Workflow Definitionjenkins test ceph-volume allJenkins Jobs | Jenkins Jobs Definitionjenkins test windowsJenkins Job | Jenkins Job Definitionjenkins test rook e2eJenkins Job | Jenkins Job DefinitionYou must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.