fix(topology): raise incidents for standalone services with no application - #6737
Open
Prabal864 wants to merge 1 commit into
Open
fix(topology): raise incidents for standalone services with no application#6737Prabal864 wants to merge 1 commit into
Prabal864 wants to merge 1 commit into
Conversation
…ation _process_tenant returned immediately whenever a tenant had no topology applications at all, so a service with an active alert never got an incident unless it happened to belong to one. Separately, _get_topology_data called get_all_topology_data without include_empty_deps, so a service with zero dependency edges (the literal 'standalone service' case) was filtered out before the processor ever saw it. Fixes both: the application loop no longer gates the rest of the function, and services with alerts that aren't part of any application now get their own topology incident via new _get/_create/_update_service_based_incident methods, keyed by service name (incident_application left null) instead of an application id. Application-based incidents are untouched. Closes keephq#6702
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6737 +/- ##
===========================================
- Coverage 46.42% 30.46% -15.96%
===========================================
Files 178 101 -77
Lines 18694 11773 -6921
===========================================
- Hits 8679 3587 -5092
+ Misses 10015 8186 -1829 ☔ View full report in Codecov by Harness. 🚀 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.
What's changed?
_process_tenantreturned immediately whenever a tenant had no topology applications at all (if not applications: return), so a service with an active alert never got an incident unless it happened to belong to an application. Separately,_get_topology_datacalledget_all_topology_datawithoutinclude_empty_deps=True, so a service with zero dependency edges - the literal "standalone service" from the issue title - was filtered out of the topology data before the processor ever saw it, even once the early-return above is removed.Fixed both:
_get_topology_datanow passesinclude_empty_deps=True._get_service_based_incident/_create_service_based_incident/_update_service_based_incidentmethods - keyed by service name withincident_applicationleftNone, instead of an application id. These are additive; the existing application-based methods and their callers are untouched.Closes #6702
How was this patch tested?
tests/test_topology.pyfollowing its existing style (realTopologyProcessor()against the sqlitedb_sessionfixture, not mocks): incident-creation defaults for the new service-based path, the same deleted-incident-is-skipped guard the application path already has, a check that the service-based lookup never picks up an application-based incident, and two_process_tenant-level tests (a standalone service alone, and an application + an unrelated standalone service together) proving the actual bug is fixed end to end.poetry install/Windows blocker as my other PRs in this repo, this time compounded bykeep.api.core.dbunconditionally importing most of the optional integrations (GCP/AWS/Azure SDKs, several message queues, etc.) at module scope, which pip's resolver couldn't reconcile in one shot on this platform. So instead I extracted the two actual pieces of changed control flow (theinclude_empty_depsgate and the application-vs-standalone routing in_process_tenant) into a standalone script using plain Python objects and confirmed old-vs-new behavior objectively - happy to paste it here if useful.python -m py_compileandblack --checkpass on both changed files.