refactor(config): adopt the single-kernel update_config subsystem#1849
Draft
marceloneppel wants to merge 12 commits into
Draft
refactor(config): adopt the single-kernel update_config subsystem#1849marceloneppel wants to merge 12 commits into
marceloneppel wants to merge 12 commits into
Conversation
Consume the single-kernel library's operator-certificate TLS handler (events.tls.TLS) and TLSManager instead of the charm-side src/relations/tls.py, stacked on the DPE-10062 Patroni/cluster port (#1788). The TLS events handler owns the two certificate requirers and is constructor-injected into TLSManager, whose live-fetch getters read cert/key from them. A charm-side reload bridge (_reload_tls_after_push) reloads PostgreSQL after the lib handler stores+pushes certs; it also fires on relation_broken so detaching the TLS operator re-renders Patroni with TLS disabled. Removes src/relations/tls.py and push_tls_files_to_workload (now owned by the lib), routes internal-cert regeneration through _regenerate_internal_cert, redirects the operator-cert getters to tls_manager, and pins the library to the TLS stack tip via archive URL (16.3.2 is not yet released). Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
The TLS lib stack was rebased onto current 16/edge and re-bumped to 16.3.3 because 16/edge had meanwhile shipped its own 16.3.2, and the rebase dropped the dead workload parameter from the TLS events handler constructor, so the pin and the construction call move together. Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
The relation_broken bridge registrations reference only self.on[...], so an __init__ reorder above the lib handler's construction would silently run the reload before the lib clears state and pushes files; the prior test asserted membership without order. The bridge's except-and-defer branch also had no coverage, so a refactor could drop the broad guard without failing CI. Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
Absorb the single remaining 16/edge commit (ca93296: renovate bump to published single-kernel 16.3.2) since the branch last merged 16/edge. #1788 (Patroni-port) and the 5a9fa05 lib pin / 2-arg TLS migration are already on this branch. Keep the branch's unreleased-lib archive-URL pin (5a9fa05) over 16/edge's published-16.3.2 dep, since this branch tests the unreleased TLS handler. Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com> # Conflicts: # poetry.lock # pyproject.toml
Absorb 16/edge deps bumps (946cb61: Python deps, 24a7609: lock maintenance) landed since the last merge. Keep the branch's unreleased-lib archive-URL pin (5a9fa05) over 16/edge's published-16.3.2 dep, since this branch tests the unreleased TLS handler. Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com> # Conflicts: # poetry.lock
Re-pin the unreleased single-kernel library from 5a9fa05 to a1d2178, the rebased TLS-stack tip. a1d2178 includes the operator-cert manager/ events handler (the migration payload) plus the docstring/comment cleanup that dropped stale operator-repo file-path references and #168/V3-V4 idiom mentions from the lib. The 5a9fa05→a1d2178 diff is docstring/comment-only, so no charm-side code changes are required. Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
Remove _platform_machine, _observers_for, and the three reload-bridge observer-ordering tests that exercised charm-side __init__ wiring now that the bridge itself is transitional and scheduled to leave the charm when update_config ports to the lib. _platform_machine was redundant: refresh_versions.toml keys both x86_64 and aarch64, so the platform.machine() snap-revision lookup succeeds natively on either arch without the monkeypatch (proven by the suite passing on aarch64 after removal). Its harness dependency and the now-unused TLS_CLIENT/TLS_PEER_RELATION imports go with it. Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
The TLS flip branch pinned postgresql-charms-single-kernel to a GitHub archive URL (commit a1d2178) to test unreleased lib changes. 16.3.3 is now published to PyPI carrying the same TLS state + manager/events content, so restore the published-version pin form and regenerate poetry.lock against the PyPI wheel/tarball. Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com> # Conflicts: # poetry.lock
Point the charm at the lib PR-stack tip (08f5993) via its GitHub archive tarball so the migrated update_config subsystem can be exercised by the charm's own unit suite before the lib is released. The pin is provisional and swaps to a released version once the lib stack lands. Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
The single-kernel library now owns update_config end to end: parameter building, worker-process calculation, Patroni API patching, restart-need handling, and Patroni template rendering. Keeping the charm's copy of that logic would mean maintaining two implementations of the same behaviour, so the charm delegates to the lib's ConfigManager and its own copies (worker-calc helpers, _api_update_config, _handle_postgresql_restart_need, get_available_memory, generate_config_hash, is_restart_pending, and the charm-local Patroni template) are removed. Tests for the deleted methods are dropped rather than re-pointed at the lib, since the lib is a faithful behaviour-preserving port and their coverage now lives there; re-asserting the same behaviour charm-side would just be duplicated coverage. The three new bridge methods (request_restart, refresh_endpoints, restart_services) that the lib calls back into, plus the update_config delegation itself, get their own tests since this is new charm-side wiring with no prior coverage. Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
2 tasks
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
update_configsubsystem (PostgreSQL parameter building →patroni.ymlrender → Patroni REST API config patch → reload/restart decision → config-hash persistence) was duplicated in this charm andpostgresql-k8s-operator. It has been migrated into thepostgresql-charms-single-kernellibrary; this PR makes the VM charm consume the library's implementation instead of carrying its own copy.Solution
08f5993, the lib PR-stack tip) so the unreleasedupdate_configcan be consumed and validated before the library is released. The pin is provisional and swaps to a released version once the lib stack lands.ConfigManagerwith its full collaborator set (tls_manager,patroni_manager) and three charm-owned bridges —request_restart(pop the restarted flag + acquire the rolling-restart lock),refresh_endpoints(client-relationupdate_endpoints), andrestart_services(monitoring + LDAP-sync snap services).update_confignow delegates toConfigManager.update_config; the charm's own copy is removed —_build_postgresql_parameters, the six_calculate_max_*helpers and their validator,_api_update_config,_handle_postgresql_restart_need,generate_config_hash,get_available_memory,is_restart_pending— along withtemplates/patroni.yml.j2(the library owns the template).Stacked on the TLS migration (#1816, base
flip/tls-lib) — draft until the lib stack releases and the pin is finalised.Checklist