refactor(config): adopt single-kernel update_config, drop charm copy#1647
Draft
marceloneppel wants to merge 2 commits into
Draft
refactor(config): adopt single-kernel update_config, drop charm copy#1647marceloneppel wants to merge 2 commits into
marceloneppel wants to merge 2 commits into
Conversation
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>
The lib's update_config stack was rebased to add the ported regression tests (resource-introspection edges + the enable_tls render assertion), orphaning the old tip 08f5993. Point the archive pin at the new #180 tip; the installed lib source is unchanged from 08f5993 — only lib test files were added. Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
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.
Issue
The K8s charm still carried its own copy of the
update_configsubsystem — parameter building, Patroni REST API patching, K8s replication-slot sync, restart handling, and config/user-hash persistence — duplicating logic the single-kernel library now owns. The VM charm already adopted the library'supdate_config(canonical/postgresql-operator#1849); while the duplication remains, the two substrates drift apart on every future config change.Solution
Delegate to the library's
ConfigManager.update_configand drop the charm's copy:ConfigManager(state, workload, tls_manager, patroni_manager + three charm-side bridge callbacksrequest_restart/refresh_endpoints/restart_services) so the library drives the K8s-specific pebble/metrics side effects without reaching into charm internals.update_configbecomes a thin wrapper that delegates and catchesDeployedWithoutTrustError— the library's K8s workload now raises this typed exception on a 403 instead of a rawApiError, and the charm re-surfaces its existing "deployed without trust" blocked status._build_postgresql_parameters, the worker-calc family,_api_update_config,_handle_postgresql_restart_need,generate_config_hash,is_restart_pending) and the charm-localtemplates/patroni.yml.j2(the library owns the merged substrate-conditional template).update_configmigration commit with thek8sextra (lightkube). Unreleased pin — this is stacked on test(integration): add async-replication-over-TLS coverage (K8s) #1619 (basetest/async-replication-tls) and draft until the library releases.Unit suite is green consuming the library (137 passed): 14 migrated-away tests removed, 5 added covering the three bridges, the delegation, and the DeployedWithoutTrust catch.
Checklist