Skip to content

nginx: skip cert fetch on startup when existing cert is still valid#8517

Merged
aapeliv merged 1 commit into
developfrom
devops/fix/skip-cert-fetch-when-valid
May 10, 2026
Merged

nginx: skip cert fetch on startup when existing cert is still valid#8517
aapeliv merged 1 commit into
developfrom
devops/fix/skip-cert-fetch-when-valid

Conversation

@aapeliv

@aapeliv aapeliv commented May 10, 2026

Copy link
Copy Markdown
Member

On deploy, the nginx container's run.sh calls get-certs.sh, which iterates over every domain and runs acme.sh --issue. If a cert happens to be inside acme.sh's renewal window at the moment of a deploy, this triggers a renewal against Let's Encrypt before the site comes up. This causes ~1 min downtime.

This PR adds a per-domain guard in get-certs.sh: if fullchain.pem already exists and is valid for more than 3 days, skip the acme.sh --issue call. The cron-based renewal (every 2 hours) continues to handle actual renewals, so deploys no longer touch Let's Encrypt as long as cron is healthy. The 3-day buffer is a safety net so that a long cron outage still gets rescued by a deploy before expiry.

Testing

Reviewed on production by inspecting the script logic. Manual test plan:

  • Deploy with healthy certs in /certs/live/<domain>/fullchain.pem: log should show Skipping <domain>: existing cert valid for >3 days for each domain and no acme.sh calls.
  • Deploy with a missing cert file: acme.sh runs and issues a new cert as before.
  • Deploy with a cert expiring within 3 days: acme.sh runs and renews.

For maintainers

  • Maintainers can push commits to my branch
  • Maintainers can merge this PR for me

This PR was created with the Couchers PR skill.

Avoid acme.sh hitting Let's Encrypt for every domain on each container restart. Per-domain, skip if a cert exists and is valid for more than 3 days; cron continues to handle renewals.
@vercel

vercel Bot commented May 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
couchers Ready Ready Preview May 10, 2026 2:55am

Request Review

@WouldYouKindly

Copy link
Copy Markdown
Contributor

@aapeliv we should probably add cron monitoring with something like croniter. Or maybe even sentry has a feature for that

@aapeliv
aapeliv merged commit 5ca7fb5 into develop May 10, 2026
7 checks passed
@aapeliv
aapeliv deleted the devops/fix/skip-cert-fetch-when-valid branch May 10, 2026 13:20
@github-actions github-actions Bot added the release notes: pending Add to stuff that should be included in release notes label May 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📝 Release Notes

This PR should be included in the release notes.

Suggested release note:

Improved site reliability by preventing unnecessary certificate renewals during deploys that could briefly take the site offline
🤖 Bot Debug Information

Model: couchers.openai.gpt-5.4
Decision: include
Reasoning: This is an infrastructure reliability change that prevents about a minute of downtime during some deploys by avoiding unnecessary certificate renewals at startup. While not a visible feature, it improves site availability in a user-noticeable way and qualifies as important technical work.

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

Labels

release notes: pending Add to stuff that should be included in release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants