Skip to content

fix(changedetector): Use service reload commands instead of supervisorctl restart <service>#2947

Merged
polarathene merged 6 commits intodocker-mailserver:masterfrom
polarathene:chore/change-detection-reload-instead-of-restart
Dec 23, 2022
Merged

fix(changedetector): Use service reload commands instead of supervisorctl restart <service>#2947
polarathene merged 6 commits intodocker-mailserver:masterfrom
polarathene:chore/change-detection-reload-instead-of-restart

Conversation

@polarathene
Copy link
Copy Markdown
Member

@polarathene polarathene commented Dec 22, 2022

Description

With reload a change detection event during local testing can be processed in less than a second according to logs. Previously this was 5+ seconds (plus additional downtime for Postfix/Dovecot to become available again).

In the past it was apparently an issue to use <service> reload due to a concern with the PID for wrapper scripts that supervisorctl managed, thus supervisorctl <service> restart had been used. Past discussions with maintainers suggest this is not likely an issue anymore, and reload should be fine to switch to now 👍


NOTE: It may not be an issue in the CI, but on local systems running tests may risk failure in setup-cli.bats from a false positive due to 1 second polling window of the test helper method, and a change event being possible to occur entirely between the two checks undetected by the current approach.

If this is a problem, we may need to think of a better way to catch the change. The letsencrypt test counts how many change events are expected to have been processed, and this could technically be leveraged by the test helper too.


NOTE: These two lines (with regex pattern for postfix) are output in the terminal when using the services respective reload commands:

postfix/master.*: reload -- version .*, configuration /etc/postfix
dovecot: master: Warning: SIGHUP received - reloading configuration

I wasn't sure how to match them as they did not appear in the changedetector log (EDIT: they appear in the main log output, eg docker logs <container name>).

Instead I've just monitored the changedetector log messages, which should be ok for logic that previously needed to ensure Dovecot / Postfix was back up after the restart was issued.


This was a change I wanted to get into a major release at some point. I don't have the usual extensive details / references to support the change however.

This should help reduce downtime during change events, especially in situations like reported here?:


Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Improvement (non-breaking change that does improve existing functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected) - Potentially?

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • New and existing unit tests pass locally with my changes

@polarathene polarathene added service/dovecot service/postfix area/scripts kind/improvement Improve an existing feature, configuration file or the documentation labels Dec 22, 2022
@polarathene polarathene added this to the v12.0.0 milestone Dec 22, 2022
@polarathene polarathene self-assigned this Dec 22, 2022
casperklein
casperklein previously approved these changes Dec 22, 2022
Copy link
Copy Markdown
Member

@georglauterbach georglauterbach left a comment

Choose a reason for hiding this comment

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

LGTM 👍🏼 Just the one thing about the return code / value.

Comment thread test/helper/common.bash Outdated
Comment thread test/test_helper/common.bash Outdated
@polarathene
Copy link
Copy Markdown
Member Author

postfix/master.*: reload -- version .*, configuration /etc/postfix
dovecot: master: Warning: SIGHUP received - reloading configuration

These seem to appear in the main logs via docker logs <container name>. Mentioning if we do get a need to match on that.

I guess this PR is fine now (assuming the CI is a tad slower to avoid race condition).

Reloading is faster than restarting the processes.

Restarting is a bit heavy handed here and may no longer be necessary for general usage?
Change detection is too fast now (0-1 seconds vs 5+).

Directory being waited on here was created near the end of a change event, reducing that time to detect a change by the utility method further.

We can instead check that the directory exists after the change detection event is completed.
We don't presently use remote storage in tests, but it might be relevant in future when testing NFS.

This at least avoids any confusing failure happening when that scenario is tested.
`-ne 0` wasn't doing what I thought apparently. Review feedback shows that this is the correct way to handle the conditional.
@polarathene polarathene force-pushed the chore/change-detection-reload-instead-of-restart branch from 1e9e1f7 to 18ddcd3 Compare December 23, 2022 02:32
@polarathene polarathene changed the title fix: Change events reload Dovecot and Postfix instead of restart fix(changedetector): Use service reload commands instead of supervisorctl restart <service> Dec 23, 2022
Copy link
Copy Markdown
Member

@georglauterbach georglauterbach left a comment

Choose a reason for hiding this comment

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

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/scripts kind/improvement Improve an existing feature, configuration file or the documentation service/dovecot service/postfix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants