fix(backend/core): self-heal stale EdgeConfig cache on GetEdgeConfig - #3950
Open
Christoph-87 wants to merge 2 commits into
Open
Christoph-87 wants to merge 2 commits into
Christoph-87 wants to merge 2 commits into
Conversation
When the Backend restarts and an Edge reconnects with a 1006/1008 close code, the onOpen callback is skipped and the EdgeConfig cache remains empty. Subsequent GetEdgeConfig requests then returned an empty config. Fix: if the cached config has no factories but the Edge is online, fetch the live config directly from the Edge via ComponentJsonApiRequest before responding. Closes OpenEMS#3756
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #3950 +/- ##
=============================================
+ Coverage 55.88% 55.91% +0.03%
- Complexity 19348 19360 +12
=============================================
Files 3705 3705
Lines 173321 173326 +5
Branches 14254 14256 +2
=============================================
+ Hits 96844 96893 +49
+ Misses 72641 72588 -53
- Partials 3836 3845 +9 🚀 New features to boost your workflow:
|
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.
Summary
onOpencallback is skipped so the EdgeConfig cache is never repopulatedGetEdgeConfigrequests then returned an empty config, breaking the UIEdgeRpcRequestHandler.handleGetEdgeConfigRequest, if the cached config has no factories and the Edge is online, fetch the live config directly from the Edge viaComponentJsonApiRequestbefore respondingTest plan
EdgeRpcRequestHandlerTest.testGetEdgeConfig_returnsCache_whenFactoriesPresent— cached config with factories is returned directlyEdgeRpcRequestHandlerTest.testGetEdgeConfig_fetchesLive_whenFactoriesEmptyAndOnline— empty cache + online Edge triggers live fetchEdgeRpcRequestHandlerTest.testGetEdgeConfig_returnsEmptyCache_whenFactoriesEmptyAndOffline— empty cache + offline Edge returns empty (no live fetch attempted)Closes #3756