From 06c07edc6f8103a7835a5a7a298a6fc1ed976b0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Sala?= <22398818+adrisala@users.noreply.github.com> Date: Wed, 9 Sep 2026 16:15:48 +0200 Subject: [PATCH] fix: awxkit user creation race condition with gateway sync (#16646) After creating a user on the gateway API, the code immediately queries the controller API to find the synced user. On containerized installs (2.6+), the gateway-to-controller sync may not have completed yet, causing an IndexError when .results.pop() is called on an empty list. This affected ~32 tests across the tower-qa legacy suite on every containerized pipeline run (2.6, 2.7, 2.8). Co-authored-by: Claude Opus 4.6 (1M context) --- awxkit/awxkit/api/pages/users.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/awxkit/awxkit/api/pages/users.py b/awxkit/awxkit/api/pages/users.py index 7b41011bdc..1f31e274cf 100644 --- a/awxkit/awxkit/api/pages/users.py +++ b/awxkit/awxkit/api/pages/users.py @@ -1,5 +1,5 @@ from awxkit.api.mixins import HasCreate, DSAdapter -from awxkit.utils import random_title, PseudoNamespace +from awxkit.utils import random_title, PseudoNamespace, poll_until from awxkit.api.resources import resources from awxkit.config import config @@ -40,8 +40,13 @@ class User(HasCreate, base.Base): # Cleanup controller attributes payload["is_platform_auditor"] = payload.get("is_system_auditor") payload.pop("is_system_auditor") - # Create gw user + # Create gw user, then wait for controller sync gw_user = gw_users_api.post(payload) + poll_until( + lambda: len(ctrl_users_api.get(username=gw_user.username).results) > 0, + interval=1, + timeout=30, + ) user = ctrl_users_api.get(username=gw_user.username).results.pop() user.json["password"] = payload.password self.update_identity(user)