Move most of maintenance mode logic into maintenance_mode module #350
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This establishes the same internal API for maintenance mode as for
health
andmetrics
. While at it, I adjustedget_response()
to make producingbody_content
more straightforward – no long a mutable variable that might or might not be overwritten but two straightforward branches. Side-effect: empty maintenance mode file will no longer result in default message. IMHO this makes sense because a) someone might actually show an empty message and b) the message about falling back to default message is only logged when the maintenance mode file doesn’t exist, not when it is empty.I also changed
DEFAULT_BODY_CONTENT
because the old message is IMHO grammatically incorrect. It should be either “server is under maintenance” or “server is in maintenance mode” (I went with the latter).Related Issue
This is another step towards fixing #342.
How Has This Been Tested?
I added some rudimentary unit tests. Functional testing on Linux was also successful.