robusta-dev / robusta

Kubernetes observability and automation, with an awesome Prometheus integration
https://home.robusta.dev/
MIT License
2.54k stars 247 forks source link

Use new custom triggers API to refactor existing playbooks #258

Open aantn opened 2 years ago

aantn commented 2 years ago

Today we try to write Robusta actions that can be re-used in multiple scenarios. For example, an action that fetches logs should be usable both in the case of a crashing pod and a prometheus alert.

In the past, we sometimes wrote actions that included triggering logic too. For example, the restart_loop_reporter action is connected to the trigger on_pod_update. This fires very frequently and not only when a pod restarts. Therefore the restart_loop_reporter action has triggering-logic which decides when the action should even do anything.

This breaks the normal separation of triggers and actions. To solve this problem, we introduced the ability to write custom triggers. For example, you can write a crashloop_backoff trigger which inherits from on_pod_update and only fires on pod updates which are due to a crashing pod.

We should rewrite old actions to use the new custom-triggers API. This will lead to more re-usable code.

Actions to rewrite:

chetak123 commented 2 years ago

Hey @aantn I'm interested in this issue but having some doubts in it:

  1. I was observing restart_loop_reporter file but can't find logs_enricher in there.
  2. Also I'm not able to find alert_on_hpa_reached_limit file or any python file related to hpa.
aantn commented 2 years ago

@chetak123 yeah, the logs_enricher is indeed in a different file.

It would probably be easier to start with alert_on_hpa_reached_limit over here.