-
Notifications
You must be signed in to change notification settings - Fork 320
fix: preserve subject and source on GenericChange findings #2129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,14 +7,19 @@ | |
| from hikaru.model.rel_1_26 import Deployment | ||
|
|
||
| from robusta.core.model.k8s_operation_type import K8sOperationType | ||
| from robusta.integrations.kubernetes.autogenerated.events import KubernetesAnyChangeEvent | ||
| from robusta.core.reporting import FindingSource | ||
| from robusta.integrations.kubernetes.autogenerated.events import ( | ||
| DeploymentChangeEvent, | ||
| KubernetesAnyChangeEvent, | ||
| ) | ||
| from robusta.integrations.kubernetes.base_triggers import ( | ||
| DEFAULT_CHANGE_FILTERS, | ||
| DEFAULT_CHANGE_IGNORE, | ||
| DEFAULT_CHANGE_INCLUDE, | ||
| K8sBaseTrigger, | ||
| K8sTriggerChangeFilters, | ||
| ) | ||
| from robusta.integrations.kubernetes.custom_models import RobustaDeployment | ||
|
|
||
|
|
||
| class TestK8sBaseTrigger: | ||
|
|
@@ -81,3 +86,23 @@ def test_check_change_filters_changes( | |
| assert diff.formatted_path == expected_change_path | ||
| assert diff.other_value == old_value | ||
| assert diff.value == expected_diff_new_value | ||
|
|
||
|
|
||
| class TestK8sBaseChangeEventDefaultFinding: | ||
| @pytest.fixture() | ||
| def event(self): | ||
| with open("tests/k8s_change_obj.json") as f: | ||
| data = json.loads(f.read()) | ||
| obj = hikaru.from_dict(data, RobustaDeployment) | ||
| return DeploymentChangeEvent(operation=K8sOperationType.UPDATE, old_obj=obj, obj=obj) | ||
|
|
||
| def test_default_finding_keeps_subject_and_source(self, event): | ||
| finding = event.create_default_finding() | ||
|
|
||
| assert finding.aggregation_key == "GenericChange" | ||
| assert finding.subject.namespace == "default" | ||
| assert finding.subject.name == "xxx-deployment" | ||
| assert finding.source == FindingSource.KUBERNETES_API_SERVER | ||
| # sink routing/grouping reads these, so they must not fall back to "None" | ||
| assert finding.attribute_map["namespace"] == "default" | ||
| assert finding.attribute_map["name"] == "xxx-deployment" | ||
|
Comment on lines
+99
to
+108
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win Cover labels and annotations in the regression test. The stated contract includes preserving 🤖 Prompt for AI Agents |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Remove the unused
DEFAULT_CHANGE_INCLUDEimport.Flake8 reports this import as unused (
F401), so it should be removed before merge.Proposed fix
from robusta.integrations.kubernetes.base_triggers import ( DEFAULT_CHANGE_FILTERS, DEFAULT_CHANGE_IGNORE, - DEFAULT_CHANGE_INCLUDE, K8sBaseTrigger,📝 Committable suggestion
🤖 Prompt for AI Agents
Source: Linters/SAST tools