Skip to content

feat(tls): emit tls_files_pushed after a successful cert push (6/6)#189

Draft
marceloneppel wants to merge 2 commits into
skl-01-update-config-testsfrom
tls-files-pushed
Draft

feat(tls): emit tls_files_pushed after a successful cert push (6/6)#189
marceloneppel wants to merge 2 commits into
skl-01-update-config-testsfrom
tls-files-pushed

Conversation

@marceloneppel

Copy link
Copy Markdown
Member

Issue

The TLS handler pushes cert files to the workload on certificate_available; the charm reloads PostgreSQL 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 charm's reload observer completes leaves the retried push writing the new cert with nothing reloading — the reload ran against the stale on-disk files and won't run again. Raised in review on the K8s TLS migration (canonical/postgresql-k8s-operator#1618).

Solution

Add a tls_files_pushed custom event on the TLS handler, emitted only after push_tls_files() succeeds; either defer guard returns without emitting. The charm's reload bridge observes this instead of certificate_available, so the reload fires only once the files are on disk, and a deferred push retries together with its reload. This also lets the charms drop the two guards (internal-ca present, client_tls_files_on_disk()) they duplicate from this handler.

Stacked on the update_config lib stack; the two charm rewires follow and pin this commit.

Checklist

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

@marceloneppel marceloneppel changed the title feat(tls): emit tls_files_pushed after a successful cert push feat(tls): emit tls_files_pushed after a successful cert push (6/6) Jul 20, 2026
@marceloneppel
marceloneppel force-pushed the skl-01-update-config-tests branch from 808b479 to 373a525 Compare July 20, 2026 19:04
@marceloneppel
marceloneppel force-pushed the skl-01-update-config-tests branch from 373a525 to 558c61f Compare July 20, 2026 20:25
@marceloneppel
marceloneppel force-pushed the skl-01-update-config-tests branch from 558c61f to ba946a4 Compare July 21, 2026 17:47
The TLS handler pushes cert files to the workload on certificate_available, and the charm reloads PostgreSQL in a separate observer of the same event. Because defer is per-observer, a push that defers (e.g. a Pebble write fails mid cert renewal) while the charm's reload observer completes leaves the retried push writing the new cert with nothing reloading.

Emit a tls_files_pushed event only after push_tls_files() succeeds; a deferred push returns without emitting. The charm's reload bridge observes this instead of certificate_available, so the reload runs only once the files are on disk and a deferred push retries together with its reload.

Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
The update_config + tls_files_pushed stack branched at 16.3.3; 16/edge has since released 16.3.4. Set the version to the next patch so the library is release-ready as soon as this stack lands on 16/edge.

Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
@marceloneppel
marceloneppel force-pushed the skl-01-update-config-tests branch from ba946a4 to af641bb Compare July 23, 2026 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant