Skip to content

Make drain plugin drain spec deterministic - #5457

Merged
philippthun merged 1 commit into
cloudfoundry:mainfrom
sap-contributions:fix-drain-plugin-spec-race
Oct 9, 2026
Merged

philippthun merged 1 commit into
cloudfoundry:mainfrom
sap-contributions:fix-drain-plugin-spec-race

Conversation

@philippthun

@philippthun philippthun commented Sep 17, 2026 •

Copy link
Copy Markdown
Member

The 'works off all remaining jobs before exiting' example raced the worker loop against TERM signal delivery. On slow/contended runners the drain flag (exit_on_complete) flipped late, so work_off ran extra times and the count inflated past 3.

Block the worker after its first work_off call until the test confirms the drain TERM handler has set exit_on_complete, then release it. This removes the timing dependency and makes the call count deterministic.

This change was developed with AI assistance; all code was reviewed and tested by me.

  • I have reviewed the contributing guide

  • I have viewed, signed, and submitted the Contributor License Agreement

  • I have made this pull request to the main branch

  • I have run all the unit tests using bundle exec rake

  • I have run CF Acceptance Tests

Comment thread spec/unit/lib/delayed_job/local_worker_drain_plugin_spec.rb Outdated
@philippthun
philippthun force-pushed the fix-drain-plugin-spec-race branch from 659fa78 to db37786 Compare October 8, 2026 09:46
The 'works off all remaining jobs before exiting' example raced the
worker loop against TERM signal delivery. On slow/contended runners the
drain flag (exit_on_complete) flipped late, so work_off ran extra times
and the count inflated past 3.

Block the worker after its first work_off call until the test confirms
the drain TERM handler has set exit_on_complete, then release it. This
removes the timing dependency and makes the call count deterministic.
@philippthun
philippthun force-pushed the fix-drain-plugin-spec-race branch from db37786 to 3ccd512 Compare October 8, 2026 09:48
@philippthun
philippthun requested a review from johha October 8, 2026 09:49
@philippthun
philippthun merged commit 0e46202 into cloudfoundry:main Oct 9, 2026
11 checks passed
ari-wg-gitbot added a commit to cloudfoundry/capi-release that referenced this pull request Oct 9, 2026
Changes in cloud_controller_ng:

- Make drain plugin drain spec deterministic
    PR: cloudfoundry/cloud_controller_ng#5457
    Author: Philipp Thun <philipp.thun@sap.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants