wait for jobs to complete when stopping the runner #202

Merged
earl-warren merged 1 commit from earl-warren/runner:wip-signal into main 2024-06-07 10:43:02 +00:00
Contributor

When receiving a signal (INT or TERM) wait for running jobs to complete instead of terminating them right away.

The new shutdown_timeout configuration setting can be used to force the termination after a grace delay. If not specified or zero it will shutdown immediately, for backward compatibility. It will be the case with existing configuration files or when a configuration file is not specified.

The config.yml created with the generate-config subcommand will however default shutdown_timeout to 3h (same as timeout) because it is likely what a new admin would expect: shutting down waits for jobs to complete and not abort them.


Note to reviewers:

When receiving a signal (INT or TERM) wait for running jobs to complete instead of terminating them right away. The new shutdown_timeout configuration setting can be used to force the termination after a grace delay. If not specified or zero it will shutdown immediately, for backward compatibility. It will be the case with existing configuration files or when a configuration file is not specified. The config.yml created with the generate-config subcommand will however default shutdown_timeout to 3h (same as timeout) because it is likely what a new admin would expect: shutting down waits for jobs to complete and not abort them. --- Note to reviewers: * Add tests (100% coverage) * See also https://gitea.com/gitea/act_runner/pulls/546 for the implementation that inspired this PR * setup-forgejo https://code.forgejo.org/actions/setup-forgejo/pulls/128 * end-to-end https://code.forgejo.org/forgejo/end-to-end/pulls/197
earl-warren force-pushed wip-signal from 1a8e1028ba
All checks were successful
/ cascade (pull_request) Has been skipped
checks / build and test (pull_request) Successful in 1m8s
checks / runner exec tests (pull_request) Successful in 30s
/ example-docker-compose (pull_request) Successful in 2m5s
to 44845583fa
All checks were successful
/ cascade (pull_request) Has been skipped
checks / build and test (pull_request) Successful in 22s
checks / runner exec tests (pull_request) Successful in 26s
/ example-docker-compose (pull_request) Successful in 2m0s
2024-06-06 15:02:16 +00:00
Compare
earl-warren force-pushed wip-signal from 5ba4238ad3
All checks were successful
/ cascade (pull_request) Has been skipped
checks / build and test (pull_request) Successful in 36s
checks / runner exec tests (pull_request) Successful in 25s
/ example-docker-compose (pull_request) Successful in 1m59s
to 708ec54339
All checks were successful
/ cascade (pull_request) Has been skipped
checks / build and test (pull_request) Successful in 28s
checks / runner exec tests (pull_request) Successful in 25s
/ example-docker-compose (pull_request) Successful in 1m59s
2024-06-06 23:32:17 +00:00
Compare
earl-warren force-pushed wip-signal from 708ec54339
All checks were successful
/ cascade (pull_request) Has been skipped
checks / build and test (pull_request) Successful in 28s
checks / runner exec tests (pull_request) Successful in 25s
/ example-docker-compose (pull_request) Successful in 1m59s
to 2367d25adf
All checks were successful
/ cascade (pull_request) Has been skipped
checks / build and test (pull_request) Successful in 22s
checks / runner exec tests (pull_request) Successful in 26s
/ example-docker-compose (pull_request) Successful in 1m59s
2024-06-06 23:48:20 +00:00
Compare
earl-warren changed title from WIP: graceful shutdown to wait for jobs to complete when stopping the runner 2024-06-06 23:49:33 +00:00
earl-warren force-pushed wip-signal from 2367d25adf
All checks were successful
/ cascade (pull_request) Has been skipped
checks / build and test (pull_request) Successful in 22s
checks / runner exec tests (pull_request) Successful in 26s
/ example-docker-compose (pull_request) Successful in 1m59s
to af763c6728
All checks were successful
/ cascade (pull_request) Has been skipped
checks / build and test (pull_request) Successful in 21s
checks / runner exec tests (pull_request) Successful in 26s
/ example-docker-compose (pull_request) Successful in 1m59s
2024-06-07 00:00:03 +00:00
Compare
Author
Contributor

The default value for the shutdown timeout is the only thing that actually make sense (same as the timeout of jobs). However it makes it a breaking change for whatever scripts expect an immediate stop. I think it is acceptable but I'm not 100% sure.

The default value for the shutdown timeout is the only thing that actually make sense (same as the timeout of jobs). However it makes it a breaking change for whatever scripts expect an immediate stop. I think it is acceptable but I'm not 100% sure.
earl-warren force-pushed wip-signal from af763c6728
All checks were successful
/ cascade (pull_request) Has been skipped
checks / build and test (pull_request) Successful in 21s
checks / runner exec tests (pull_request) Successful in 26s
/ example-docker-compose (pull_request) Successful in 1m59s
to c15caa51e7
All checks were successful
/ cascade (pull_request) Has been skipped
checks / build and test (pull_request) Successful in 21s
checks / runner exec tests (pull_request) Successful in 25s
/ example-docker-compose (pull_request) Successful in 2m5s
2024-06-07 00:04:40 +00:00
Compare
earl-warren force-pushed wip-signal from c15caa51e7
All checks were successful
/ cascade (pull_request) Has been skipped
checks / build and test (pull_request) Successful in 21s
checks / runner exec tests (pull_request) Successful in 25s
/ example-docker-compose (pull_request) Successful in 2m5s
to 67a1d83ad7
All checks were successful
/ cascade (pull_request) Has been skipped
checks / build and test (pull_request) Successful in 53s
checks / runner exec tests (pull_request) Successful in 28s
/ example-docker-compose (pull_request) Successful in 2m0s
2024-06-07 07:10:42 +00:00
Compare
earl-warren force-pushed wip-signal from 67a1d83ad7
All checks were successful
/ cascade (pull_request) Has been skipped
checks / build and test (pull_request) Successful in 53s
checks / runner exec tests (pull_request) Successful in 28s
/ example-docker-compose (pull_request) Successful in 2m0s
to 7b6fe77166
All checks were successful
checks / build and test (pull_request) Successful in 22s
checks / runner exec tests (pull_request) Successful in 26s
/ example-docker-compose (pull_request) Successful in 1m59s
/ cascade (pull_request) Successful in 6m53s
2024-06-07 07:13:29 +00:00
Compare
Author
Contributor

The implementation was changed to default to terminating immediately if shutdown_timeout is zero or unset. Defaulting to the timeout is a bad idea. Not only is it a breaking change https://code.forgejo.org/forgejo/end-to-end tests that rely on the fact that the runner can be stopped immediately (but that can easily be changed by setting the timeout to 1).

It is also problematic because there is no way to force the runner to stop immediately. Once the runner received the signal, it will stop listening to other signals and the admin will have no choice but to wait it out. Or kill -9 which would force them to manually cleanup leftovers.

The implementation was changed to default to terminating immediately if shutdown_timeout is zero or unset. Defaulting to the timeout is a bad idea. Not only is it a breaking change https://code.forgejo.org/forgejo/end-to-end tests that rely on the fact that the runner can be stopped immediately (but that can easily be changed by setting the timeout to 1). It is also problematic because there is no way to force the runner to stop immediately. Once the runner received the signal, it will stop listening to other signals and the admin will have no choice but to wait it out. Or kill -9 which would force them to manually cleanup leftovers.
Contributor

cascading-pr updated at actions/setup-forgejo#128

cascading-pr updated at https://code.forgejo.org/actions/setup-forgejo/pulls/128
earl-warren force-pushed wip-signal from 7b6fe77166
All checks were successful
checks / build and test (pull_request) Successful in 22s
checks / runner exec tests (pull_request) Successful in 26s
/ example-docker-compose (pull_request) Successful in 1m59s
/ cascade (pull_request) Successful in 6m53s
to e02e0fc5f5
All checks were successful
/ example-docker-compose (pull_request) Successful in 2m5s
/ cascade (pull_request) Has been skipped
checks / build and test (pull_request) Successful in 32s
checks / runner exec tests (pull_request) Successful in 33s
2024-06-07 10:33:42 +00:00
Compare
earl-warren deleted branch wip-signal 2024-06-07 10:43:03 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
forgejo/runner!202
No description provided.