fix: cert pool changes requiring pebble restart - #870
Closed
hpidcock wants to merge 1 commit into
Closed
Conversation
This direction is fine for us, thanks for this @hpidcock |
|
@hpidcock If this merges, how would we be able to make use of this? Is this bound to Juju versions: would we need to rebuild our rocks? Is there a way for us to work around this issue for now? E.g., remove a LogTarget or something similar? |
Member
Author
|
We're exploring this as the solution, so closing this now. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This is a WIP, and I'm not entirely happy with having to extract logic from the std library.
TLS root cert pool refresh on replan
When the system CA certificate bundle changes, HTTP clients in
checkstate,loki, andopentelemetrypreviously held a stale*http.Transportfor the lifetime of the process. This PR adds automatic refresh on replan.What changed
internals/httputil— new package providingTransport, a lazy-loadinghttp.RoundTripper:x509.SystemCertPool()(stdlib memoised call, correct at startup).Refresh(), cert files are stat-checked first; if any mtime/size changed, individual certs are re-parsed, diffed against the tracked set, and additions/removals are logged vialogger.Noticef. A new*http.Transport(cloned fromhttp.DefaultTransport) is swapped in and idle connections on the old one are closed.RoundTrip,Refresh()is a no-op (lazy loading).tools/gencertloader— code-generation tool that extractsloadSystemRoots,certFiles,certDirectories, and supporting helpers directly from$GOROOT/src/crypto/x509/root_unix.goandroot_linux.govia AST transformation. Every mutation is self-documenting: the original stdlib line is preserved as a comment above the replacement. Run viago generate ./internals/httputil.checkstate,logstate,loki,opentelemetry— each manager gains a*httputil.Transportcreated at construction;PlanChangedcallstransport.Refresh()before any other work.flowchart TD A[OS cert bundle updated]:::accent2 B[Operator adds/edits layer]:::accent2 C[planMgr.PlanChanged]:::accent1 C --> D[checkstate.PlanChanged]:::accent0 C --> E[logstate.PlanChanged]:::accent0 D --> F[httputil.Transport.Refresh]:::accent3 E --> F F --> G{cert files\nchanged?}:::accent3 G -- no --> H[no-op]:::accent4 G -- yes --> I[parse certs\ndiff fingerprints\nlog added/removed]:::accent3 I --> J[swap *http.Transport\nclose idle conns]:::accent3 J --> K[httpChecker.check]:::accent5 J --> L[loki.Client.Flush]:::accent5 J --> M[otel.Client.Flush]:::accent5 A --> B --> C