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

setup-grest: Improve cleanup of cron scripts and running jobs #1699

Merged
merged 1 commit into from
Nov 2, 2023

Conversation

rdlrt
Copy link
Contributor

@rdlrt rdlrt commented Nov 2, 2023

Description

Currently, setup-grest.sh relies on removing individual files and kill corresponding cron job processes. This can lead to multiple scenarios where old (retired) cron jobs may not be cleaned up, as well as relies on assumptions on nomen clature of running processes (which as seen in #1666 is not always true)

  • Remove all cron jobs for given CRON_SCRIPTS_DIR from /etc/cron.d, as well as empty the CRON_SCRIPTS_DIR itself
  • Use PG_CANCEL_BACKEND and PG_TERMINATE_BACKEND psql calls to terminate all jobs run using installer user as psql session (it is a bit aggressive, but does not break any non-psql sessions like an admin client or dbsync - cron jobs always run as psql commands, the only other psql references on gRest nodes should be get-metrics script, which should anyways have a hiccup when removing all gRest functions), rather than having to maintain a list. This is only triggered when using -q or -r flags.

Which issue it fixes?

Closes #1666

How has this been tested?

Tested in-place update on guildnet node

@rdlrt rdlrt requested a review from Scitz0 November 2, 2023 05:30
@rdlrt rdlrt merged commit 332fd7b into alpha Nov 2, 2023
1 check passed
@rdlrt rdlrt deleted the setup-grest branch November 2, 2023 05:36
rdlrt added a commit that referenced this pull request Nov 3, 2023
## Description
<!--- Describe your changes -->
Currently, setup-grest.sh relies on removing individual files and kill
corresponding cron job processes. This can lead to multiple scenarios
where old (retired) cron jobs may not be cleaned up, as well as relies
on assumptions on nomen clature of running processes (which as seen in
#1666 is not always true)

- [x] Remove all cron jobs for given `CRON_SCRIPTS_DIR` from
/etc/cron.d, as well as empty the `CRON_SCRIPTS_DIR` itself
- [x] Use PG_CANCEL_BACKEND and PG_TERMINATE_BACKEND psql calls to
terminate all jobs run using installer user as `psql` session (it is a
bit aggressive, but does not break any non-psql sessions like an admin
client or dbsync - cron jobs always run as psql commands, the only other
psql references on gRest nodes should be get-metrics script, which
should anyways have a hiccup when removing all gRest functions), rather
than having to maintain a list. This is only triggered when using `-q`
or `-r` flags.

## Which issue it fixes?
<!--- Link to issue: Closes #issue-number -->
Closes #1666

## How has this been tested?
<!--- Describe how you tested changes -->
Tested in-place update on guildnet node
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Grest: Cron job names in kill_cron_psql_process() do not match sql procedure names
2 participants