|
15 | 15 | import sys |
16 | 16 | import time |
17 | 17 |
|
| 18 | +from datetime import datetime, timezone |
18 | 19 | from get_testing_resources import get_testing_credentials, get_managed_test_resource_outputs # type: ignore[import-not-found] # noqa: E402 |
19 | 20 |
|
20 | 21 | from boto3.session import Session |
@@ -103,12 +104,28 @@ def setup_credentials(): |
103 | 104 | mask_value(value) |
104 | 105 | write_env(f"CI_ACCESS_ROLE_{env_key}", value) |
105 | 106 |
|
106 | | - # Get test credentials |
107 | | - try: |
108 | | - env_vars = get_testing_credentials(skip_role_deletion=True) |
109 | | - except Exception: |
110 | | - print("First attempt with skip_role_deletion failed, trying without parameter...") |
111 | | - env_vars = get_testing_credentials(skip_role_deletion=False) |
| 107 | + # Log system clock for debugging InvalidSignatureException on Windows |
| 108 | + print(f"[DEBUG] System clock UTC: {datetime.now(timezone.utc).isoformat()}") |
| 109 | + |
| 110 | + # Get test credentials with retry for transient OIDC propagation issues |
| 111 | + max_retries = 3 |
| 112 | + for attempt in range(1, max_retries + 1): |
| 113 | + try: |
| 114 | + try: |
| 115 | + env_vars = get_testing_credentials(skip_role_deletion=True) |
| 116 | + except Exception: |
| 117 | + print("First attempt with skip_role_deletion failed, trying without parameter...") |
| 118 | + env_vars = get_testing_credentials(skip_role_deletion=False) |
| 119 | + break |
| 120 | + except Exception as e: |
| 121 | + if attempt < max_retries: |
| 122 | + print(f"Credential fetch attempt {attempt}/{max_retries} failed: {e}", file=sys.stderr) |
| 123 | + print(f"[DEBUG] System clock UTC: {datetime.now(timezone.utc).isoformat()}") |
| 124 | + print(f"Retrying in 5s...") |
| 125 | + time.sleep(5) |
| 126 | + else: |
| 127 | + print(f"FATAL: Failed to get credentials after {max_retries} attempts.", file=sys.stderr) |
| 128 | + raise |
112 | 129 |
|
113 | 130 | # Get managed test resources |
114 | 131 | test_session = Session( |
|
0 commit comments