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

Catch SIGTERM and SIGINT #556

Open
Nudin opened this issue Jun 20, 2024 · 1 comment
Open

Catch SIGTERM and SIGINT #556

Nudin opened this issue Jun 20, 2024 · 1 comment

Comments

@Nudin
Copy link

Nudin commented Jun 20, 2024

What is the idea ?

When an ansible deploy is stopped – by for example C^c, kill or a crash of the controller – ara will continue to show the run as "running" indefinitely or until ara expire is executed. For some kinds of crashes like SIGKILL or kernel panics this is unavoidable, but for the most common cases SIGINT (C^c) and SIGTERM it would be possible to catch the signal to gracefully mark the run as failed. This would improve the usefulness of ara, since one would see if a run is still ongoing or was canceled by the caller.

I tried adding a signal trap to the ara ansible callback script and it works.

@dmsimard
Copy link
Contributor

Hi @Nudin and thanks for the issue.

This use case is in part why the ara expire command exists: to eventually expire playbooks that crashed or were interrupted and thus remained in running forever.

I like the idea of trying to capture signals if it is possible and you have something working.

I wonder how reliable it would be because running from within the ansible callback plugin interface is kind of special but it is probably better than nothing.

I also wonder about whether the status of the playbook should be failed, expired or if we need something new like "interrupted" because the playbook didn't /really/ fail.

If you would like to open a PR with what you have we can discuss it and go from there.

Nudin added a commit to Nudin/ara that referenced this issue Jun 27, 2024
This will catch SIGINT/SIGTERM and send an update to the ara server, so
that the playbook does not continue to be shown as running indefinitely
but will report failed. See ansible-community#556
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

No branches or pull requests

2 participants