As part of the DrupalCI MVP deployment core maintainers would like the ability to cancel a pending or in-progress test - to save time in instances of known bad patches, hung testbot states, etc..

A further delineation of use cases for canceling tests would likely be useful.

Permissions:

  1. We'll go ahead and great the ability of anyone who submitted a patch the ability to cancel their own tests.
  2. We'll likely also allow project maintainers to cancel tests in their projects.

2 ways to cancel jobs in Jenkins:

  • If the job has a ci_url set, as in the test has started, the request to cancel is a straightforward HTTP request.
  • If the job is in-between, it will be a couple HTTP requests to find and cancel the Jenkins queue item.

Comments

hestenet’s picture

The short term solution for this is simply granting Jenkins access to trusted core devs to cancel jobs.

A blocker right now is that a canceled job in Jenkins does not kill the container.

We discussed solutions during the weekly testbot meeting.

The testbot host itself will likely need to check to see if it's still supposed to be running and kill if not.

tim.plunkett’s picture

I think "known bad patches" covers most of my usages of this. Or, "I uploaded 3 patches in quick succession, please cancel the first two", which is a subset of that.

I get pings like that about 2 times a week, more during sprints or when qa.d.o used to get backed up.

yesct’s picture

I dont think this is a blocker to disabling the old testbots. (but is an important feature to add to the new ones.)

basic’s picture

Our idea for solving this is to use a "drupalci clean" command before each test run to ensure the test runner is in a clean state.

If a test is cancelled, the test runner may still be running on the spot instance, but the next job that is assigned to the test runner would:

drupalci clean
drupalci run

Which would always start the next test in a clean state.

d.o -> job 1 -> dispatcher -> runner A (drupalci clean, drupalci run)
d.o -> cancel job 1 -> dispatcher -> cancel job 1 -> runner A continues to run test w/o jenkins knowledge
d.o -> job 2 -> dispatcher -> runner A (drupalci clean, drupalci run) -- drupalci clean cancels the existing test and cleans the existing data before running job 2
isntall’s picture

This should also have the added benefit of Jenkins killing the testrunner once it reaches the timeout, end or the billable hour.

isntall’s picture

The dispatcher.dci.o work has been completed for this. It should no longer be a blocker for the front-end/drupal.org side.

A little bit of how I see this working
Cancel button is pressed on d.o
Once a 'Cancel' request has been received dispatcher.dci.o, Jenkins will stop the job and change the state of the testrunner to idle.
In the idle state a new job can be sent to a testrunner, or it can be terminated.

drumm’s picture

Who should have access to do this? Should everyone have access to cancel their own tests?

Is a POST to https://dispatcher.drupalci.org/job/{job}/{build}/stop?token=correct_token the correct way to stop it?

drumm’s picture

Status: Active » Postponed (maintainer needs more info)
basic’s picture

Status: Postponed (maintainer needs more info) » Needs work

It looks like that GET request is correct for builds that have started. If the build hasn't started and it is still in a queued state then there should be a post to https://dispatcher.drupalci.org/queue/cancelItem?id=

http://stackoverflow.com/questions/21021905/how-to-stop-a-build-in-jenki...

hestenet’s picture

Discussing this internally and based on the comments in the issue above:

1) We'll go ahead and great the ability of anyone who submitted a patch the ability to cancel their own tests.

2) We'll likely also allow project maintainers to cancel tests in their projects.

hestenet’s picture

Issue summary: View changes
drumm’s picture

Version: » 7.x-3.x-dev

This will be done in 3 parts:

  • If the job has a status of PIFT_CI_STATUS_QUEUE, the test hasn't been sent yet, and can be aborted without sending to the dispatcher.
  • If the job has a ci_url set, as in the test has started, the request to cancel is a straightforward HTTP request.
  • If the job is in-between, it will be a couple HTTP requests to find and cancel the Jenkins queue item.
drumm’s picture

Project: DrupalCI: Dispatcher (Modernizing Testbot Initiative) » Project issue file test
wim leers’s picture

#11 sounds awesome.

drumm’s picture

Assigned: Unassigned » drumm
Issue summary: View changes

If the job has a status of PIFT_CI_STATUS_QUEUE, the test hasn't been sent yet, and can be aborted without sending to the dispatcher.

I'll leave this part off. Jobs are in this state for less than a minute, which we might minimize in the future with supervisord & beanstalk.

  • drumm committed 4447149 on 7.x-3.x
    Issue #2518056: Need the ability to cancel a test job, cancel running...

  • drumm committed 07e6927 on 7.x-3.x
    Issue #2518056: Need the ability to cancel a test job, use correct...
drumm’s picture

Canceling running tests is now working.

drumm’s picture

Status: Needs work » Fixed

I'm going to call this done. Most of the time, there isn't much of a queueing step in Jenkins. A followup can be filed if it is needed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.