Skip to content

refactor(tls): reload on tls_files_pushed instead of certificate_available#1663

Closed
marceloneppel wants to merge 2 commits into
skl-01-adopt-update-config-k8sfrom
skl-01-tls-files-pushed-k8s
Closed

refactor(tls): reload on tls_files_pushed instead of certificate_available#1663
marceloneppel wants to merge 2 commits into
skl-01-adopt-update-config-k8sfrom
skl-01-tls-files-pushed-k8s

Conversation

@marceloneppel

Copy link
Copy Markdown
Member

Issue

The lib TLS handler pushes cert files to the workload on certificate_available, and this charm reloads PostgreSQL (after refreshing the K8s trust store + charm-local CA bundle) in a separate observer of the same event. defer is per-observer, so a push that defers (e.g. a Pebble write fails during a cert renewal) while the reload observer completes leaves the retried push writing the new cert with nothing reloading. The bridge also duplicated the handler's two readiness guards, and its wiring tests asserted an ops observer-order dependency. Raised in review on the TLS migration (#1618).

Solution

The lib now emits a tls_files_pushed event after a successful push (canonical/postgresql-single-kernel-library#189). Observe that single event instead of the four certificate_available / relation_broken observers, and drop the two guards (internal-ca present, client_tls_files_on_disk()): the event fires only once the files are on disk, so a deferred push no longer triggers a reload against files that were never written, and the observer-order dependency is gone. The K8s-specific trust-store + CA-bundle sync still runs before the reload. Re-pin the lib to the commit that adds the event.

Stacked on the update_config adoption.

Checklist

  • I have added or updated any relevant documentation.
  • I have cleaned any remaining cloud resources from my accounts.

The single-kernel PostgreSQL library now owns the full update_config
subsystem (parameter building, Patroni API patching, K8s slot sync,
restart handling, and hash persistence), matching the already-adopted
VM charm. Duplicating this logic in both places would let the two
substrates drift out of sync on every future config change, so the
charm delegates to the lib's ConfigManager instead of keeping its own
copy.

The charm now constructs a 7-arg ConfigManager wired with 3 bridge
callbacks (request_restart, refresh_endpoints, restart_services) so
the lib can trigger K8s-specific pebble/metrics side effects without
depending on charm internals directly. update_config becomes a thin
wrapper that also catches DeployedWithoutTrustError, since the lib's
K8s workload now raises this on a 403 instead of a raw ApiError.

Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
…lable

The lib TLS handler now emits tls_files_pushed after a successful cert push. Observe that single event instead of certificate_available/relation_broken on both requirers, and drop the two guards (internal-ca present, cert files on disk) the bridge duplicated from the handler: the event fires only once the push has landed, so a deferred push no longer lets the bridge reload against stale files. This also removes the ops observer-order dependency the wiring tests asserted. Re-pin the lib to the commit that adds the event.

Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
@github-actions github-actions Bot added the Libraries: Out of sync The charm libs used are out-of-sync label Jul 20, 2026
@marceloneppel
marceloneppel force-pushed the skl-01-adopt-update-config-k8s branch from 76be2e2 to 65d097d Compare July 20, 2026 19:13
@marceloneppel

Copy link
Copy Markdown
Member Author

Folded into #1647: the TLS tls_files_pushed rewire now rides with the update_config adoption in a single per-charm PR. Superseded.

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

Labels

Libraries: Out of sync The charm libs used are out-of-sync

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant