Skip to content

Closes #11152: Add support to abort custom script gracefully #11621

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

Conversation

BarbarossaTM
Copy link
Contributor

@BarbarossaTM BarbarossaTM commented Jan 30, 2023

Fixes: #11152

This PR adds a new AbortScript exception which a custom script can throw in case the script should be terminated cleanly. It allows specifying an error message which will be reported to the user, but no stack trace is shown. Any other unhandled exception will still raise a stacktrace.

Copy link
Member

@jeremystretch jeremystretch left a comment

Choose a reason for hiding this comment

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

A couple very minor notes, but this is great work! Thank you!

@jeremystretch
Copy link
Member

@BarbarossaTM thanks for this! Do you think it would make sense to implement this functionality for reports too? (I'd be fine reusing the same AbortScript exception for reports.)

…cefully

Signed-off-by: Maximilian Wilhelm <max@sdn.clinic>
@BarbarossaTM BarbarossaTM force-pushed the 11152-report-script-errors branch from ff2dd4a to 3c92787 Compare February 2, 2023 20:19
@jeremystretch jeremystretch merged commit 699edd0 into netbox-community:develop Feb 2, 2023
@jeremystretch
Copy link
Member

Thanks @BarbarossaTM!

@BarbarossaTM BarbarossaTM deleted the 11152-report-script-errors branch February 2, 2023 20:23
@BarbarossaTM
Copy link
Contributor Author

Thanks for the native speaker language polish :-)

I haven't used report myself yet, but I assume it might be useful there too, I guess the place to do it there would be in

def run_report(job_result, *args, **kwargs):

Do you want to me look into this and file another PR?

@jeremystretch
Copy link
Member

If you'd like to. Or we can wait and see if this gets any feedback first.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow custom scripts to fail gracefully on errors detected by the scripts
2 participants