Skip to content

fix(scaletest): cleanup: attempt to cancel in-progress jobs #9080

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

Merged
merged 2 commits into from
Aug 14, 2023

Conversation

johnstcn
Copy link
Member

It's possible to end up in a situation where, after running a scaletest create-workspaces, you over-estimate your capacity and end up with a bunch of pending workspace builds.

It's possible to hack around with this using some curl and jq, but that's neither ideal nor user-friendly:

for BUILD_ID in $(curl -H "Coder-Session-Token: ${CODER_SESSION_TOKEN}" "https://${CODER_URL}/api/v2/workspaces?limit=100" | jq -r '.workspaces[] | select(.name | startswith("scaletest")) | .latest_build | select(.status=="pending") | .id'); do echo curl -H "Coder-Session-Token: ${CODER_SESSION_TOKEN}" -X PATCH "https://${CODER_URL}/api/v2/workspacebuilds/${BUILD_ID}/cancel"; done

This change modifies the cleanup behaviour to make a best-effort attempt to cancel the in-progress scaletest workspace build jobs before deleting them.

@johnstcn johnstcn self-assigned this Aug 14, 2023
if err = r.client.CancelWorkspaceBuild(ctx, build.ID); err != nil {
logger.Warn(ctx, "failed to cancel workspace build, attempting to delete anyway", slog.Error(err))
} else {
canceled = true
Copy link
Member

Choose a reason for hiding this comment

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

We could just wait here vs using a boolean?

@johnstcn johnstcn changed the title fix(cli): scaletest/cleanup: attempt to cancel in-progress jobs fix(scaletest): cleanup: attempt to cancel in-progress jobs Aug 14, 2023
@johnstcn johnstcn merged commit ef9d84c into main Aug 14, 2023
@johnstcn johnstcn deleted the cj/scaletest-cleanup-cancel branch August 14, 2023 11:43
@github-actions github-actions bot locked and limited conversation to collaborators Aug 14, 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.

2 participants