Skip to content

[DPE-10839] feat(config): complete update_config with API apply, restart engine, and bridges (4/6) - #180

Merged
marceloneppel merged 10 commits into
16/edgefrom
feature/migrate-update-config
Aug 18, 2026
Merged

[DPE-10839] feat(config): complete update_config with API apply, restart engine, and bridges (4/6)#180
marceloneppel merged 10 commits into
16/edgefrom
feature/migrate-update-config

Conversation

@marceloneppel

@marceloneppel marceloneppel commented Jul 11, 2026

Copy link
Copy Markdown
Member

Issue

The capstone of the migration: the update_config orchestration itself — apply the Patroni REST API config patch, decide reload-vs-restart, and persist the config hash — plus the charm-owned bridges it calls back into.

Solution

  • managers/config.py: update_config orchestration wiring apply_api_config, handle_restart_need, is_tls_enabled, is_restart_pending, generate_config_hash, and config-hash persistence.
  • Reload/restart bridges as constructor-injected charm-owned callables (request_restart, refresh_endpoints, restart_services), matching the TLS migration's collaborator-injection pattern; declared @abstractmethod on the abstract charm and stubbed per substrate.
  • VM-only standalone connect-gate; K8s goes member-started → apply_api_config directly.
  • is_tls_enabled additionally requires the certs to be on disk (TLSManager.client_tls_files_on_disk). This is a deliberate divergence from the charms, which check the relation databag alone: issued certs reach the databag before the push writes them to the workload, and the push can defer — on K8s whenever the container is not ready — so any of the other update_config call sites firing in that window rendered ssl: on against files that were not there yet.
  • The VM snap-revision gate narrows self.workload with a type-checking-only cast, so workload/vm.py — and with it the snap charm lib, which K8s does not install — stays out of the K8s import graph.
  • generate_config_hash is a cached_property and the config-render line logs at info level, both restoring what the charms do.

Final (code-only) PR in the update_config stack; the ConfigManager constructor grows to seven args, so the minimal fixture update to keep the suite green rides here, and the new unit tests land in the stack's test PR (#188). Charm adoption — deleting the charm-side copies, catching DeployedWithoutTrustError, wiring the bridges — follows in per-charm PRs once the lib is released.

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(config): migrate update_config subsystem into the library feat(config): complete update_config with API apply, restart engine, and bridges Jul 11, 2026
@marceloneppel
marceloneppel changed the base branch from tls-4-tests to skl-01-update-config-3-template July 11, 2026 01:42
@marceloneppel
marceloneppel force-pushed the skl-01-update-config-3-template branch from cba92af to fdf2a44 Compare July 11, 2026 16:12
@marceloneppel
marceloneppel force-pushed the feature/migrate-update-config branch from 08f5993 to 40752dd Compare July 11, 2026 16:12
@marceloneppel
marceloneppel force-pushed the skl-01-update-config-3-template branch from fdf2a44 to ef76d9a Compare July 20, 2026 13:22
@marceloneppel
marceloneppel force-pushed the feature/migrate-update-config branch from 40752dd to 912b1a4 Compare July 20, 2026 13:22
@marceloneppel marceloneppel changed the title feat(config): complete update_config with API apply, restart engine, and bridges feat(config): complete update_config with API apply, restart engine, and bridges (4/5) Jul 20, 2026
@marceloneppel marceloneppel changed the title feat(config): complete update_config with API apply, restart engine, and bridges (4/5) feat(config): complete update_config with API apply, restart engine, and bridges (4/6) Jul 20, 2026
@marceloneppel
marceloneppel force-pushed the skl-01-update-config-3-template branch from ef76d9a to d994db8 Compare July 20, 2026 19:04
@marceloneppel
marceloneppel force-pushed the feature/migrate-update-config branch 2 times, most recently from 9efcc0a to e80e84f Compare July 20, 2026 20:25
@marceloneppel
marceloneppel force-pushed the skl-01-update-config-3-template branch from d994db8 to f5d55f2 Compare July 21, 2026 17:46
@marceloneppel
marceloneppel force-pushed the feature/migrate-update-config branch from e80e84f to 113b21b Compare July 21, 2026 17:46
@marceloneppel
marceloneppel force-pushed the skl-01-update-config-3-template branch from f5d55f2 to 79f2a4f Compare July 23, 2026 17:34
@marceloneppel
marceloneppel force-pushed the feature/migrate-update-config branch from 113b21b to 814ec30 Compare July 23, 2026 17:38
@marceloneppel marceloneppel changed the title feat(config): complete update_config with API apply, restart engine, and bridges (4/6) [DPE-10839] feat(config): complete update_config with API apply, restart engine, and bridges (4/6) Aug 13, 2026
…and bridges

The library now owns the full config-update flow (steps 3-10) instead of the
charm. update_config renders, applies Patroni-controlled parameters via the API,
runs the TLS/pending-restart decision engine, honors the VM snap gate, and
persists the config/user hashes -- all in the lib.

The substrate-tangled pieces of the restart trigger, endpoint refresh, and
monitoring/LDAP service restarts ride charm-side through three injected bridge
callables (request_restart, refresh_endpoints, restart_services) until their own
migration phases, so the two HIGH-risk substrate diffs in the restart trigger
(VM pops postgresql_restarted; K8s updates the metrics scrape job) stay out of
the library. is_tls_enabled and generate_config_hash internalize; user_hash
stays injected. The config hash is byte-compatible with the charm's, so charm
adoption does not force a spurious restart.

Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
The millicore floor is a behaviour change with no counterpart in the charms
this port mirrors, so it does not belong in a parity diff a reviewer checks
line by line against them. It now lives in its own fix on 16/edge (#206).

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

BaseWorkload gained a non-abstract get_snap_revision that only the VM workload
can answer, purely so the type checker would accept a call the substrate guard
already keeps off K8s. Reach it the way the event handlers reach the other
VM-only workload capability, by narrowing with isinstance at the call site, so
the shared interface stops advertising a snap the K8s workload has no access to.

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

The ported line carried the VM charm's wording, which dropped the K8s charm's
"Updating Patroni config file" from the logs entirely. Operators grepping either
substrate's history for that phrase would have found nothing after the move.

Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
Both charms compute this hash once per hook via cached_property; the port turned
it into a plain property, so update_config recomputes it on each of its two
accesses. The value cannot differ within a hook, so this only restores the
charms' cost profile.

Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
Narrowing the snap gate with isinstance needed VMWorkload at runtime, and that
module imports the snap charm lib, which ships only in the vm extra. The K8s
charm installs postgresql and k8s, imports the config manager, and would have
died at startup on `cannot import name 'snap' from 'charmlibs'`. The library's
own test env installs every extra, so nothing here would have caught it.

Narrow with a type-checking-only cast instead; the substrate guard is what keeps
the call off K8s at runtime.

Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
The K8s charm logged this at info, so operators saw a config render in
debug-log at default verbosity; the port left it at the VM charm's debug level
and that visibility disappeared on both substrates.

Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
These base classes are the per-substrate charm definitions, not test scaffolding,
and describing them as unit-test only reopens a settled question about whether
they belong in the shipped wheel. What the comment needs to say is which side
owns the bridges, which the preceding lines already do.

Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
Issued certs land in the relation databag before the push writes them to the
workload, and the push can defer — on K8s whenever the container is not ready.
Any of the other update_config call sites firing in that window rendered ssl on
against files that were not there, which is the non-atomicity the TLS port left
open; TLSManager.client_tls_files_on_disk was added for this and had no caller.

This diverges from the charms, which check the databag alone.

Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
Base automatically changed from skl-01-update-config-3-template to 16/edge August 17, 2026 19:11
@marceloneppel
marceloneppel force-pushed the feature/migrate-update-config branch from 69a977a to aa29985 Compare August 17, 2026 19:12
@marceloneppel
marceloneppel marked this pull request as ready for review August 17, 2026 19:23
@marceloneppel
marceloneppel requested a review from a team as a code owner August 17, 2026 19:23
@marceloneppel
marceloneppel requested review from carlcsaposs-canonical, dragomirp, juju-charm-bot and taurus-forever and removed request for a team August 17, 2026 19:23
Comment thread single_kernel_postgresql/managers/config.py Outdated
…y log

update_config runs on nearly every hook, and the ported line had merged the K8s
charm's info level with the VM charm's parameter payload, so the full PostgreSQL
parameter dict landed in every operator's log at default verbosity.

Each substrate's original line goes back as it was: the info announcement
operators grep for, and the parameter dump at debug.

Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
@marceloneppel
marceloneppel merged commit 803beae into 16/edge Aug 18, 2026
6 of 7 checks passed
@marceloneppel
marceloneppel deleted the feature/migrate-update-config branch August 18, 2026 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants