Skip to content
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

Added a playbook to restart a deployment on certain prometheus alert #321

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

NikhilMaheshwari
Copy link

No description provided.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Nikhil Maheshwari seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Contributor

@arikalon1 arikalon1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work. Left a few minor comments, mostly around naming. Code itself is super clean, bug free.

Restart Based on prometheus alert
########################

These actions are useful for automatic restart of deployment based on certain prometheus alert.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you emphasize that we restart the deployment by the configured name, and not necessarily the deployment related to the alert



@action
def deployment_restart(alert: PrometheusKubernetesAlert, params: DeploymentParams):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mind naming it deployment_restart_by_name.
We might add another action in the future, that will do the same but using the deployment in the alert (according to labels). So we want to save a name like this for that one

f"cannot run deployment_restart on alert with no deployment: {alert}"
)
return
my_deployment.spec.template.metadata.annotations['kubectl.kubernetes.io/restartedAt'] = now
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


if not my_deployment:
logging.error(
f"cannot run deployment_restart on alert with no deployment: {alert}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will happen if the deployment doesn't exist.
It might be useful to add the deployment name and namespace to the error log

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants