Skip to content

Puma 5.6.5 with SystemD - #52240

Merged
Hamms merged 20 commits into
stagingfrom
puma-5-only-systemctl
Jun 15, 2023
Merged

Puma 5.6.5 with SystemD#52240
Hamms merged 20 commits into
stagingfrom
puma-5-only-systemctl

Conversation

@Hamms

@Hamms Hamms commented Jun 6, 2023

Copy link
Copy Markdown
Contributor

Reverts #52045, restoring #51929

Daemonization was removed in Puma 5 without replacement, so in addition to updating the Puma gem to 5.6.5 we also refactor our process monitoring. Before, we were using a SystemD service to manage a SysV init script which executes puma in daemon mode and handles things like sending a restart signal manually. Now, we simply use SystemD to directly manage a non-daemonized puma process.

The main piece of functionality we lose out on with this approach is Puma's "hot restart", which we had previously implemented manually in the SysV init script with a SIGUSR2 signal. We could replace our existing functionality with an invocation of pumactl restart, but after talking it through with @sureshc I'm convinced we don't actually need any fancy restart support here so we instead simply perform a hard restart of the entire SystemD service whenever we need to update. Note that this does mean that any requests made to the server while it is restarting will now immediately fail with a 502 error; previously, those requests would hang until they either time out or the restart finishes, whichever comes first. This is probably a less-desirable behavior overall, but because it only impacts our content and build servers and not production, we've decided it's an acceptable loss.

Links

Testing story

Tested on an adhoc to verify that everything starts up as expected, and can be successfully updated with subsequent builds.

Comparative analysis of chef-bootstrap-debug.log indicates that this approach does result in us doing a few more restarts and spending a bit more time waiting than in our current implementation, but at the cost of only 1-3 minutes of time over the course of a 2+ hour build process.

Deployment strategy

This update should apply cleanly to our existing persistent managed servers, but we will need to manually remove any artifacts of the old implementation that we no longer want. In particular, the /etc/init.d/{dashboard,pegasus} scripts.

@Hamms Hamms changed the title Puma 5 only systemctl Puma 5.6.5 with SystemD Jun 7, 2023
@Hamms Hamms added the Ruby Update Everything related to work to update the version of Ruby our codebase runs on label Jun 7, 2023
@Hamms
Hamms marked this pull request as ready for review June 7, 2023 20:16
@Hamms
Hamms requested a review from a team as a code owner June 7, 2023 20:16

# We always want to restart the web server process whenever port/socket
# listener configuration is changed, so create a file with that information
# as its contents and invoke the restart whenever those contents change.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We specify listener via code and config that in practice only changes with a release and an invocation of our build process (which stops/starts the service). Do we need to support this use case?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It might not be strictly necessary, but building in protections for execution scenarios other than a full ci_build is still good practice. We don't want our Chef scripts to break unless they're run in a particular way by a particular external build process; they should be internally consistent.

@sureshc

sureshc commented Jun 9, 2023

Copy link
Copy Markdown
Contributor

Is it important to test the persistent server use case? Provision an adhoc from a feature branch off of the staging branch and then merge this change into that feature branch to ensure the adhoc rebuilds itself smoothly with the new SystemD service?

Or maybe you already ran this test. I wasn’t sure based on the details in the Testing Story.

@sureshc
sureshc self-requested a review June 9, 2023 01:25

@sureshc sureshc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Assuming we have a good plan for how this change gets applied to existing managed servers, this looks great!

@Hamms

Hamms commented Jun 9, 2023

Copy link
Copy Markdown
Contributor Author

Ah, good callout; I haven't tested that scenario yet, and it does seem worth doing. I'll do that before merging.

Although, I will point out that so far that approach hasn't been sufficient to catch many of the issues that arise in practice with upgrading our persistent servers. Drift and accumulated one-off operations that have been applied to the servers outside the context of Chef are rampant. Still worth doing just in case, though!

@Hamms Hamms mentioned this pull request Jun 13, 2023
@Hamms
Hamms merged commit 5e03f0a into staging Jun 15, 2023
@Hamms
Hamms deleted the puma-5-only-systemctl branch June 15, 2023 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ruby Update Everything related to work to update the version of Ruby our codebase runs on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants