base-deployment-controller 0.3.0__tar.gz → 0.4.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.
- {base_deployment_controller-0.3.0 → base_deployment_controller-0.4.0}/PKG-INFO +3 -3
- {base_deployment_controller-0.3.0 → base_deployment_controller-0.4.0}/README.md +2 -2
- {base_deployment_controller-0.3.0 → base_deployment_controller-0.4.0}/pyproject.toml +1 -1
- {base_deployment_controller-0.3.0 → base_deployment_controller-0.4.0}/src/base_deployment_controller/models/environment.py +4 -4
- {base_deployment_controller-0.3.0 → base_deployment_controller-0.4.0}/src/base_deployment_controller/routers/environment.py +17 -17
- {base_deployment_controller-0.3.0 → base_deployment_controller-0.4.0}/src/base_deployment_controller/services/config.py +13 -10
- {base_deployment_controller-0.3.0 → base_deployment_controller-0.4.0}/src/base_deployment_controller.egg-info/PKG-INFO +3 -3
- {base_deployment_controller-0.3.0 → base_deployment_controller-0.4.0}/setup.cfg +0 -0
- {base_deployment_controller-0.3.0 → base_deployment_controller-0.4.0}/src/base_deployment_controller/__init__.py +0 -0
- {base_deployment_controller-0.3.0 → base_deployment_controller-0.4.0}/src/base_deployment_controller/builder.py +0 -0
- {base_deployment_controller-0.3.0 → base_deployment_controller-0.4.0}/src/base_deployment_controller/models/__init__.py +0 -0
- {base_deployment_controller-0.3.0 → base_deployment_controller-0.4.0}/src/base_deployment_controller/models/api.py +0 -0
- {base_deployment_controller-0.3.0 → base_deployment_controller-0.4.0}/src/base_deployment_controller/models/compose.py +0 -0
- {base_deployment_controller-0.3.0 → base_deployment_controller-0.4.0}/src/base_deployment_controller/models/container.py +0 -0
- {base_deployment_controller-0.3.0 → base_deployment_controller-0.4.0}/src/base_deployment_controller/models/deployment.py +0 -0
- {base_deployment_controller-0.3.0 → base_deployment_controller-0.4.0}/src/base_deployment_controller/models/events.py +0 -0
- {base_deployment_controller-0.3.0 → base_deployment_controller-0.4.0}/src/base_deployment_controller/models/task.py +0 -0
- {base_deployment_controller-0.3.0 → base_deployment_controller-0.4.0}/src/base_deployment_controller/routers/__init__.py +0 -0
- {base_deployment_controller-0.3.0 → base_deployment_controller-0.4.0}/src/base_deployment_controller/routers/api.py +0 -0
- {base_deployment_controller-0.3.0 → base_deployment_controller-0.4.0}/src/base_deployment_controller/routers/container.py +0 -0
- {base_deployment_controller-0.3.0 → base_deployment_controller-0.4.0}/src/base_deployment_controller/routers/deployment.py +0 -0
- {base_deployment_controller-0.3.0 → base_deployment_controller-0.4.0}/src/base_deployment_controller/services/__init__.py +0 -0
- {base_deployment_controller-0.3.0 → base_deployment_controller-0.4.0}/src/base_deployment_controller/services/deployment_status_monitor.py +0 -0
- {base_deployment_controller-0.3.0 → base_deployment_controller-0.4.0}/src/base_deployment_controller/services/status_event_manager.py +0 -0
- {base_deployment_controller-0.3.0 → base_deployment_controller-0.4.0}/src/base_deployment_controller/services/task_manager.py +0 -0
- {base_deployment_controller-0.3.0 → base_deployment_controller-0.4.0}/src/base_deployment_controller.egg-info/SOURCES.txt +0 -0
- {base_deployment_controller-0.3.0 → base_deployment_controller-0.4.0}/src/base_deployment_controller.egg-info/dependency_links.txt +0 -0
- {base_deployment_controller-0.3.0 → base_deployment_controller-0.4.0}/src/base_deployment_controller.egg-info/requires.txt +0 -0
- {base_deployment_controller-0.3.0 → base_deployment_controller-0.4.0}/src/base_deployment_controller.egg-info/top_level.txt +0 -0
- {base_deployment_controller-0.3.0 → base_deployment_controller-0.4.0}/tests/test_api.py +0 -0
- {base_deployment_controller-0.3.0 → base_deployment_controller-0.4.0}/tests/test_containers.py +0 -0
- {base_deployment_controller-0.3.0 → base_deployment_controller-0.4.0}/tests/test_deployment.py +0 -0
- {base_deployment_controller-0.3.0 → base_deployment_controller-0.4.0}/tests/test_envs.py +0 -0
- {base_deployment_controller-0.3.0 → base_deployment_controller-0.4.0}/tests/test_status_event_manager.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: base-deployment-controller
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: REST API to control the basic operations of a deployment
|
|
5
5
|
Author: Tknika
|
|
6
6
|
License: Creative Commons Atribución-NoComercial (CC BY-NC)
|
|
@@ -108,13 +108,13 @@ curl http://localhost:8000/envs
|
|
|
108
108
|
```
|
|
109
109
|
|
|
110
110
|
#### PUT /envs
|
|
111
|
-
Actualiza variables de entorno. Usa `
|
|
111
|
+
Actualiza variables de entorno. Usa `recreate_services` (por defecto `true`) para controlar si se recrean los servicios afectados.
|
|
112
112
|
|
|
113
113
|
```bash
|
|
114
114
|
# Actualización múltiple
|
|
115
115
|
curl -X PUT http://localhost:8000/envs \
|
|
116
116
|
-H "Content-Type: application/json" \
|
|
117
|
-
-d '{"variables": {"MCC": "214", "MNC": "07"}, "
|
|
117
|
+
-d '{"variables": {"MCC": "214", "MNC": "07"}, "recreate_services": false}'
|
|
118
118
|
```
|
|
119
119
|
|
|
120
120
|
#### GET /containers
|
|
@@ -87,13 +87,13 @@ curl http://localhost:8000/envs
|
|
|
87
87
|
```
|
|
88
88
|
|
|
89
89
|
#### PUT /envs
|
|
90
|
-
Actualiza variables de entorno. Usa `
|
|
90
|
+
Actualiza variables de entorno. Usa `recreate_services` (por defecto `true`) para controlar si se recrean los servicios afectados.
|
|
91
91
|
|
|
92
92
|
```bash
|
|
93
93
|
# Actualización múltiple
|
|
94
94
|
curl -X PUT http://localhost:8000/envs \
|
|
95
95
|
-H "Content-Type: application/json" \
|
|
96
|
-
-d '{"variables": {"MCC": "214", "MNC": "07"}, "
|
|
96
|
+
-d '{"variables": {"MCC": "214", "MNC": "07"}, "recreate_services": false}'
|
|
97
97
|
```
|
|
98
98
|
|
|
99
99
|
#### GET /containers
|
|
@@ -23,10 +23,10 @@ class BulkEnvUpdateRequest(BaseModel):
|
|
|
23
23
|
"""Request to update multiple environment variables in bulk."""
|
|
24
24
|
|
|
25
25
|
variables: dict[str, str] = Field(..., description="Variables to update")
|
|
26
|
-
|
|
26
|
+
recreate_services: bool = Field(
|
|
27
27
|
default=True,
|
|
28
28
|
description=(
|
|
29
|
-
"Whether to
|
|
29
|
+
"Whether to recreate affected services after updating the variables."
|
|
30
30
|
),
|
|
31
31
|
)
|
|
32
32
|
|
|
@@ -37,6 +37,6 @@ class EnvUpdateResponse(BaseModel):
|
|
|
37
37
|
success: bool = Field(..., description="Update success status")
|
|
38
38
|
updated: list[str] = Field(..., description="List of updated variables")
|
|
39
39
|
message: str = Field(..., description="Status message")
|
|
40
|
-
|
|
41
|
-
default_factory=dict, description="Services
|
|
40
|
+
recreated_services: dict[str, bool] = Field(
|
|
41
|
+
default_factory=dict, description="Services recreated and their status"
|
|
42
42
|
)
|
|
@@ -30,7 +30,7 @@ class EnvRoutes:
|
|
|
30
30
|
|
|
31
31
|
Provides endpoints for retrieving and updating environment variables
|
|
32
32
|
defined in the compose.yaml x-env-vars schema. Updates are async when
|
|
33
|
-
services need to be
|
|
33
|
+
services need to be recreated.
|
|
34
34
|
|
|
35
35
|
Args:
|
|
36
36
|
config: Instance of `ConfigService` for file access and validation.
|
|
@@ -134,11 +134,11 @@ class EnvRoutes:
|
|
|
134
134
|
"""
|
|
135
135
|
Update environment variables in .env file asynchronously.
|
|
136
136
|
|
|
137
|
-
When
|
|
137
|
+
When recreate_services is True, the operation runs asynchronously
|
|
138
138
|
and returns 202 Accepted with a task_id.
|
|
139
139
|
|
|
140
140
|
Args:
|
|
141
|
-
request: Bulk update request with variables and
|
|
141
|
+
request: Bulk update request with variables and recreate flag.
|
|
142
142
|
fastapi_request: FastAPI request object (for building Location header).
|
|
143
143
|
|
|
144
144
|
Returns:
|
|
@@ -176,11 +176,11 @@ class EnvRoutes:
|
|
|
176
176
|
|
|
177
177
|
logger.info(f"Updating {len(updates)} environment variables")
|
|
178
178
|
|
|
179
|
-
# Create async task for update +
|
|
179
|
+
# Create async task for update + recreate
|
|
180
180
|
task_id = await self.task_manager.create_task(
|
|
181
181
|
operation="env_update",
|
|
182
182
|
func=lambda: self._execute_env_update(
|
|
183
|
-
task_id, updates, request.
|
|
183
|
+
task_id, updates, request.recreate_services
|
|
184
184
|
),
|
|
185
185
|
)
|
|
186
186
|
|
|
@@ -287,10 +287,10 @@ class EnvRoutes:
|
|
|
287
287
|
self,
|
|
288
288
|
task_id: str,
|
|
289
289
|
updates: dict[str, str],
|
|
290
|
-
|
|
290
|
+
recreate_services: bool,
|
|
291
291
|
) -> EnvUpdateResponse:
|
|
292
292
|
"""
|
|
293
|
-
Execute environment variable update with optional service
|
|
293
|
+
Execute environment variable update with optional service recreation.
|
|
294
294
|
|
|
295
295
|
Runs in thread executor. TaskManager auto-manages state transitions:
|
|
296
296
|
PENDING -> RUNNING (on start) -> COMPLETED (success) or FAILED (exception).
|
|
@@ -299,13 +299,13 @@ class EnvRoutes:
|
|
|
299
299
|
Args:
|
|
300
300
|
task_id: Task identifier (for logging).
|
|
301
301
|
updates: Dict of variables to update.
|
|
302
|
-
|
|
302
|
+
recreate_services: Whether to recreate affected services.
|
|
303
303
|
|
|
304
304
|
Returns:
|
|
305
305
|
EnvUpdateResponse with update results.
|
|
306
306
|
|
|
307
307
|
Raises:
|
|
308
|
-
Exception: On update/
|
|
308
|
+
Exception: On update/recreate failure. Message stored in task.error.
|
|
309
309
|
"""
|
|
310
310
|
try:
|
|
311
311
|
# Update .env file
|
|
@@ -315,20 +315,20 @@ class EnvRoutes:
|
|
|
315
315
|
# Build updated variables list for response
|
|
316
316
|
updated_var_names = list(updates.keys())
|
|
317
317
|
|
|
318
|
-
#
|
|
319
|
-
|
|
320
|
-
if
|
|
321
|
-
# Compute affected services and
|
|
318
|
+
# Recreate services if requested
|
|
319
|
+
recreate_results: dict[str, bool] = {}
|
|
320
|
+
if recreate_services:
|
|
321
|
+
# Compute affected services and recreate via ConfigService
|
|
322
322
|
affected_services = self.config.get_affected_services(updated_var_names)
|
|
323
|
-
logger.info(f"[{task_id}]
|
|
324
|
-
|
|
323
|
+
logger.info(f"[{task_id}] Recreating {len(affected_services)} affected services")
|
|
324
|
+
recreate_results = self.config.recreate_services(affected_services)
|
|
325
325
|
|
|
326
326
|
logger.info(f"[{task_id}] Environment update completed successfully")
|
|
327
327
|
return EnvUpdateResponse(
|
|
328
328
|
success=True,
|
|
329
329
|
message=f"Updated {len(updates)} environment variables",
|
|
330
330
|
updated=updated_var_names,
|
|
331
|
-
|
|
331
|
+
recreated_services=recreate_results,
|
|
332
332
|
)
|
|
333
333
|
except Exception as e:
|
|
334
334
|
logger.error(f"[{task_id}] Error executing environment update: {e}")
|
|
@@ -336,7 +336,7 @@ class EnvRoutes:
|
|
|
336
336
|
success=False,
|
|
337
337
|
message=f"Failed to update environment variables: {str(e)}",
|
|
338
338
|
updated=[],
|
|
339
|
-
|
|
339
|
+
recreated_services={},
|
|
340
340
|
)
|
|
341
341
|
|
|
342
342
|
# Service-state updates removed; tasks no longer track per-service states.
|
|
@@ -326,15 +326,15 @@ class ConfigService:
|
|
|
326
326
|
affected_services.update(services)
|
|
327
327
|
return list(affected_services)
|
|
328
328
|
|
|
329
|
-
def
|
|
329
|
+
def recreate_services(self, service_names: List[str]) -> Dict[str, bool]:
|
|
330
330
|
"""
|
|
331
|
-
|
|
331
|
+
Recreate specified Docker services/containers.
|
|
332
332
|
|
|
333
333
|
Args:
|
|
334
|
-
service_names: List of service names from compose.yaml to
|
|
334
|
+
service_names: List of service names from compose.yaml to recreate.
|
|
335
335
|
|
|
336
336
|
Returns:
|
|
337
|
-
Dict mapping service names to
|
|
337
|
+
Dict mapping service names to recreate success status (True/False).
|
|
338
338
|
"""
|
|
339
339
|
results: Dict[str, bool] = {}
|
|
340
340
|
|
|
@@ -353,23 +353,26 @@ class ConfigService:
|
|
|
353
353
|
|
|
354
354
|
try:
|
|
355
355
|
if client.container.exists(container_name):
|
|
356
|
-
# Only
|
|
356
|
+
# Only recreate if container exists
|
|
357
357
|
container_inspect = client.container.inspect(container_name)
|
|
358
358
|
if container_inspect.state.status == "running":
|
|
359
|
-
|
|
359
|
+
# Recreate service container to apply environment changes.
|
|
360
|
+
# Equivalent intent to: docker compose rm -f -s <service> && docker compose up -d <service>
|
|
361
|
+
client.compose.rm(services=[service_name], stop=True)
|
|
362
|
+
client.compose.up(detach=True, services=[service_name])
|
|
360
363
|
results[service_name] = True
|
|
361
364
|
else:
|
|
362
|
-
# Container exists but not running, don't
|
|
365
|
+
# Container exists but not running, don't recreate
|
|
363
366
|
results[service_name] = False
|
|
364
367
|
else:
|
|
365
|
-
# Container doesn't exist, can't
|
|
368
|
+
# Container doesn't exist, can't recreate
|
|
366
369
|
results[service_name] = False
|
|
367
370
|
except Exception as e:
|
|
368
|
-
logger.error(f"Error
|
|
371
|
+
logger.error(f"Error recreating service {service_name}: {e}")
|
|
369
372
|
results[service_name] = False
|
|
370
373
|
|
|
371
374
|
except Exception as e:
|
|
372
|
-
logger.error(f"Error in
|
|
375
|
+
logger.error(f"Error in recreate_services: {e}")
|
|
373
376
|
|
|
374
377
|
return results
|
|
375
378
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: base-deployment-controller
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: REST API to control the basic operations of a deployment
|
|
5
5
|
Author: Tknika
|
|
6
6
|
License: Creative Commons Atribución-NoComercial (CC BY-NC)
|
|
@@ -108,13 +108,13 @@ curl http://localhost:8000/envs
|
|
|
108
108
|
```
|
|
109
109
|
|
|
110
110
|
#### PUT /envs
|
|
111
|
-
Actualiza variables de entorno. Usa `
|
|
111
|
+
Actualiza variables de entorno. Usa `recreate_services` (por defecto `true`) para controlar si se recrean los servicios afectados.
|
|
112
112
|
|
|
113
113
|
```bash
|
|
114
114
|
# Actualización múltiple
|
|
115
115
|
curl -X PUT http://localhost:8000/envs \
|
|
116
116
|
-H "Content-Type: application/json" \
|
|
117
|
-
-d '{"variables": {"MCC": "214", "MNC": "07"}, "
|
|
117
|
+
-d '{"variables": {"MCC": "214", "MNC": "07"}, "recreate_services": false}'
|
|
118
118
|
```
|
|
119
119
|
|
|
120
120
|
#### GET /containers
|
|
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
|
{base_deployment_controller-0.3.0 → base_deployment_controller-0.4.0}/tests/test_containers.py
RENAMED
|
File without changes
|
{base_deployment_controller-0.3.0 → base_deployment_controller-0.4.0}/tests/test_deployment.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|