mainsequence 9.0.8.dev44__py3-none-any.whl → 9.0.8.dev45__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mainsequence/cli/config.py +3 -7
- mainsequence/client/utils.py +61 -19
- mainsequence/code_repository_context.py +3 -3
- mainsequence/logconf.py +29 -10
- mainsequence/runtime_credential_exchange.py +168 -0
- {mainsequence-9.0.8.dev44.dist-info → mainsequence-9.0.8.dev45.dist-info}/METADATA +1 -1
- {mainsequence-9.0.8.dev44.dist-info → mainsequence-9.0.8.dev45.dist-info}/RECORD +11 -10
- {mainsequence-9.0.8.dev44.dist-info → mainsequence-9.0.8.dev45.dist-info}/WHEEL +0 -0
- {mainsequence-9.0.8.dev44.dist-info → mainsequence-9.0.8.dev45.dist-info}/entry_points.txt +0 -0
- {mainsequence-9.0.8.dev44.dist-info → mainsequence-9.0.8.dev45.dist-info}/licenses/LICENSE +0 -0
- {mainsequence-9.0.8.dev44.dist-info → mainsequence-9.0.8.dev45.dist-info}/top_level.txt +0 -0
mainsequence/cli/config.py
CHANGED
|
@@ -29,6 +29,7 @@ from keyring import core as keyring_core
|
|
|
29
29
|
from keyring import errors as keyring_errors
|
|
30
30
|
|
|
31
31
|
from mainsequence.defaults import CANONICAL_BACKEND_ENV, STANDARD_BACKEND_URL
|
|
32
|
+
from mainsequence.runtime_credential_exchange import runtime_credential_configured
|
|
32
33
|
|
|
33
34
|
APP_NAME = "MainSequenceCLI"
|
|
34
35
|
|
|
@@ -804,13 +805,8 @@ def session_report() -> dict:
|
|
|
804
805
|
refresh_expires_at = token_expiry(refresh)
|
|
805
806
|
|
|
806
807
|
if auth_mode == "runtime_credential":
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
or (
|
|
810
|
-
(os.environ.get("MAINSEQUENCE_RUNTIME_CREDENTIAL_ID") or "").strip()
|
|
811
|
-
and (os.environ.get("MAINSEQUENCE_RUNTIME_CREDENTIAL_SECRET") or "").strip()
|
|
812
|
-
)
|
|
813
|
-
)
|
|
808
|
+
# The credential is an ID with a bootstrap secret or an identity token file.
|
|
809
|
+
authenticated = bool(access or runtime_credential_configured())
|
|
814
810
|
session_expires_at = None
|
|
815
811
|
elif refresh:
|
|
816
812
|
authenticated = refresh_expires_at is None or refresh_expires_at > now
|
mainsequence/client/utils.py
CHANGED
|
@@ -21,6 +21,14 @@ from requests.structures import CaseInsensitiveDict
|
|
|
21
21
|
|
|
22
22
|
from mainsequence.defaults import resolve_backend_endpoint
|
|
23
23
|
from mainsequence.logconf import logger
|
|
24
|
+
from mainsequence.runtime_credential_exchange import (
|
|
25
|
+
RUNTIME_CREDENTIAL_ID_ENV,
|
|
26
|
+
RUNTIME_CREDENTIAL_SECRET_ENV,
|
|
27
|
+
RUNTIME_IDENTITY_TOKEN_FILE_ENV,
|
|
28
|
+
RuntimeIdentityTokenError,
|
|
29
|
+
exchange_runtime_credential,
|
|
30
|
+
identity_token_file_from_environment,
|
|
31
|
+
)
|
|
24
32
|
|
|
25
33
|
from ._transport import DEFAULT_ALLOWED_METHODS as DEFAULT_ALLOWED_METHODS
|
|
26
34
|
from ._transport import DEFAULT_STATUS_FORCELIST as DEFAULT_STATUS_FORCELIST
|
|
@@ -309,6 +317,17 @@ class SessionJWTAuthProvider(BaseAuthProvider):
|
|
|
309
317
|
|
|
310
318
|
@dataclass
|
|
311
319
|
class RuntimeCredentialAuthProvider(BaseAuthProvider):
|
|
320
|
+
"""
|
|
321
|
+
Exchange the runtime credential the platform injected for short-lived access tokens.
|
|
322
|
+
|
|
323
|
+
The proof is the projected workload identity token when
|
|
324
|
+
`MAINSEQUENCE_RUNTIME_IDENTITY_TOKEN_FILE` is set: the file is read for every
|
|
325
|
+
exchange, and `MAINSEQUENCE_RUNTIME_CREDENTIAL_SECRET` is never read or sent.
|
|
326
|
+
Otherwise the proof is that bootstrap secret. The token is never kept on the
|
|
327
|
+
provider. Throttled (`429`) and temporarily unavailable (`503`) exchanges are
|
|
328
|
+
retried within the timeout budget; a rejected one (`401`) fails at once.
|
|
329
|
+
"""
|
|
330
|
+
|
|
312
331
|
credential_id: str | None = None
|
|
313
332
|
credential_secret: str | None = None
|
|
314
333
|
token_url: str | None = None
|
|
@@ -316,13 +335,18 @@ class RuntimeCredentialAuthProvider(BaseAuthProvider):
|
|
|
316
335
|
refresh_skew_seconds: int = 30
|
|
317
336
|
timeout: tuple[float, float] = DEFAULT_TIMEOUT
|
|
318
337
|
expires_at: float | None = None
|
|
338
|
+
identity_token_file: str | None = None
|
|
319
339
|
_lock: threading.RLock = field(default_factory=threading.RLock, init=False, repr=False)
|
|
320
340
|
|
|
321
341
|
def __post_init__(self):
|
|
322
342
|
if self.credential_id is None:
|
|
323
|
-
self.credential_id = os.getenv(
|
|
324
|
-
if self.
|
|
325
|
-
self.
|
|
343
|
+
self.credential_id = os.getenv(RUNTIME_CREDENTIAL_ID_ENV)
|
|
344
|
+
if self.identity_token_file is None:
|
|
345
|
+
self.identity_token_file = identity_token_file_from_environment()
|
|
346
|
+
else:
|
|
347
|
+
self.identity_token_file = str(self.identity_token_file).strip() or None
|
|
348
|
+
if self.credential_secret is None and not self.identity_token_file:
|
|
349
|
+
self.credential_secret = os.getenv(RUNTIME_CREDENTIAL_SECRET_ENV)
|
|
326
350
|
if not self.token_url:
|
|
327
351
|
self.token_url = f"{API_ENDPOINT}/runtime-credentials/token/"
|
|
328
352
|
|
|
@@ -344,20 +368,48 @@ class RuntimeCredentialAuthProvider(BaseAuthProvider):
|
|
|
344
368
|
|
|
345
369
|
return exp <= int(time.time()) + self.refresh_skew_seconds
|
|
346
370
|
|
|
347
|
-
|
|
371
|
+
@staticmethod
|
|
372
|
+
def _log_exchange_retry(status: int, delay: float) -> None:
|
|
373
|
+
logger.warning(f"Runtime credential exchange returned {status}; retrying in {delay:.1f} s.")
|
|
374
|
+
|
|
375
|
+
def _exchange(self) -> requests.Response:
|
|
348
376
|
credential_id = (self.credential_id or "").strip()
|
|
349
|
-
|
|
377
|
+
identity_token_file = self.identity_token_file
|
|
378
|
+
credential_secret = None if identity_token_file else (self.credential_secret or "").strip()
|
|
350
379
|
if not credential_id:
|
|
351
380
|
raise AuthError(
|
|
352
381
|
"MAINSEQUENCE_RUNTIME_CREDENTIAL_ID is required when "
|
|
353
382
|
"MAINSEQUENCE_AUTH_MODE=runtime_credential."
|
|
354
383
|
)
|
|
355
|
-
if not credential_secret:
|
|
384
|
+
if not identity_token_file and not credential_secret:
|
|
356
385
|
raise AuthError(
|
|
357
386
|
"MAINSEQUENCE_RUNTIME_CREDENTIAL_SECRET is required when "
|
|
358
|
-
"MAINSEQUENCE_AUTH_MODE=runtime_credential
|
|
387
|
+
"MAINSEQUENCE_AUTH_MODE=runtime_credential and "
|
|
388
|
+
f"{RUNTIME_IDENTITY_TOKEN_FILE_ENV} is not set."
|
|
359
389
|
)
|
|
360
|
-
|
|
390
|
+
try:
|
|
391
|
+
# One budget for every attempt and wait, inside the caller's budget if any.
|
|
392
|
+
with request_budget(self.timeout) as budget:
|
|
393
|
+
|
|
394
|
+
def post(body: dict[str, str]) -> requests.Response:
|
|
395
|
+
return requests.post(
|
|
396
|
+
self.token_url,
|
|
397
|
+
json=body,
|
|
398
|
+
headers={"Content-Type": "application/json"},
|
|
399
|
+
timeout=budget.timeout(),
|
|
400
|
+
allow_redirects=False,
|
|
401
|
+
)
|
|
402
|
+
|
|
403
|
+
return exchange_runtime_credential(
|
|
404
|
+
post,
|
|
405
|
+
credential_id=credential_id,
|
|
406
|
+
credential_secret=credential_secret,
|
|
407
|
+
identity_token_file=identity_token_file,
|
|
408
|
+
deadline=budget.deadline,
|
|
409
|
+
on_retry=self._log_exchange_retry,
|
|
410
|
+
)
|
|
411
|
+
except RuntimeIdentityTokenError as exc:
|
|
412
|
+
raise AuthError(str(exc)) from None
|
|
361
413
|
|
|
362
414
|
def refresh(
|
|
363
415
|
self,
|
|
@@ -370,17 +422,7 @@ class RuntimeCredentialAuthProvider(BaseAuthProvider):
|
|
|
370
422
|
if not force and not self._needs_exchange():
|
|
371
423
|
return
|
|
372
424
|
|
|
373
|
-
|
|
374
|
-
response = requests.post(
|
|
375
|
-
self.token_url,
|
|
376
|
-
json={
|
|
377
|
-
"credential_id": credential_id,
|
|
378
|
-
"credential_secret": credential_secret,
|
|
379
|
-
},
|
|
380
|
-
headers={"Content-Type": "application/json"},
|
|
381
|
-
timeout=remaining_timeout(self.timeout),
|
|
382
|
-
allow_redirects=False,
|
|
383
|
-
)
|
|
425
|
+
response = self._exchange()
|
|
384
426
|
if response.status_code < 200 or response.status_code >= 300:
|
|
385
427
|
raise AuthError(
|
|
386
428
|
f"Runtime credential exchange failed with status {response.status_code}."
|
|
@@ -10,6 +10,8 @@ from dataclasses import dataclass, replace
|
|
|
10
10
|
from typing import Any, Literal
|
|
11
11
|
from urllib.parse import urlsplit
|
|
12
12
|
|
|
13
|
+
from mainsequence.runtime_credential_exchange import runtime_credential_configured
|
|
14
|
+
|
|
13
15
|
CodeRepositoryContextStatus = Literal[
|
|
14
16
|
"resolved",
|
|
15
17
|
"code_repository_branch_not_registered",
|
|
@@ -204,9 +206,7 @@ def _exchange_authenticated_runtime_context_if_configured() -> None:
|
|
|
204
206
|
return
|
|
205
207
|
if (os.getenv("MAINSEQUENCE_AUTH_MODE") or "").strip().lower() != "runtime_credential":
|
|
206
208
|
return
|
|
207
|
-
if not (
|
|
208
|
-
return
|
|
209
|
-
if not (os.getenv("MAINSEQUENCE_RUNTIME_CREDENTIAL_SECRET") or "").strip():
|
|
209
|
+
if not runtime_credential_configured():
|
|
210
210
|
return
|
|
211
211
|
|
|
212
212
|
from mainsequence.client.utils import AuthError, loaders
|
mainsequence/logconf.py
CHANGED
|
@@ -5,6 +5,7 @@ import logging
|
|
|
5
5
|
import logging.config
|
|
6
6
|
import os
|
|
7
7
|
import sys
|
|
8
|
+
import time
|
|
8
9
|
import traceback
|
|
9
10
|
from collections.abc import Mapping
|
|
10
11
|
from importlib.metadata import PackageNotFoundError
|
|
@@ -22,6 +23,13 @@ from structlog.stdlib import BoundLogger
|
|
|
22
23
|
from .defaults import resolve_backend_endpoint
|
|
23
24
|
from .instrumentation import OTelJSONRenderer
|
|
24
25
|
from .repository_identity_security import UNSUPPORTED_SOURCE_IDENTITY_ENV_NAMES
|
|
26
|
+
from .runtime_credential_exchange import (
|
|
27
|
+
RUNTIME_CREDENTIAL_ID_ENV,
|
|
28
|
+
RUNTIME_CREDENTIAL_SECRET_ENV,
|
|
29
|
+
exchange_runtime_credential,
|
|
30
|
+
identity_token_file_from_environment,
|
|
31
|
+
runtime_credential_configured,
|
|
32
|
+
)
|
|
25
33
|
from .runtime_flags import is_running_in_pod
|
|
26
34
|
|
|
27
35
|
logger = None
|
|
@@ -94,20 +102,31 @@ def _request_job_startup_state(*, timeout_s: float = 10.0) -> dict[str, Any]:
|
|
|
94
102
|
return headers, False
|
|
95
103
|
|
|
96
104
|
def _exchange_runtime_credential() -> bool:
|
|
97
|
-
|
|
98
|
-
credential_secret = (os.getenv("MAINSEQUENCE_RUNTIME_CREDENTIAL_SECRET") or "").strip()
|
|
99
|
-
if not credential_id or not credential_secret:
|
|
105
|
+
if not runtime_credential_configured():
|
|
100
106
|
return False
|
|
107
|
+
identity_token_file = identity_token_file_from_environment()
|
|
108
|
+
token_url = f"{_backend_base_url()}/api/v1/runtime-credentials/token/"
|
|
101
109
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
110
|
+
def _post(body: dict[str, str]) -> requests.Response:
|
|
111
|
+
return requests.post(
|
|
112
|
+
token_url,
|
|
105
113
|
headers={"Content-Type": "application/json"},
|
|
106
|
-
json=
|
|
107
|
-
"credential_id": credential_id,
|
|
108
|
-
"credential_secret": credential_secret,
|
|
109
|
-
},
|
|
114
|
+
json=body,
|
|
110
115
|
timeout=timeout_s,
|
|
116
|
+
allow_redirects=False,
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
try:
|
|
120
|
+
token_resp = exchange_runtime_credential(
|
|
121
|
+
_post,
|
|
122
|
+
credential_id=(os.getenv(RUNTIME_CREDENTIAL_ID_ENV) or "").strip(),
|
|
123
|
+
credential_secret=(
|
|
124
|
+
None
|
|
125
|
+
if identity_token_file
|
|
126
|
+
else (os.getenv(RUNTIME_CREDENTIAL_SECRET_ENV) or "").strip()
|
|
127
|
+
),
|
|
128
|
+
identity_token_file=identity_token_file,
|
|
129
|
+
deadline=time.monotonic() + timeout_s,
|
|
111
130
|
)
|
|
112
131
|
except Exception:
|
|
113
132
|
return False
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"""
|
|
2
|
+
The runtime credential exchange, shared by the auth provider and the logger.
|
|
3
|
+
|
|
4
|
+
A runtime started with ``MAINSEQUENCE_AUTH_MODE=runtime_credential`` exchanges its
|
|
5
|
+
credential at ``POST /api/v1/runtime-credentials/token/`` for a short-lived access
|
|
6
|
+
token. The request carries ``credential_id`` and exactly one proof:
|
|
7
|
+
|
|
8
|
+
* ``workload_identity_token`` when ``MAINSEQUENCE_RUNTIME_IDENTITY_TOKEN_FILE`` is
|
|
9
|
+
set: the projected token read from that file for every exchange, because the
|
|
10
|
+
file is rotated. The bootstrap secret is then never read or sent, and a missing,
|
|
11
|
+
unreadable or empty file is an error, never a fallback to the secret.
|
|
12
|
+
* ``credential_secret`` otherwise: ``MAINSEQUENCE_RUNTIME_CREDENTIAL_SECRET``.
|
|
13
|
+
|
|
14
|
+
The token exists only inside one exchange request. It is not kept on any object,
|
|
15
|
+
written to the environment or a file, logged, or included in an error message.
|
|
16
|
+
|
|
17
|
+
The logger exchanges a runtime credential while it is being configured, so this
|
|
18
|
+
module imports nothing from the SDK.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
from __future__ import annotations
|
|
22
|
+
|
|
23
|
+
import os
|
|
24
|
+
import time
|
|
25
|
+
from collections.abc import Callable
|
|
26
|
+
from typing import Any
|
|
27
|
+
|
|
28
|
+
from urllib3.exceptions import InvalidHeader
|
|
29
|
+
from urllib3.util import Retry
|
|
30
|
+
|
|
31
|
+
RUNTIME_CREDENTIAL_ID_ENV = "MAINSEQUENCE_RUNTIME_CREDENTIAL_ID"
|
|
32
|
+
RUNTIME_CREDENTIAL_SECRET_ENV = "MAINSEQUENCE_RUNTIME_CREDENTIAL_SECRET"
|
|
33
|
+
RUNTIME_IDENTITY_TOKEN_FILE_ENV = "MAINSEQUENCE_RUNTIME_IDENTITY_TOKEN_FILE"
|
|
34
|
+
|
|
35
|
+
# 429: the exchange is throttled. 503: verification is temporarily unavailable.
|
|
36
|
+
# Neither exchanged anything, so the same request may be sent again.
|
|
37
|
+
RETRYABLE_EXCHANGE_STATUSES = frozenset({429, 503})
|
|
38
|
+
EXCHANGE_RETRIES = 3
|
|
39
|
+
EXCHANGE_BACKOFF_FACTOR = 0.5
|
|
40
|
+
|
|
41
|
+
_RETRY_AFTER = Retry(total=0)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class RuntimeIdentityTokenError(Exception):
|
|
45
|
+
"""The runtime identity token file cannot be used. The message never holds its content."""
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def _environment_value(name: str) -> str:
|
|
49
|
+
return (os.getenv(name) or "").strip()
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def identity_token_file_from_environment() -> str | None:
|
|
53
|
+
"""Return the path in ``MAINSEQUENCE_RUNTIME_IDENTITY_TOKEN_FILE``, or None when unset."""
|
|
54
|
+
return _environment_value(RUNTIME_IDENTITY_TOKEN_FILE_ENV) or None
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def runtime_credential_configured() -> bool:
|
|
58
|
+
"""
|
|
59
|
+
Say whether the environment holds a runtime credential to exchange.
|
|
60
|
+
|
|
61
|
+
That is a credential ID and one proof: the identity token file, or else the
|
|
62
|
+
bootstrap secret. Only the presence of the setting is checked. The token file
|
|
63
|
+
is read by the exchange itself, which reports a missing or empty file.
|
|
64
|
+
"""
|
|
65
|
+
if not _environment_value(RUNTIME_CREDENTIAL_ID_ENV):
|
|
66
|
+
return False
|
|
67
|
+
if identity_token_file_from_environment():
|
|
68
|
+
return True
|
|
69
|
+
return bool(_environment_value(RUNTIME_CREDENTIAL_SECRET_ENV))
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def _read_identity_token(path: str) -> str:
|
|
73
|
+
source = f"The runtime identity token file {path} ({RUNTIME_IDENTITY_TOKEN_FILE_ENV})"
|
|
74
|
+
try:
|
|
75
|
+
with open(path, "rb") as token_file:
|
|
76
|
+
raw = token_file.read()
|
|
77
|
+
except FileNotFoundError:
|
|
78
|
+
raise RuntimeIdentityTokenError(f"{source} does not exist.") from None
|
|
79
|
+
except OSError as exc:
|
|
80
|
+
raise RuntimeIdentityTokenError(
|
|
81
|
+
f"{source} could not be read ({type(exc).__name__})."
|
|
82
|
+
) from None
|
|
83
|
+
try:
|
|
84
|
+
token = raw.decode("utf-8").strip()
|
|
85
|
+
except UnicodeDecodeError:
|
|
86
|
+
# Raised below, outside this handler: the decode error holds the bytes.
|
|
87
|
+
token = None
|
|
88
|
+
if token is None:
|
|
89
|
+
raise RuntimeIdentityTokenError(f"{source} does not hold a token.")
|
|
90
|
+
if not token:
|
|
91
|
+
raise RuntimeIdentityTokenError(f"{source} is empty.")
|
|
92
|
+
return token
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def _request_body(
|
|
96
|
+
credential_id: str,
|
|
97
|
+
credential_secret: str | None,
|
|
98
|
+
identity_token_file: str | None,
|
|
99
|
+
) -> dict[str, str]:
|
|
100
|
+
if identity_token_file:
|
|
101
|
+
return {
|
|
102
|
+
"credential_id": credential_id,
|
|
103
|
+
"workload_identity_token": _read_identity_token(identity_token_file),
|
|
104
|
+
}
|
|
105
|
+
return {"credential_id": credential_id, "credential_secret": credential_secret or ""}
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def _retry_delay(response: Any, attempt: int) -> float:
|
|
109
|
+
delay = min(EXCHANGE_BACKOFF_FACTOR * 2**attempt, Retry.DEFAULT_BACKOFF_MAX)
|
|
110
|
+
retry_after = (getattr(response, "headers", None) or {}).get("Retry-After")
|
|
111
|
+
if retry_after is not None:
|
|
112
|
+
try:
|
|
113
|
+
delay = max(delay, _RETRY_AFTER.parse_retry_after(str(retry_after)))
|
|
114
|
+
except InvalidHeader:
|
|
115
|
+
pass
|
|
116
|
+
return delay
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def exchange_runtime_credential(
|
|
120
|
+
send: Callable[[dict[str, str]], Any],
|
|
121
|
+
*,
|
|
122
|
+
credential_id: str,
|
|
123
|
+
credential_secret: str | None,
|
|
124
|
+
identity_token_file: str | None,
|
|
125
|
+
deadline: float,
|
|
126
|
+
on_retry: Callable[[int, float], None] | None = None,
|
|
127
|
+
) -> Any:
|
|
128
|
+
"""
|
|
129
|
+
Send one runtime credential exchange and return the last response.
|
|
130
|
+
|
|
131
|
+
Parameters
|
|
132
|
+
----------
|
|
133
|
+
send:
|
|
134
|
+
Posts the JSON body it is given to the exchange route and returns the
|
|
135
|
+
response. It is called once per attempt.
|
|
136
|
+
credential_id:
|
|
137
|
+
The runtime credential ID.
|
|
138
|
+
credential_secret:
|
|
139
|
+
The bootstrap secret. Ignored when ``identity_token_file`` is set.
|
|
140
|
+
identity_token_file:
|
|
141
|
+
The projected token file. It is read again for every attempt.
|
|
142
|
+
deadline:
|
|
143
|
+
``time.monotonic()`` value after which no retry starts.
|
|
144
|
+
on_retry:
|
|
145
|
+
Called with the status and the delay before each retry.
|
|
146
|
+
|
|
147
|
+
A ``429`` or ``503`` answer is retried up to ``EXCHANGE_RETRIES`` times. The
|
|
148
|
+
wait is the exponential backoff or the answer's ``Retry-After``, whichever is
|
|
149
|
+
longer; a wait that would not end before ``deadline`` ends the retries. Any
|
|
150
|
+
other answer, ``401`` included, is returned at once and the proof is never
|
|
151
|
+
switched. ``RuntimeIdentityTokenError`` is raised when the token file cannot
|
|
152
|
+
be used.
|
|
153
|
+
"""
|
|
154
|
+
for attempt in range(EXCHANGE_RETRIES + 1):
|
|
155
|
+
response = send(_request_body(credential_id, credential_secret, identity_token_file))
|
|
156
|
+
status = response.status_code
|
|
157
|
+
if status not in RETRYABLE_EXCHANGE_STATUSES or attempt == EXCHANGE_RETRIES:
|
|
158
|
+
return response
|
|
159
|
+
delay = _retry_delay(response, attempt)
|
|
160
|
+
if delay >= deadline - time.monotonic():
|
|
161
|
+
return response
|
|
162
|
+
if on_retry is not None:
|
|
163
|
+
on_retry(status, delay)
|
|
164
|
+
close = getattr(response, "close", None)
|
|
165
|
+
if callable(close):
|
|
166
|
+
close()
|
|
167
|
+
time.sleep(delay)
|
|
168
|
+
raise AssertionError("Unreachable retry state")
|
|
@@ -12,11 +12,12 @@ mainsequence/__init__.py,sha256=70CbIo7ZG1mzi5uwkqDtVESunBE0RanHjeFg4ptfsA0,385
|
|
|
12
12
|
mainsequence/__main__.py,sha256=KuAP69uduS2ImrPIgNMzbGBRepZzjqvUONu5vFh4v4A,176
|
|
13
13
|
mainsequence/_request_identity.py,sha256=jiroPFVDM8vphEf9VXuggQJKUOGohfk7-pDwJSOILEw,1211
|
|
14
14
|
mainsequence/bootstrap.py,sha256=AvG55Y46RcshVqJZsyqvUDN62CJg4CDbHu0Bvsbwfzs,2910
|
|
15
|
-
mainsequence/code_repository_context.py,sha256=
|
|
15
|
+
mainsequence/code_repository_context.py,sha256=JRrWjwpnUy8I-OjSd9hHlrcq8-Ow3Zeh_N6cYvmtA3o,28545
|
|
16
16
|
mainsequence/code_repository_skills.py,sha256=AyC1HFAxQXHXNBGbarVUJS2cHd4X5HwDx6u8XBophbE,23611
|
|
17
17
|
mainsequence/defaults.py,sha256=5r6s7AI-X40rpm1D3IgcNsWam7iJg4_lIxB3F_1u2z0,408
|
|
18
|
-
mainsequence/logconf.py,sha256=
|
|
18
|
+
mainsequence/logconf.py,sha256=RonnNIbUAP5IPdbYUHiuqBeWvRtHb5pj2YtWzHluEE4,19295
|
|
19
19
|
mainsequence/repository_identity_security.py,sha256=Cdywndhiy1zJFUPh-FfM90RjZ3Hg3tjhxBr64FRhmXs,1035
|
|
20
|
+
mainsequence/runtime_credential_exchange.py,sha256=US368h7_KKorqW9yeRtIhk_Du9xjs2XNgml21dEGcLk,6428
|
|
20
21
|
mainsequence/runtime_flags.py,sha256=1eTM7VRRhnuZ_GXcmFhqAmdEKwyQYMyZcPsio88vJRQ,378
|
|
21
22
|
mainsequence/scaffold_skills.py,sha256=k0V6eKC5AwbHr9wB9UGMJNF-8eJ0_1izF4-BU01KHrg,10606
|
|
22
23
|
mainsequence/cli/__init__.py,sha256=sMWTnomCaISjnureLuXFRqOzkH2Y77uYEivsd-M6_8Y,28
|
|
@@ -24,7 +25,7 @@ mainsequence/cli/api.py,sha256=emn5UsIpQ0qvGLnW7MpNPYenQZjR4NJ6SGDKmLo6gHk,12740
|
|
|
24
25
|
mainsequence/cli/browser_auth.py,sha256=C-Sbpt0Pr9Pv3Z9dO80TMk7zPcaaZ-4zvW0tbRVMrTU,9863
|
|
25
26
|
mainsequence/cli/cli.py,sha256=zo3ptVxluTYAIeIAluGQPwgFY-_vr0SO3BthCGuVK-0,268962
|
|
26
27
|
mainsequence/cli/code_repository_status.py,sha256=SHEnU8YSWFowPG6dEdE4Yd8CS1tIcJSE1MXFLfvD3Os,5975
|
|
27
|
-
mainsequence/cli/config.py,sha256=
|
|
28
|
+
mainsequence/cli/config.py,sha256=Q4aGhSLxSeSjX2HqGgPDGg9kNAvrLhIBzWUJ-pY4lPg,45567
|
|
28
29
|
mainsequence/cli/docker_utils.py,sha256=eAnp9MI042cHWwKasA5IF2I7INL3A6tV2JX-cSIe7rc,10687
|
|
29
30
|
mainsequence/cli/doctor.py,sha256=_1XHd72jheRDt7dEJHd6hbBSSpCPpMwwFDUOLcdkii8,4550
|
|
30
31
|
mainsequence/cli/local_ops.py,sha256=15XzdIxooWqUYgWDnKB81KCmXrCdYd3AGCVazVHD1MQ,4363
|
|
@@ -46,16 +47,16 @@ mainsequence/client/models_foundry.py,sha256=iN1jJzDokfniEQF0Ac5eepAB7L5pVjJnKav
|
|
|
46
47
|
mainsequence/client/models_helpers.py,sha256=y7cgcsH8yO3dfIWPhRdcYam7ItWHw3Ps63-WYDe4YHE,46262
|
|
47
48
|
mainsequence/client/models_user.py,sha256=co9uhe-LKkt7Kw5u8-wDMWcp0yL_lS2LuUOyauW5KF0,38557
|
|
48
49
|
mainsequence/client/observability.py,sha256=_WrDKCaNk_TXmKElKCXC1inork6Exxxe8FRY4m1GI9s,16008
|
|
49
|
-
mainsequence/client/utils.py,sha256=
|
|
50
|
+
mainsequence/client/utils.py,sha256=wg0tSaAe9R4-LD75_A-G9pf5p43kXZWRqXo6sHL8Q0Y,32123
|
|
50
51
|
mainsequence/client/value_sets.py,sha256=7TA-mpuAd3hOduNgO1WTQQTuNOGaFgue-VqCsDWKaC8,6181
|
|
51
52
|
mainsequence/instrumentation/__init__.py,sha256=J_9XmfjprElvz0u2t9rTyJT0kFdyKpxdbkdQiaw28_U,316
|
|
52
53
|
mainsequence/instrumentation/utils.py,sha256=b-ihjSioAepeLfMpudM2SqCtvnxMqIXileHx3klBCQU,3377
|
|
53
54
|
mainsequence/server/__init__.py,sha256=BHUAhtdWPDRdxX07NYO_6wrBv5mf0GsXflecO52PmUc,73
|
|
54
55
|
mainsequence/server/caller_assertions.py,sha256=f9jHhVeoFK1ScDCmW8h3lEIU5V7zKw70SUSVV2P7wUI,10975
|
|
55
56
|
mainsequence/server/fastapi.py,sha256=Y5QB51CRVbuUVRUcWh5GKQ5b5vMPjbs9scioTt684oQ,10712
|
|
56
|
-
mainsequence-9.0.8.
|
|
57
|
-
mainsequence-9.0.8.
|
|
58
|
-
mainsequence-9.0.8.
|
|
59
|
-
mainsequence-9.0.8.
|
|
60
|
-
mainsequence-9.0.8.
|
|
61
|
-
mainsequence-9.0.8.
|
|
57
|
+
mainsequence-9.0.8.dev45.dist-info/licenses/LICENSE,sha256=b6Ecsk8wjsEby3lbSzdljR6hHiFGHBizt9iWV2p1c_I,1074
|
|
58
|
+
mainsequence-9.0.8.dev45.dist-info/METADATA,sha256=z8ETo9B0eKLTBZxqULrm9ZNkbehM-ObnGFdieIR5WjA,7402
|
|
59
|
+
mainsequence-9.0.8.dev45.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
60
|
+
mainsequence-9.0.8.dev45.dist-info/entry_points.txt,sha256=XGAOq3-mF2lWWpeRJvoaWyMarRcK167mH1g124aGdUs,88
|
|
61
|
+
mainsequence-9.0.8.dev45.dist-info/top_level.txt,sha256=BFeblM_Q9q0cUWBvTxnfWcWQEHtf5XZi9nOS-Gdfwus,28
|
|
62
|
+
mainsequence-9.0.8.dev45.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|