foxops 2.9.0__tar.gz → 2.10.0__tar.gz
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.
- {foxops-2.9.0 → foxops-2.10.0}/PKG-INFO +2 -1
- {foxops-2.9.0 → foxops-2.10.0}/pyproject.toml +4 -1
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/errors.py +4 -0
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/hosters/gitlab.py +92 -13
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/logger.py +8 -1
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/services/change.py +5 -0
- {foxops-2.9.0 → foxops-2.10.0}/LICENSE +0 -0
- {foxops-2.9.0 → foxops-2.10.0}/README.md +0 -0
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/__init__.py +0 -0
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/__main__.py +0 -0
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/database/__init__.py +0 -0
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/database/engine.py +0 -0
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/database/repositories/__init__.py +0 -0
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/database/repositories/change/__init__.py +0 -0
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/database/repositories/change/errors.py +0 -0
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/database/repositories/change/model.py +0 -0
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/database/repositories/change/repository.py +0 -0
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/database/repositories/incarnation/__init__.py +0 -0
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/database/repositories/incarnation/errors.py +0 -0
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/database/repositories/incarnation/model.py +0 -0
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/database/repositories/incarnation/repository.py +0 -0
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/database/schema.py +0 -0
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/dependencies.py +0 -0
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/engine/__init__.py +0 -0
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/engine/__main__.py +0 -0
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/engine/custom_filters.py +0 -0
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/engine/errors.py +0 -0
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/engine/initialization.py +0 -0
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/engine/models/__init__.py +0 -0
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/engine/models/incarnation_state.py +0 -0
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/engine/models/template_config.py +0 -0
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/engine/patching/__init__.py +0 -0
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/engine/patching/git_diff_patch.py +0 -0
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/engine/rendering.py +0 -0
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/engine/update.py +0 -0
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/error_handlers.py +0 -0
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/external/__init__.py +0 -0
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/external/git.py +0 -0
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/hosters/__init__.py +0 -0
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/hosters/local.py +0 -0
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/hosters/types.py +0 -0
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/middlewares.py +0 -0
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/models/__init__.py +0 -0
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/models/change.py +0 -0
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/models/errors.py +0 -0
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/models/incarnation.py +0 -0
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/openapi.py +0 -0
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/routers/__init__.py +0 -0
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/routers/auth.py +0 -0
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/routers/changes.py +0 -0
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/routers/incarnations.py +0 -0
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/routers/not_found.py +0 -0
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/routers/version.py +0 -0
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/services/__init__.py +0 -0
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/services/incarnation.py +0 -0
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/settings.py +0 -0
- {foxops-2.9.0 → foxops-2.10.0}/src/foxops/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: foxops
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.10.0
|
|
4
4
|
Summary: Foxops 🦊
|
|
5
5
|
License: Apache-2.0
|
|
6
6
|
License-File: LICENSE
|
|
@@ -18,6 +18,7 @@ Requires-Dist: aiosqlite (>=0.20.0,<0.21.0)
|
|
|
18
18
|
Requires-Dist: alembic[tz] (>=1.8.1,<2.0.0)
|
|
19
19
|
Requires-Dist: anyio (>=4.0)
|
|
20
20
|
Requires-Dist: asyncpg (>=0.31.0,<0.32.0)
|
|
21
|
+
Requires-Dist: certifi (>=2026.10.19)
|
|
21
22
|
Requires-Dist: fastapi (>=0.120.1)
|
|
22
23
|
Requires-Dist: greenlet (>=3.1.1,<4.0.0)
|
|
23
24
|
Requires-Dist: httpx (>=0.27.2,<0.28.0)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "foxops"
|
|
3
3
|
# managed by poetry-dynamic-versioning, do not change.
|
|
4
|
-
version = "2.
|
|
4
|
+
version = "2.10.0"
|
|
5
5
|
description = "Foxops 🦊"
|
|
6
6
|
license = "Apache-2.0"
|
|
7
7
|
authors = [
|
|
@@ -27,6 +27,9 @@ tenacity = "^9.0.0"
|
|
|
27
27
|
pydantic = "^2.11.7"
|
|
28
28
|
structlog = "25.5.0"
|
|
29
29
|
anyio = ">=4.0"
|
|
30
|
+
# Floor for the Mozilla CA bundle used by httpx/requests: 2026.10.19 removed the root behind the
|
|
31
|
+
# compromised eMudhra intermediates (Oct 2026). Keep it so the image can never trust them again.
|
|
32
|
+
certifi = ">=2026.10.19"
|
|
30
33
|
|
|
31
34
|
# Database
|
|
32
35
|
SQLAlchemy = {extras = ["asyncio"], version = "^2.0.2"}
|
|
@@ -18,6 +18,10 @@ class ReconciliationUserError(ReconciliationError, FoxopsUserError):
|
|
|
18
18
|
"""Exception raised when a user error occurs during reconciliation."""
|
|
19
19
|
|
|
20
20
|
|
|
21
|
+
class MergeRequestCreationFailedError(FoxopsError):
|
|
22
|
+
"""Exception raised when the hoster refused to create a merge request for a pushed branch."""
|
|
23
|
+
|
|
24
|
+
|
|
21
25
|
class IncarnationNotFoundError(FoxopsError):
|
|
22
26
|
"""Exception raised when an Incarnation cannot be found in the inventory"""
|
|
23
27
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import asyncio
|
|
2
2
|
import base64
|
|
3
|
+
import re
|
|
3
4
|
import shutil
|
|
4
5
|
from contextlib import asynccontextmanager
|
|
5
6
|
from datetime import timedelta
|
|
@@ -12,12 +13,12 @@ from urllib.parse import quote_plus
|
|
|
12
13
|
|
|
13
14
|
import httpx
|
|
14
15
|
from tenacity import retry
|
|
15
|
-
from tenacity.retry import retry_if_exception_type
|
|
16
|
+
from tenacity.retry import retry_if_exception, retry_if_exception_type
|
|
16
17
|
from tenacity.stop import stop_after_delay
|
|
17
18
|
from tenacity.wait import wait_fixed
|
|
18
19
|
|
|
19
20
|
from foxops.engine import IncarnationState
|
|
20
|
-
from foxops.errors import IncarnationRepositoryNotFound
|
|
21
|
+
from foxops.errors import IncarnationRepositoryNotFound, MergeRequestCreationFailedError
|
|
21
22
|
from foxops.external.git import (
|
|
22
23
|
GitRepository,
|
|
23
24
|
add_authentication_to_git_clone_url,
|
|
@@ -36,6 +37,19 @@ from foxops.logger import bound, get_logger
|
|
|
36
37
|
#: Holds the module logger
|
|
37
38
|
logger = get_logger(__name__)
|
|
38
39
|
|
|
40
|
+
MERGE_REQUEST_SOURCE_BRANCH_RETRY_TIMEOUT = timedelta(seconds=10)
|
|
41
|
+
MERGE_REQUEST_SOURCE_BRANCH_RETRY_WAIT = timedelta(seconds=1)
|
|
42
|
+
|
|
43
|
+
_SOURCE_BRANCH_MISSING_PATTERN = re.compile(r'"source_branch":\s*\["does not exist"')
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def _is_source_branch_not_yet_visible(error: BaseException) -> bool:
|
|
47
|
+
return (
|
|
48
|
+
isinstance(error, httpx.HTTPStatusError)
|
|
49
|
+
and error.response.is_client_error
|
|
50
|
+
and _SOURCE_BRANCH_MISSING_PATTERN.search(error.response.text) is not None
|
|
51
|
+
)
|
|
52
|
+
|
|
39
53
|
|
|
40
54
|
class MergeRequest(TypedDict):
|
|
41
55
|
iid: int
|
|
@@ -135,18 +149,13 @@ class GitlabHoster(Hoster):
|
|
|
135
149
|
# For now, foxops anyways only supports operating on the default branch.
|
|
136
150
|
target_branch = (await self.get_repository_metadata(incarnation_repository))["default_branch"]
|
|
137
151
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
"description": description,
|
|
145
|
-
"remove_source_branch": "True",
|
|
146
|
-
},
|
|
152
|
+
merge_request = await self._create_merge_request(
|
|
153
|
+
incarnation_repository=incarnation_repository,
|
|
154
|
+
source_branch=source_branch,
|
|
155
|
+
target_branch=target_branch,
|
|
156
|
+
title=title,
|
|
157
|
+
description=description,
|
|
147
158
|
)
|
|
148
|
-
response.raise_for_status()
|
|
149
|
-
merge_request: MergeRequest = response.json()
|
|
150
159
|
logger.info(
|
|
151
160
|
f"Created merge request at {merge_request['web_url']}",
|
|
152
161
|
title=title,
|
|
@@ -184,6 +193,76 @@ class GitlabHoster(Hoster):
|
|
|
184
193
|
|
|
185
194
|
return merge_request["sha"], str(merge_request["iid"])
|
|
186
195
|
|
|
196
|
+
async def _create_merge_request(
|
|
197
|
+
self,
|
|
198
|
+
*,
|
|
199
|
+
incarnation_repository: str,
|
|
200
|
+
source_branch: str,
|
|
201
|
+
target_branch: str,
|
|
202
|
+
title: str,
|
|
203
|
+
description: str,
|
|
204
|
+
) -> MergeRequest:
|
|
205
|
+
@retry(
|
|
206
|
+
retry=retry_if_exception(_is_source_branch_not_yet_visible),
|
|
207
|
+
stop=stop_after_delay(MERGE_REQUEST_SOURCE_BRANCH_RETRY_TIMEOUT.total_seconds()),
|
|
208
|
+
wait=wait_fixed(MERGE_REQUEST_SOURCE_BRANCH_RETRY_WAIT.total_seconds()),
|
|
209
|
+
reraise=True,
|
|
210
|
+
)
|
|
211
|
+
async def __create() -> MergeRequest:
|
|
212
|
+
try:
|
|
213
|
+
response = await self.client.post(
|
|
214
|
+
f"/projects/{quote_plus(incarnation_repository)}/merge_requests",
|
|
215
|
+
json={
|
|
216
|
+
"source_branch": source_branch,
|
|
217
|
+
"target_branch": target_branch,
|
|
218
|
+
"title": title,
|
|
219
|
+
"description": description,
|
|
220
|
+
"remove_source_branch": "True",
|
|
221
|
+
},
|
|
222
|
+
timeout=MERGE_REQUEST_SOURCE_BRANCH_RETRY_TIMEOUT.total_seconds(),
|
|
223
|
+
)
|
|
224
|
+
except httpx.TimeoutException as e:
|
|
225
|
+
raise MergeRequestCreationFailedError(
|
|
226
|
+
f"GitLab did not respond to the merge request creation for branch '{source_branch}' in "
|
|
227
|
+
f"'{incarnation_repository}' within "
|
|
228
|
+
f"{MERGE_REQUEST_SOURCE_BRANCH_RETRY_TIMEOUT.total_seconds():.0f}s."
|
|
229
|
+
) from e
|
|
230
|
+
|
|
231
|
+
try:
|
|
232
|
+
response.raise_for_status()
|
|
233
|
+
except httpx.HTTPStatusError as e:
|
|
234
|
+
if _is_source_branch_not_yet_visible(e):
|
|
235
|
+
logger.warning(
|
|
236
|
+
f"GitLab does not see the pushed source branch '{source_branch}' in "
|
|
237
|
+
f"'{incarnation_repository}' yet, retrying merge request creation",
|
|
238
|
+
status_code=response.status_code,
|
|
239
|
+
)
|
|
240
|
+
raise
|
|
241
|
+
raise MergeRequestCreationFailedError(
|
|
242
|
+
f"GitLab refused to create a merge request for branch '{source_branch}' in "
|
|
243
|
+
f"'{incarnation_repository}' (HTTP {response.status_code}): {response.text}"
|
|
244
|
+
) from e
|
|
245
|
+
|
|
246
|
+
return response.json()
|
|
247
|
+
|
|
248
|
+
try:
|
|
249
|
+
return await __create()
|
|
250
|
+
except httpx.HTTPStatusError as e:
|
|
251
|
+
logger.error(
|
|
252
|
+
"Gave up creating a merge request: the branch was pushed but GitLab still does not see it. "
|
|
253
|
+
"The incarnation repository now has a pushed branch with no merge request.",
|
|
254
|
+
incarnation_repository=incarnation_repository,
|
|
255
|
+
source_branch=source_branch,
|
|
256
|
+
target_branch=target_branch,
|
|
257
|
+
retry_timeout_seconds=MERGE_REQUEST_SOURCE_BRANCH_RETRY_TIMEOUT.total_seconds(),
|
|
258
|
+
)
|
|
259
|
+
raise MergeRequestCreationFailedError(
|
|
260
|
+
f"GitLab still reports the source branch '{source_branch}' in "
|
|
261
|
+
f"'{incarnation_repository}' as non-existent "
|
|
262
|
+
f"{MERGE_REQUEST_SOURCE_BRANCH_RETRY_TIMEOUT.total_seconds():.0f}s after it was pushed. "
|
|
263
|
+
f"Last response from GitLab: {e.response.text}"
|
|
264
|
+
) from e
|
|
265
|
+
|
|
187
266
|
@asynccontextmanager
|
|
188
267
|
async def cloned_repository(
|
|
189
268
|
self, repository: str, *, refspec: str | None = None, bare: bool = False
|
|
@@ -33,6 +33,13 @@ def configure_uvicorn_logging():
|
|
|
33
33
|
uvicorn_access_logger.handlers.clear()
|
|
34
34
|
|
|
35
35
|
|
|
36
|
+
def build_console_renderer() -> structlog.dev.ConsoleRenderer:
|
|
37
|
+
# Without an explicit exception_formatter, ConsoleRenderer silently switches to rich's
|
|
38
|
+
# whenever rich is installed, and that one repr()s every frame's locals: ~26s per
|
|
39
|
+
# traceback here, rendered synchronously on the event loop.
|
|
40
|
+
return structlog.dev.ConsoleRenderer(exception_formatter=structlog.dev.plain_traceback)
|
|
41
|
+
|
|
42
|
+
|
|
36
43
|
def setup_logging(level: int | str) -> None:
|
|
37
44
|
if structlog.is_configured():
|
|
38
45
|
return
|
|
@@ -62,7 +69,7 @@ def setup_logging(level: int | str) -> None:
|
|
|
62
69
|
processors=[
|
|
63
70
|
# Remove _record & _from_structlog.
|
|
64
71
|
structlog.stdlib.ProcessorFormatter.remove_processors_meta,
|
|
65
|
-
|
|
72
|
+
build_console_renderer(),
|
|
66
73
|
],
|
|
67
74
|
)
|
|
68
75
|
|
|
@@ -434,6 +434,11 @@ class ChangeService:
|
|
|
434
434
|
)
|
|
435
435
|
|
|
436
436
|
if merge_request_id is None:
|
|
437
|
+
log.warning(
|
|
438
|
+
"Found a dangling branch with no merge request",
|
|
439
|
+
incarnation_repository=incarnation.incarnation_repository,
|
|
440
|
+
branch_name=change.merge_request_branch_name,
|
|
441
|
+
)
|
|
437
442
|
raise CannotRepairChangeException(
|
|
438
443
|
"the commit and branch for the change exist, but the MR does not. "
|
|
439
444
|
f"Please go ahead and manually create a merge request for "
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|