fix: retry LookupAccountName with exponential backoff to prevent ERROR_NONE_MAPPED on fresh EC2 instances - #262
Conversation
…ttributes
When CodeBuild Windows integration tests run with LOGNAME=SYSTEM, getpass.getuser()
returns "SYSTEM" and the subsequent LookupAccountName("", "SYSTEM") call fails with
ERROR_NONE_MAPPED (1332) on freshly started reserved-fleet EC2 instances because the
LSA service hasn't finished initializing.
SYSTEM (S-1-5-18) is a well-known SID constant that never varies across Windows
machines. Use ConvertStringSidToSid("S-1-5-18") to bypass the LSA lookup entirely,
consistent with how the network SID (S-1-5-2) is already handled in the same method.
Fixes intermittent Windows integration test failures in deadline-cloud-for-cinema-4d
and 6 other DCC repos that share the LOGNAME=SYSTEM CodeBuild workaround.
Signed-off-by: leon-li-inspire <2182521+leon-li-inspire@users.noreply.github.com>
bc7b020 to
1dbca63
Compare
Signed-off-by: Leon Li <2182521+leon-li-inspire@users.noreply.github.com>
Head branch was pushed to by a user without write access
|
Pushed a formatting fix (commit 1735af2) — |
LookupAccountName mock must return a real PySID object (not a string) because downstream code passes it to dacl.AddAccessAllowedAce() which validates the type on Windows. Signed-off-by: Leon Li <2182521+leon-li-inspire@users.noreply.github.com>
|
Pushed another fix (commit 617a7c9) — the Windows tests were failing because the mock returned a string The CI runs need maintainer approval again — could someone please approve the pending workflow runs? |
Signed-off-by: Leon Li <2182521+leon-li-inspire@users.noreply.github.com>
Head branch was pushed to by a user without write access
| ): | ||
| named_pipe_helper.NamedPipeHelper.generate_pipe_name("AdaptorTest") | ||
|
|
||
| @patch("getpass.getuser", return_value="regularuser") |
There was a problem hiding this comment.
we will need to port this to openjd-rs too!
…MAPPED LookupAccountNameW fails intermittently with ERROR_NONE_MAPPED (1332) on freshly started EC2 instances where the LSA service hasn't finished initializing. Add retry with exponential backoff (up to 3 attempts, sleeping 1s then 2s) to the lookup_sid() function, then re-raise if all attempts are exhausted. This is the Rust equivalent of the Python fix in OpenJobDescription/openjd-adaptor-runtime-for-python#262 which addresses the same intermittent failure in Windows integration tests across all DCC repos that use LOGNAME=SYSTEM in their CodeBuild Windows environment. Signed-off-by: Leon Li <2182521+leon-li-inspire@users.noreply.github.com>
…MAPPED LookupAccountNameW fails intermittently with ERROR_NONE_MAPPED (1332) on freshly started EC2 instances where the LSA service hasn't finished initializing. Add retry with exponential backoff (up to 3 attempts, sleeping 1s then 2s) to the lookup_sid() function, then re-raise if all attempts are exhausted. This is the Rust equivalent of the Python fix in OpenJobDescription/openjd-adaptor-runtime-for-python#262 which addresses the same intermittent failure in Windows integration tests across all DCC repos that use LOGNAME=SYSTEM in their CodeBuild Windows environment. Signed-off-by: Leon Li <2182521+leon-li-inspire@users.noreply.github.com>
…MAPPED LookupAccountNameW fails intermittently with ERROR_NONE_MAPPED (1332) on freshly started EC2 instances where the LSA service hasn't finished initializing. Add retry with exponential backoff (up to 3 attempts, sleeping 1s then 2s) to the lookup_sid() function, then re-raise if all attempts are exhausted. This is the Rust equivalent of the Python fix in OpenJobDescription/openjd-adaptor-runtime-for-python#262 which addresses the same intermittent failure in Windows integration tests across all DCC repos that use LOGNAME=SYSTEM in their CodeBuild Windows environment. Signed-off-by: Leon Li <2182521+leon-li-inspire@users.noreply.github.com>
…MAPPED LookupAccountNameW fails intermittently with ERROR_NONE_MAPPED (1332) on freshly started EC2 instances where the LSA service hasn't finished initializing. Add retry with exponential backoff (up to 3 attempts, sleeping 1s then 2s) to the lookup_sid() function, then re-raise if all attempts are exhausted. This is the Rust equivalent of the Python fix in OpenJobDescription/openjd-adaptor-runtime-for-python#262 which addresses the same intermittent failure in Windows integration tests across all DCC repos that use LOGNAME=SYSTEM in their CodeBuild Windows environment. Signed-off-by: Leon Li <2182521+leon-li-inspire@users.noreply.github.com>
…MAPPED (#221) * fix: retry LookupAccountNameW with exponential backoff on ERROR_NONE_MAPPED LookupAccountNameW fails intermittently with ERROR_NONE_MAPPED (1332) on freshly started EC2 instances where the LSA service hasn't finished initializing. Add retry with exponential backoff (up to 3 attempts, sleeping 1s then 2s) to the lookup_sid() function, then re-raise if all attempts are exhausted. This is the Rust equivalent of the Python fix in OpenJobDescription/openjd-adaptor-runtime-for-python#262 which addresses the same intermittent failure in Windows integration tests across all DCC repos that use LOGNAME=SYSTEM in their CodeBuild Windows environment. Signed-off-by: Leon Li <2182521+leon-li-inspire@users.noreply.github.com> * fix: gate LookupAccountNameW retry on LSA-not-ready to avoid penalizing unmapped names ERROR_NONE_MAPPED (1332) is overloaded: Windows returns it both when the LSA service is still initializing (transient, only at instance startup) and when a name genuinely does not map to an account (permanent). The previous retry fired on every 1332, so steady-state lookups of a non-existent principal — notably the WindowsSessionUser::is_process_user fallback path — blocked for ~3s before returning, a regression for a path that previously returned immediately. Gate the backoff on a process-global LSA-availability check: once any lookup succeeds (or a probe of the current process user resolves), the LSA is known to be up and a subsequent 1332 must mean the name is unmapped, so it fails fast. The LSA never restarts within a process lifetime, so the result is cached. Update test_lookup_sid_fails_for_nonexistent_user accordingly: it now asserts the unmappable-name lookup fails fast (<1s) once LSA is confirmed up, instead of asserting the old >=3s backoff. Signed-off-by: Leon Li <2182521+leon-li-inspire@users.noreply.github.com> --------- Signed-off-by: Leon Li <2182521+leon-li-inspire@users.noreply.github.com>
Summary
create_security_attributes()callswin32security.LookupAccountName("", username)to resolve the current user's SID for named pipe access controlpywintypes.error: (1332, 'LookupAccountName', 'No mapping between account names and security IDs was done.')on freshly started EC2 instances where the LSA (Local Security Authority) service has not finished initializingAffected repos
Fixes intermittent Windows integration test failures in all DCC repos that use
LOGNAME=SYSTEMin their CodeBuild Windows environment: Cinema 4D, Blender, Houdini, Maya, 3ds Max, VRED, and Unreal Engine.Related ticket: https://t.corp.amazon.com/P447504169
Test plan
test_create_security_attributes_uses_lookup: verifiesLookupAccountNameis called with the current usernametest_create_security_attributes_retries_on_lsa_not_ready: verifies retry succeeds after a transient 1332 error, with correct backoff sleeptest_create_security_attributes_raises_after_max_retries: verifies the original error is re-raised after exhausting all retries