Skip to content

fix(acme): make renewal scheduling lifetime-aware and retry-safe - #86

Merged
RentnerKev merged 3 commits into
mainfrom
fix/acme-renewal-scheduling
Sep 12, 2026
Merged

RentnerKev merged 3 commits into
mainfrom
fix/acme-renewal-scheduling

Conversation

@RentnerKev

@RentnerKev RentnerKev commented Sep 12, 2026 •

Copy link
Copy Markdown
Member

Summary

Fixes #76 (A4-01).

Short-lived ACME certificates were due almost immediately because the controller used a minimum 30-day renewal window while the UI used a different formula. A six-hour scheduler also missed shorter retry deadlines, and manual renewal could clear stored backoff.

Solution and architecture

  • Renew after two thirds of the actual certificate lifetime; poll due work every minute.
  • Persist consecutive attempts, last attempt/success and the next retry deadline in the existing controller certificate index. Attempt history continues growing after the backoff reaches its cap. Keep four global ACME slots and per-certificate leases.
  • Enforce retry deadlines at the certificate-store mutation boundary, including manual retry and restart recovery.
  • Preserve CA Retry-After independently of local backoff through the existing instant-acme boundary. Persist shared account cooldowns per environment for 429/503, and keep them across imports, concurrent successes and restarts.
  • Keep imported certificates out of automatic renewal and preserve active certificate material on renewal failure.
  • Align the Web status formula and accept additive controller scheduling metadata.

Tests

The complete local check passed (format, lint, typecheck, migration validation, 726 Bun tests including PostgreSQL/Redis integration, clippy and both production builds). After the final counter correction, all 131 Rust tests, clippy and format checks passed again; 36 real Caddy proxy checks; 40 real certificate/HTTP-01/DNS-01 checks; 11 upstream TLS checks. 29 appliance/backup/restore/legacy-upgrade checks also passed. The tests cover lifetime boundaries, persistent retry/restart, manual import/retry, account/environment isolation, legacy indexes and RBAC/runtime contracts. ACME tests use pinned Pebble fixtures, never production issuance.

The real certificate smoke checks denied retries before and after restart. To test eventual success without a 30-minute sleep it changes only the stopped disposable fixture's persisted deadline; no production retry-bypass endpoint is added.

Migration

Existing Alpha 3 certificate indexes and retryAfter timestamps remain readable. The optional acmeRetryUntil map holds shared account cooldowns. The controller continues using the existing state backup; no database migration or proxy snapshot version change is required by this issue. Rollback restores the pre-upgrade backup with the old image.

Security

Retry checks remain inside the existing certificate operation lease boundary. RBAC and the typed Caddy runtime architecture are unchanged. CA transport remains HTTPS-only and does not follow redirects. No credentials, private certificates or production data are included.

Screenshots

Not applicable: this change corrects status timing without changing the layout.

No alpha.4 tag or GitHub release is published by this PR.

@RentnerKev RentnerKev added this to the v1.0.0-alpha.4 milestone Sep 12, 2026
@RentnerKev RentnerKev added bug Something isn't working area: runtime Caddy and privileged controller runtime behavior. area: certificates Certificates, ACME, trusted CAs, and TLS material. labels Sep 12, 2026
@coderabbitai

coderabbitai Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 8b8572db-7bbf-4137-ab99-f8c7045cff4c


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Sep 12, 2026
@RentnerKev
RentnerKev merged commit 679c13f into main Sep 12, 2026
21 checks passed
@RentnerKev
RentnerKev deleted the fix/acme-renewal-scheduling branch September 12, 2026 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: certificates Certificates, ACME, trusted CAs, and TLS material. area: runtime Caddy and privileged controller runtime behavior. bug Something isn't working documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(acme): make renewal scheduling lifetime-aware and retry-safe

1 participant