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

HTTP API route for aborting execution #1352

Closed
hynd opened this issue Mar 9, 2020 · 3 comments
Closed

HTTP API route for aborting execution #1352

hynd opened this issue Mar 9, 2020 · 3 comments
Labels

Comments

@hynd
Copy link
Contributor

hynd commented Mar 9, 2020

I run load tests on a remote instance(s) with no SSH access. If a test goes awry, i'd like to be able to terminate it as quickly as possible and shutting down the instance can sometimes take several seconds/minutes. The HTTP API is great for pausing/resuming tests quickly - it would be nice and tidy if i could also abort a test in the same way (which in my case leads to the output being saved and the instance terminated).

Suggested Solution (optional)

I see the various contexts in play, but no easy path to cancel the parent created in the run cmd from the http API. The existing OS interrupt/term signal handling is graceful enough, but forcing a signal back into the process from the API feels wrong, and (i think) lacks some support on Windows.

Would simply adding a bool to the Engine struct and testing for it at the end of the select in Engine.Run() (https://github.com/loadimpact/k6/blob/new-schedulers/core/engine.go#L222) be an option you'd consider?

If so, any suggestions for the HTTP route (ie; adding to the /status PATCH, or a new route/different verb?)

@hynd hynd added the feature label Mar 9, 2020
@na--
Copy link
Member

na-- commented Mar 10, 2020

Would simply adding a bool to the Engine struct and testing for it at the end of the select in Engine.Run() (https://github.com/loadimpact/k6/blob/new-schedulers/core/engine.go#L222) be an option you'd consider?

hmm... that could work, though you shouldn't add a plain bool, since that wouldn't be thread safe. You can instead create a signal channel in NewEngine() and a new Engine.Stop() method that closes that channel. Then, the REST API can call that new Stop() method and everything should be fine.

hynd added a commit to hynd/k6 that referenced this issue Mar 10, 2020
Including a new `stop` cmd to trigger it via the HTTP API.
Closes grafana#1352.
@hynd
Copy link
Contributor Author

hynd commented Mar 10, 2020

Great, that seems to work as expected...
Any preference for the API route? (i added it to the /status PATCH route for now).

hynd added a commit to hynd/k6 that referenced this issue Mar 11, 2020
hynd added a commit to hynd/k6 that referenced this issue Mar 11, 2020
hynd added a commit to hynd/k6 that referenced this issue Mar 11, 2020
hynd added a commit to hynd/k6 that referenced this issue Mar 11, 2020
hynd added a commit to hynd/k6 that referenced this issue Mar 11, 2020
@na--
Copy link
Member

na-- commented Mar 12, 2020

Closed by #1355 (wasn't auto-closed, because the PR was merged in #1007, not master)

@na-- na-- closed this as completed Mar 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants