Skip to content

Fix busy-poll when waiting on an in-progress project update - #405

Merged
cigamit merged 1 commit into
ctrliq:mainfrom
blaipr:fix/project-update-busy-poll
Jun 14, 2026
Merged

Fix busy-poll when waiting on an in-progress project update#405
cigamit merged 1 commit into
ctrliq:mainfrom
blaipr:fix/project-update-busy-poll

Conversation

@blaipr

@blaipr blaipr commented Jun 14, 2026

Copy link
Copy Markdown
Contributor
SUMMARY

wait_for_project_update() in awx.awx.project busy-polled an in-progress project update.

When a project already has an update running — most commonly the automatic update that fires right after an SCM project is created — the current_update branch looped over GET /project_updates/<id>/ with no delay between requests until the update finished. The time.sleep(1) was placed inside the is_job_done() check, so it only ever ran once the job was already done. The same branch also ignored the module's wait, timeout, and interval parameters entirely:

  • API spam — the update endpoint was hit back-to-back with zero delay.
  • interval ignored — the user's polling interval had no effect.
  • timeout ignored — a stuck update would loop forever.
  • wait: false ignored — the task blocked unconditionally.

This change routes the branch through the existing wait_on_url() helper (the same one the explicit update_project path already uses), so interval/timeout are honored, the API is no longer hammered, and wait: false no longer blocks. changed is now derived from whether the SCM revision actually moved, matching the other branch.

This is the behavior requested upstream in ansible/awx#12850 — the busy-poll is still present in current upstream devel, so this fix is equally applicable there.

ISSUE TYPE
  • Bug, Docs Fix or other nominal change
COMPONENT NAME
  • Collection
ASCENDER VERSION
awx: 25.4.1.dev22+ga49ad5bf92.d20260614
ADDITIONAL INFORMATION

Reproduction (before this change): create a new git-backed project with the default wait: true. The module fires the automatic post-create update and lands in the current_update branch, which polls /api/v2/project_updates/<id>/ in a tight loop with no delay until the sync finishes.

Tests: added unit tests for wait_for_project_update() covering the in-progress-update wait path (asserts wait_on_url is called with the configured timeout/interval and that the endpoint is not busy-polled), the unchanged-SCM-revision changed: false case, and the wait: false non-blocking case.

awx_collection/test/awx/test_project.py::test_existing_update_is_waited_on_with_interval PASSED
awx_collection/test/awx/test_project.py::test_existing_update_unchanged_revision_is_not_changed PASSED
awx_collection/test/awx/test_project.py::test_existing_update_not_waited_on_when_wait_false PASSED

(The three pre-existing run_module-based tests in this file fail identically on unmodified main due to an unrelated ansible-core/test-harness incompatibility in exit_json; they are not affected by this change.)

When a project already has an update in progress (most commonly the
automatic update that fires right after an SCM project is created),
wait_for_project_update() polled /project_updates/<id>/ in a tight loop
with no delay until the update finished. The time.sleep(1) sat inside
the is_job_done branch, so it only ran once the job was already done.
The loop also ignored the wait, timeout, and interval parameters.

Route this branch through the same wait_on_url() helper used by the
explicit-update path so the interval and timeout are honored, the API
is not hammered, and wait: false no longer blocks. Changed is now set
from whether the SCM revision actually moved, matching the other path.

This matches the behavior requested upstream in ansible/awx#12850.

Add unit tests covering the wait, unchanged-revision, and wait: false
cases for wait_for_project_update().

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes the awx.awx.project collection module’s wait_for_project_update() behavior when a project already has a sync/update in progress, avoiding a tight/busy polling loop and ensuring user-provided wait, timeout, and interval are respected.

Changes:

  • Replaces the tight polling loop for an in-progress current_update with the existing wait_on_url() helper (interval/timeout-aware and non-busy).
  • Ensures wait: false does not block when an update is already running.
  • Adds unit tests covering the in-progress-update path (including interval/timeout passthrough), unchanged-SCM-revision changed: false, and wait: false non-blocking behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
awx_collection/plugins/modules/project.py Routes the “current update already running” case through wait_on_url() to honor wait/timeout/interval and avoid busy-polling.
awx_collection/test/awx/test_project.py Adds targeted unit tests validating the non-busy wait behavior and correct changed semantics for the in-progress-update branch.

@cigamit
cigamit merged commit 19f1997 into ctrliq:main Jun 14, 2026
@cigamit cigamit self-assigned this Jun 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants