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) <noreply@anthropic.com>
This commit is contained in:
Adrià Sala
2026-09-09 16:15:48 +02:00
committed by GitHub
co-authored by Claude Opus 4.6
parent c0a83697d5
commit 06c07edc6f
+7 -2
View File
@@ -1,5 +1,5 @@
from awxkit.api.mixins import HasCreate, DSAdapter 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.api.resources import resources
from awxkit.config import config from awxkit.config import config
@@ -40,8 +40,13 @@ class User(HasCreate, base.Base):
# Cleanup controller attributes # Cleanup controller attributes
payload["is_platform_auditor"] = payload.get("is_system_auditor") payload["is_platform_auditor"] = payload.get("is_system_auditor")
payload.pop("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) 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 = ctrl_users_api.get(username=gw_user.username).results.pop()
user.json["password"] = payload.password user.json["password"] = payload.password
self.update_identity(user) self.update_identity(user)