Skip to content

AAP-91782: Make workflow_node_wait wait until approval nodes leave pending - #16642

Open
nikhjain14 wants to merge 1 commit into
ansible:develfrom
nikhjain14:fix-15503-workflow-node-wait
Open

nikhjain14 wants to merge 1 commit into
ansible:develfrom
nikhjain14:fix-15503-workflow-node-wait

Conversation

@nikhjain14

@nikhjain14 nikhjain14 commented Sep 6, 2026

Copy link
Copy Markdown

Summary

workflow_node_wait looks only at event_processing_finished. After a successful launch of an approval node, that field is already true while status is still pending. A wait task then returns ok immediately instead of waiting for approve, deny, or timeout. This change also waits while the job is still new, pending, waiting, or running.

ISSUE TYPE
  • Bug, Docs Fix or other nominal change
COMPONENT NAME
  • Collection

Problem

When awx.awx.workflow_node_wait is used on an approval node (collection 24.3.1+), the first poll sees event_processing_finished: true. The wait loop never runs. The playbook continues while the workflow is still waiting for a human.

Expected behavior

The wait task should stay running until the approval node is approved, denied, or the timeout is reached.

Actual behavior

The wait task returns ok in about 2 seconds with status: pending. Nobody has approved yet.

Solution

In wait_on_url, keep looping while event_processing_finished is false or is_job_done(status) is false. Approve then returns ok. Deny fails the wait. No action hits the timeout. Other job waits are unchanged.

Changes made

  • awx_collection/plugins/module_utils/controller_api.py: wait while the job status is still in progress

Testing Results

  • Unpatched 24.6.1 on lab: wait returned ok in ~2s, status=pending (workflow job 145)
  • Patched: nobody approved → timeout; Approve while waiting → successful; Deny while waiting → wait failed

Related Issue

Fixes #15503

Summary by CodeRabbit

  • Bug Fixes
    • Improved asynchronous operation tracking so status updates continue until the event or job is fully complete.

Approval jobs set event_processing_finished immediately, so wait_on_url
returned before a human approved or denied. Also wait while status is
new/pending/waiting/running (Fixes ansible#15503).

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions github-actions Bot added component:awx_collection issues related to the collection for controlling AWX community labels Sep 6, 2026
@coderabbitai

coderabbitai Bot commented Sep 6, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 2284d061-a71a-473c-ba0b-072ba318eb50

📥 Commits

Reviewing files that changed from the base of the PR and between df97f07 and 1d2ea35.

📒 Files selected for processing (1)
  • awx_collection/plugins/module_utils/controller_api.py

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The change updates wait_on_url so workflow node waits continue polling until event processing finishes and the job reaches a terminal status.

Changes

Workflow node polling

Layer / File(s) Summary
Update workflow polling condition
awx_collection/plugins/module_utils/controller_api.py
wait_on_url now continues polling while the job status remains active, even after event processing finishes.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Merge Risk: ⚪ Minimal · up to 1d2ea

Workflow approval waits now continue until the approval reaches a terminal outcome rather than returning while pending. No merge-blocking risk remains.

Suggested reviewers: therealhaoliu

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The change addresses issue #15503 by continuing to poll while approval-related job statuses remain active, instead of stopping when event_processing_finished is true.
Out of Scope Changes check ✅ Passed The pull request contains one focused change in controller_api.py that directly supports the workflow_node_wait approval-waiting fix.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the primary change: keeping workflow approval nodes waiting until they leave the pending state.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@nikhjain14 nikhjain14 changed the title Make workflow_node_wait wait until approval nodes leave pending AAP-91782: Make workflow_node_wait wait until approval nodes leave pending Sep 6, 2026
@sonarqubecloud

sonarqubecloud Bot commented Sep 6, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
26 New issues
E Maintainability Rating on New Code (required ≥ A)
C Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

if wait_on_field not in result['json']:
wait_on_field = 'finished'
while not result['json'][wait_on_field]:
while (not result['json'][wait_on_field]) or (not self.is_job_done(result['json'].get('status'))):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is kind of a coding nit, formally this is De Morgan’s law

But not (this and that) really is a lot easier to read. I look at this, and I don't know what it's saying.

We require both conditions before we are done with this "wait" method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community component:awx_collection issues related to the collection for controlling AWX

Projects

None yet

Development

Successfully merging this pull request may close these issues.

awx.awx.workflow_node_wait bug

2 participants