feat: Change renew rc when cert is still valid #2366
Closed
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.
Sometimes the lego Client may fail to contact the CA due to some temporary networking issue on the host. The certificate may otherwise still be valid, and a user may want to ignore this issue.
This change modifies the renew service so that if the lego client is nil, but the certificate is not expired, the exit code of the program will be 2 instead of 1. Crucially it does not change if lego exits, only the exit code itself.
In order to implement this, I had to change the setup function to remove a usage of
log.Fatalf
which in turn required me to introduce explicitos.Exit
calls in some commands. Although this was the lowest patch delta solution, I also considered refactoring the setup entirely to removelog.Fatalf
, and return setup errors instead.As with my previous PR, I performed a full integration test using the NixOS ACME integration test suite. You can run that test locally with this command:
nix run github:m1cr0man/nixpkgs/lego-offline-renewal-test#nixosTests.acme
Here's some example log output with this change implemented, sampled from a system with the network disabled: