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

Remove crontab #3369

Merged
merged 3 commits into from
Apr 5, 2023
Merged

Conversation

dbutenhof
Copy link
Member

PBENCH-1086

Use systemd to periodically run the pbench-index service instead of requiring that we generate a crontab file and install components to use it.

We add the sd_notify service to the server shell to better synchronize with systemd so that it knows our service isn't "running" once we've been exec-d, but only when we tell it. I also added some STATUS updates, although these don't matter much unless someone is watching with systemctl status. The critical bit is that we issue READY=1 when we want systemd to consider the server "active". This triggers the new pbench-index.timer, which will begin to run every minute (more or less as with crontab). The sd_notify delay ensures that the server will have initialized PostgreSQL and Elasticsearch to avoid any conflicts. This introduces the Type = notify and NotifyAccess settings. (I chose all as the NotifyAccess because it appears that we're now seeing notifications from gunicorn as well, and all allows systemd to recogize sd_notify calls from children of the main service PID instead of writing a warning into the journal.)

We use User = pbench system services rather than user services principally because the latter would complicate the build and deployment without giving any real benefits. Because buildah builds images without an initd pid 1, the necessary loginctl enable-linger pbench and systemctl --user commands aren't available during container build. While I experimented with deferring these until we stand up the real container during deployment, that never felt "clean".

Note that I removed the pidfile and kill configuration from the service file. These are actually unnecessary unless the service is doing something unusual: instead we simply tell systemd to use SIGTERM on the primary service PID. (Though even that isn't strictly necessary as SIGTERM is the default.)

PBENCH-1086

Use systemd to periodically run the pbench-index service instead of requiring
that we generate a crontab file and install components to use it.

We add the `sd_notify` service to the server shell to better synchronize with
`systemd` so that it knows our service isn't "running" once we've been exec-d,
but only when we tell it. I also added some `STATUS` updates, although these
don't matter much unless someone is watching with `systemctl status`. The
critical bit is that we issue `READY=1` when we want `systemd` to consider the
server "active". This triggers the new `pbench-index.timer`, which will begin
to run every minute (more or less as with `crontab`). The `sd_notify` delay
ensures that the server will have initialized PostgreSQL and Elasticsearch to
avoid any conflicts. This introduces the `Type = notify` and `NotifyAccess`
settings. (I chose `all` as the `NotifyAccess` because it appears that we're
now seeing notifications from `gunicorn` as well, and `all` allows `systemd`
to recogize `sd_notify` calls from children of the main service PID instead
of writing a warning into the journal.)

We use `User = pbench` system services rather than user services principally
because the latter would complicate the build and deployment without giving
any real benefits. Because `buildah` builds images without an `initd` pid 1,
the necessary `loginctl enable-linger pbench` and `systemctl --user` commands
aren't available during container build. While I experimented with deferring
these until we stand up the real container during deployment, that never felt
"clean".

Note that I removed the pidfile and kill configuration from the service file.
These are actually unnecessary unless the service is doing something unusual:
instead we simply tell `systemd` to use `SIGTERM` on the primary service PID.
(Though even that isn't strictly necessary as `SIGTERM` is the default.)
@dbutenhof dbutenhof added Server Installation Containerization Of and relating to the process of setting up and maintaining container images labels Apr 4, 2023
@dbutenhof dbutenhof self-assigned this Apr 4, 2023
webbnh
webbnh previously approved these changes Apr 4, 2023
Copy link
Member

@webbnh webbnh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Just small stuff and nits.

lib/pbench/cli/server/shell.py Show resolved Hide resolved
lib/pbench/test/unit/server/test_shell_cli.py Show resolved Hide resolved
server/lib/config/nginx.conf Outdated Show resolved Hide resolved
lib/pbench/test/unit/server/test_shell_cli.py Show resolved Hide resolved
server/lib/systemd/pbench-server.service Outdated Show resolved Hide resolved
server/pbenchinacan/container-build.sh Show resolved Hide resolved
server/pbenchinacan/container-build.sh Outdated Show resolved Hide resolved
webbnh

This comment was marked as resolved.

Copy link
Member

@webbnh webbnh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@ndokos ndokos self-requested a review April 5, 2023 16:20
@dbutenhof dbutenhof merged commit 2914daf into distributed-system-analysis:main Apr 5, 2023
@dbutenhof dbutenhof deleted the syscron branch April 5, 2023 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Containerization Of and relating to the process of setting up and maintaining container images Installation Server
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants