Skip to content

Commit

Permalink
fix(reactions): Ignore rules without reactions
Browse files Browse the repository at this point in the history
  • Loading branch information
adityahase committed Jan 2, 2025
1 parent 35ddeb7 commit 8c6acc4
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,15 @@ def react_for_instance(self, instance) -> dict:
rule: "PrometheusAlertRule" = frappe.get_doc("Prometheus Alert Rule", self.alert)
labels = self.get_labels_for_instance(instance)
job = rule.react(instance_type, instance, labels)
return {"press_job_type": job.job_type, "press_job": job.name}
if job:
return {"press_job_type": job.job_type, "press_job": job.name}
return {}

def react(self):
for instance in self.get_instances_from_alerts_payload(self.payload):
self.append("reaction_jobs", self.react_for_instance(instance))
reaction_job = self.react_for_instance(instance)
if reaction_job:
self.append("reaction_jobs", reaction_job)
self.save()

def get_instances_from_alerts_payload(self, payload: str) -> set[str]:
Expand Down

0 comments on commit 8c6acc4

Please sign in to comment.