-
Notifications
You must be signed in to change notification settings - Fork 825
fix: keep valid cert symlinks until docker-gen generates its data #1274
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
Merged
buchdag
merged 4 commits into
nginx-proxy:main
from
JamBalaya56562:fix/cert-symlinks-on-startup
Jul 6, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
b2f22a8
fix: keep valid cert symlinks until docker-gen generates its data
JamBalaya56562 ea81d86
test: fail certs_persistence when the update_certs run errors
JamBalaya56562 007661d
chore: trim verbose comments and split the certs_persistence exec calls
JamBalaya56562 f94c9cf
tests: extend force_renew check timeout
buchdag File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| #!/bin/bash | ||
|
|
||
| ## Test that existing certificate symlinks survive an update_certs run happening | ||
| ## before docker-gen generated /app/letsencrypt_service_data (issue #956). | ||
|
|
||
| if [[ -z $GITHUB_ACTIONS ]]; then | ||
| le_container_name="$(basename "${0%/*}")_$(date "+%Y-%m-%d_%H.%M.%S")" | ||
| else | ||
| le_container_name="$(basename "${0%/*}")" | ||
| fi | ||
| run_le_container "${1:?}" "$le_container_name" | ||
|
|
||
| # Use the first domain from the comma separated TEST_DOMAINS. | ||
| IFS=',' read -r -a domains <<< "$TEST_DOMAINS" | ||
| domain="${domains[0]}" | ||
|
|
||
| # Cleanup function with EXIT trap | ||
| function cleanup { | ||
| # Remove the Nginx container silently. | ||
| docker rm --force "$domain" &> /dev/null | ||
| # Cleanup the files created by this run of the test to avoid foiling following test(s). | ||
| docker exec "$le_container_name" /app/cleanup_test_artifacts | ||
| # Stop the LE container | ||
| docker stop "$le_container_name" > /dev/null | ||
| } | ||
| trap cleanup EXIT | ||
|
|
||
| # Issue a certificate for $domain and wait for its symlink. | ||
| run_nginx_container --hosts "$domain" | ||
| if ! wait_for_symlink "$domain" "$le_container_name" "./${domain}/fullchain.pem"; then | ||
| echo "Failed to issue an initial certificate for $domain." | ||
| fi | ||
|
|
||
| # Case A: no user data file present; the symlink must be preserved. | ||
| # remove service and user data files | ||
| docker exec "$le_container_name" bash -c 'rm -f /app/letsencrypt_service_data /app/letsencrypt_user_data' 2>&1 | ||
| # manually trigger cert update loop | ||
| if ! update_certs_out="$(docker exec "$le_container_name" bash -c 'source /app/letsencrypt_service --source-only && update_certs' 2>&1)"; then | ||
| echo "update_certs failed during the data-less run with no user data: $update_certs_out" | ||
| fi | ||
| if ! docker exec "$le_container_name" test -L "/etc/nginx/certs/${domain}.crt"; then | ||
| echo "The $domain symlink was removed by a data-less update_certs run with no user data (issue #956)." | ||
| fi | ||
|
|
||
| # Case B: an empty user data file but no service data file; the symlink must be preserved. | ||
| # create an empty user data file and remove service data file | ||
| docker exec "$le_container_name" bash -c 'touch /app/letsencrypt_user_data && rm -f /app/letsencrypt_service_data' 2>&1 | ||
| # manually trigger cert update loop | ||
| if ! update_certs_out="$(docker exec "$le_container_name" bash -c 'source /app/letsencrypt_service --source-only && update_certs' 2>&1)"; then | ||
| echo "update_certs failed during the data-less run with user data present: $update_certs_out" | ||
| fi | ||
| if ! docker exec "$le_container_name" test -L "/etc/nginx/certs/${domain}.crt"; then | ||
| echo "The $domain symlink was removed by a data-less update_certs run with user data present (issue #956)." | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Uh oh!
There was an error while loading. Please reload this page.