Preserve discovery progress and group cleanup on membership changes#691
Open
Preserve discovery progress and group cleanup on membership changes#691
Conversation
65f9d47 to
a243bc2
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #691 +/- ##
==========================================
+ Coverage 97.51% 97.52% +0.01%
==========================================
Files 62 62
Lines 10949 10960 +11
==========================================
+ Hits 10677 10689 +12
+ Misses 272 271 -1 ☔ View full report in Codecov by Sentry. 🚀 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.
This pull request introduces robust error handling and lifecycle management improvements for device and group entity discovery in the ZHA integration. The changes ensure that exceptions during endpoint discovery do not halt discovery for other endpoints, and that group entity cleanup properly invokes lifecycle methods, preventing resource leaks and stale entities.
Improved error handling for entity discovery
discover_device_entitiesto catch exceptions during endpoint discovery, log the error, and continue processing remaining endpoints, preventing partial entity loss.test_discover_device_entities_continues_after_endpoint_exception) to verify that discovery continues after an endpoint exception.Group entity lifecycle and cleanup enhancements
discover_group_entitiesto schedule lifecycle cleanup (on_remove) for group entities when group membership drops below quorum, instead of directly clearing entities, ensuring proper cleanup and avoiding leaks.test_discover_group_entities_member_drop_runs_group_entity_on_remove) and stale platform entity pruning (test_discover_group_entities_platform_quorum_drop_prunes_stale_platform_entity).Test infrastructure updates
tests/test_discover.pyto support the new tests and discovery logic.## SummaryMakes discovery resilient to per-endpoint exceptions and ensures stale group entities are removed via lifecycle cleanup when membership/platform quorum changes.
Failing tests addressed
tests/test_discover.py::test_discover_device_entities_continues_after_endpoint_exceptiontests/test_discover.py::test_discover_group_entities_member_drop_runs_group_entity_on_removetests/test_discover.py::test_discover_group_entities_platform_quorum_drop_prunes_stale_platform_entityVerification
pytest(branch-local targeted run): all listed tests pass.