[agent] Replace drbdsetup status polling with events2 state store#643
Open
astef wants to merge 1 commit into
Open
[agent] Replace drbdsetup status polling with events2 state store#643astef wants to merge 1 commit into
astef wants to merge 1 commit into
Conversation
3e7ad1d to
ec3685e
Compare
Introduce DRBDStateStore — an in-memory representation of DRBD runtime state maintained from the events2 stream by the Scanner — and ShowCache for lazy per-resource caching of drbdsetup show results. The reconciler's initial observe phase now reads from the store and show cache (zero subprocess calls in steady state), while the post-convergence refresh still calls drbdsetup status directly for immediate accuracy. Key changes: - Add --statistics to events2 args so device size is available - Type Event.Kind and Event.Object as enums with validation in parseLine - Scanner populates DRBDStateStore alongside the existing DRBDPortCache - observeActualDRBDState reads from store + show cache - New observeActualDRBDStateFresh for post-convergence (direct status) - Orphan and rename existence checks use store.ResourceExists() - ShowCache invalidated after convergence actions Subprocess calls per reconcile: Non-converging: 2 → 0 (first time: 1 show) Converging: 4 → 2 (refresh status + refresh show) Signed-off-by: Aleksandr Stefurishin <aleksandr.stefurishin@flant.com>
ec3685e to
f620d04
Compare
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.
Description
Replace per-reconcile
drbdsetup status+drbdsetup showsubprocess calls with an in-memory state store backed by theevents2stream, plus a lazy show cache for configuration data.Two new components are introduced in the
drbdrpackage:DRBDStateStore— thread-safe store of DRBD runtime state (role, disk-state, connections, paths, etc.), built incrementally from events2 by the Scanner. ProvidesSnapshot(resourceName)that returns a*drbdutils.Resourcecompatible with the existingactualStateconsumption.ShowCache— per-resource cache ofdrbdsetup showresults (configuration options, backing disk, net options). Fetched lazily on first access, invalidated after convergence actions.The reconciler's initial observe phase reads from the store + show cache (zero subprocess calls in steady state). The post-convergence refresh still calls
drbdsetup statusdirectly for immediate accuracy, then re-fetches show from the invalidated cache.--statisticsflag added to events2 args sosizeis available in device events.Why do we need it, and what problem does it solve?
Every reconcile of a
DRBDResourcespawned 2 subprocesses (drbdsetup status+drbdsetup show), and up to 2 more after convergence. With 20 concurrent reconcilers and frequent events, this created excessive process overhead.The events2 stream already carries all runtime state data — the same data that
drbdsetup statusreturns. By maintaining this state in memory and reading from it during reconciliation, we eliminate redundant subprocess calls.What is the expected result?
Subprocess calls per reconcile cycle:
Functional behavior is preserved — the same
ActualDRBDStateinterface is used by downstream code (Report,computeTargetDRBDActions, etc.) with no changes.Checklist