qontract-reconcile 0.10.2.dev86__py3-none-any.whl → 0.10.2.dev87__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.
- {qontract_reconcile-0.10.2.dev86.dist-info → qontract_reconcile-0.10.2.dev87.dist-info}/METADATA +1 -1
- {qontract_reconcile-0.10.2.dev86.dist-info → qontract_reconcile-0.10.2.dev87.dist-info}/RECORD +6 -6
- reconcile/external_resources/manager.py +48 -20
- reconcile/external_resources/model.py +17 -12
- {qontract_reconcile-0.10.2.dev86.dist-info → qontract_reconcile-0.10.2.dev87.dist-info}/WHEEL +0 -0
- {qontract_reconcile-0.10.2.dev86.dist-info → qontract_reconcile-0.10.2.dev87.dist-info}/entry_points.txt +0 -0
{qontract_reconcile-0.10.2.dev86.dist-info → qontract_reconcile-0.10.2.dev87.dist-info}/METADATA
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: qontract-reconcile
|
3
|
-
Version: 0.10.2.
|
3
|
+
Version: 0.10.2.dev87
|
4
4
|
Summary: Collection of tools to reconcile services with their desired state as defined in the app-interface DB.
|
5
5
|
Project-URL: homepage, https://github.com/app-sre/qontract-reconcile
|
6
6
|
Project-URL: repository, https://github.com/app-sre/qontract-reconcile
|
{qontract_reconcile-0.10.2.dev86.dist-info → qontract_reconcile-0.10.2.dev87.dist-info}/RECORD
RENAMED
@@ -199,10 +199,10 @@ reconcile/external_resources/aws.py,sha256=wzN3GHxyqVa4Lqqg5HdogqNW2RM532t0ZiKaQ
|
|
199
199
|
reconcile/external_resources/factories.py,sha256=C0QHT0soEv6z99-ELAAE19S5MaMHhV0t1fSiQn0Coc4,5970
|
200
200
|
reconcile/external_resources/integration.py,sha256=JF38M7R0Z4ADUTx57TZqSZH9k_xpPlbAxQAcGyIISuM,6925
|
201
201
|
reconcile/external_resources/integration_secrets_sync.py,sha256=dX09O3r6KURziUYYfiki10orNjOGVma-XojhVqd0ww4,1667
|
202
|
-
reconcile/external_resources/manager.py,sha256=
|
202
|
+
reconcile/external_resources/manager.py,sha256=mvFfcXPzvNqDWDgKTK8eiSe6C_FUvBtben3bSqrqSoc,18246
|
203
203
|
reconcile/external_resources/meta.py,sha256=noaytFzmShpzLA_ebGh7wuP45mOfHIOnnoUxivjDa1I,672
|
204
204
|
reconcile/external_resources/metrics.py,sha256=KiBjMUaN_z0cSkF_7Ar_a8RiuiwVqjyMcVdISlxhzXE,3898
|
205
|
-
reconcile/external_resources/model.py,sha256=
|
205
|
+
reconcile/external_resources/model.py,sha256=HrSkmAjOqw0aT3CsZKXKMLyocM__8XO5qHb-dXcoagw,13747
|
206
206
|
reconcile/external_resources/reconciler.py,sha256=-0trp1K-iUgOQn3mm1ZUSmfaReRrUT0eHzPkUhNPolQ,9583
|
207
207
|
reconcile/external_resources/secrets_sync.py,sha256=ZDxzGZ6wC4zxLhA7-L39xDRH6rzUM285gytuzmRQdlw,16208
|
208
208
|
reconcile/external_resources/state.py,sha256=gF3ACdl7YiUlbQ4uEGrD6i_Txxqr6mT9f8IFlTQ-8dY,13176
|
@@ -786,7 +786,7 @@ tools/saas_promotion_state/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJ
|
|
786
786
|
tools/saas_promotion_state/saas_promotion_state.py,sha256=UfwwRLS5Ya4_Nh1w5n1dvoYtchQvYE9yj1VANt2IKqI,3925
|
787
787
|
tools/sre_checkpoints/__init__.py,sha256=CDaDaywJnmRCLyl_NCcvxi-Zc0hTi_3OdwKiFOyS39I,145
|
788
788
|
tools/sre_checkpoints/util.py,sha256=zEDbGr18ZeHNQwW8pUsr2JRjuXIPz--WAGJxZo9sv_Y,894
|
789
|
-
qontract_reconcile-0.10.2.
|
790
|
-
qontract_reconcile-0.10.2.
|
791
|
-
qontract_reconcile-0.10.2.
|
792
|
-
qontract_reconcile-0.10.2.
|
789
|
+
qontract_reconcile-0.10.2.dev87.dist-info/METADATA,sha256=nVRpZDkDyzcxrgE5yIHcfaAKhAQBbpzHtq_p3vStPr8,24565
|
790
|
+
qontract_reconcile-0.10.2.dev87.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
791
|
+
qontract_reconcile-0.10.2.dev87.dist-info/entry_points.txt,sha256=5i9l54La3vQrDLAdwDKQWC0iG4sV9RRfOb1BpvzOWLc,698
|
792
|
+
qontract_reconcile-0.10.2.dev87.dist-info/RECORD,,
|
@@ -133,6 +133,40 @@ class ExternalResourcesManager:
|
|
133
133
|
self.thread_pool_size = thread_pool_size
|
134
134
|
self.dry_runs_validator = dry_runs_validator
|
135
135
|
|
136
|
+
def _resource_spec_changed(
|
137
|
+
self, reconciliation: Reconciliation, state: ExternalResourceState
|
138
|
+
) -> bool:
|
139
|
+
return reconciliation.resource_hash != state.reconciliation.resource_hash
|
140
|
+
|
141
|
+
def _resource_drift_detection_ttl_expired(
|
142
|
+
self, reconciliation: Reconciliation, state: ExternalResourceState
|
143
|
+
) -> bool:
|
144
|
+
return (datetime.now(state.ts.tzinfo) - state.ts).total_seconds() > (
|
145
|
+
reconciliation.module_configuration.reconcile_drift_interval_minutes * 60
|
146
|
+
)
|
147
|
+
|
148
|
+
def _reconciliation_module_config_overridden(
|
149
|
+
self, reconciliation: Reconciliation, state: ExternalResourceState
|
150
|
+
) -> bool:
|
151
|
+
return reconciliation.module_configuration.overridden and (
|
152
|
+
reconciliation.module_configuration.image_version
|
153
|
+
!= state.reconciliation.module_configuration.image_version
|
154
|
+
)
|
155
|
+
|
156
|
+
def _reconciliation_needs_dry_run_run(
|
157
|
+
self, reconciliation: Reconciliation, state: ExternalResourceState
|
158
|
+
) -> bool:
|
159
|
+
return (
|
160
|
+
reconciliation.action == Action.APPLY
|
161
|
+
and (
|
162
|
+
self._resource_spec_changed(reconciliation, state)
|
163
|
+
or self._reconciliation_module_config_overridden(reconciliation, state)
|
164
|
+
)
|
165
|
+
) or (
|
166
|
+
reconciliation.action == Action.DESTROY
|
167
|
+
and not state.resource_status.is_in_progress
|
168
|
+
)
|
169
|
+
|
136
170
|
def _get_reconcile_action(
|
137
171
|
self, reconciliation: Reconciliation, state: ExternalResourceState
|
138
172
|
) -> ReconcileAction:
|
@@ -145,17 +179,16 @@ class ExternalResourcesManager:
|
|
145
179
|
case ResourceStatus.ERROR:
|
146
180
|
return ReconcileAction.APPLY_ERROR
|
147
181
|
case ResourceStatus.CREATED | ResourceStatus.PENDING_SECRET_SYNC:
|
148
|
-
if (
|
149
|
-
reconciliation.resource_hash
|
150
|
-
!= state.reconciliation.resource_hash
|
151
|
-
):
|
182
|
+
if self._resource_spec_changed(reconciliation, state):
|
152
183
|
return ReconcileAction.APPLY_SPEC_CHANGED
|
153
|
-
elif (
|
154
|
-
|
155
|
-
> reconciliation.module_configuration.reconcile_drift_interval_minutes
|
156
|
-
* 60
|
184
|
+
elif self._resource_drift_detection_ttl_expired(
|
185
|
+
reconciliation, state
|
157
186
|
):
|
158
187
|
return ReconcileAction.APPLY_DRIFT_DETECTION
|
188
|
+
elif self._reconciliation_module_config_overridden(
|
189
|
+
reconciliation, state
|
190
|
+
):
|
191
|
+
return ReconcileAction.APPLY_MODULE_CONFIG_OVERRIDDEN
|
159
192
|
elif reconciliation.action == Action.DESTROY:
|
160
193
|
match state.resource_status:
|
161
194
|
case ResourceStatus.CREATED:
|
@@ -411,18 +444,13 @@ class ExternalResourcesManager:
|
|
411
444
|
self.dry_runs_validator.validate()
|
412
445
|
desired_r = self._get_desired_objects_reconciliations()
|
413
446
|
deleted_r = self._get_deleted_objects_reconciliations()
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
and state.reconciliation.resource_hash != r.resource_hash
|
422
|
-
) or (
|
423
|
-
r.action == Action.DESTROY and not state.resource_status.is_in_progress
|
424
|
-
):
|
425
|
-
triggered.add(r)
|
447
|
+
triggered = {
|
448
|
+
r
|
449
|
+
for r in desired_r.union(deleted_r)
|
450
|
+
if self._reconciliation_needs_dry_run_run(
|
451
|
+
r, self.state_mgr.get_external_resource_state(key=r.key)
|
452
|
+
)
|
453
|
+
}
|
426
454
|
|
427
455
|
threaded.run(
|
428
456
|
self.reconciler.reconcile_resource,
|
@@ -7,7 +7,7 @@ from collections.abc import ItemsView, Iterable, Iterator, MutableMapping
|
|
7
7
|
from enum import StrEnum
|
8
8
|
from typing import Any
|
9
9
|
|
10
|
-
from pydantic import BaseModel
|
10
|
+
from pydantic import BaseModel, Field
|
11
11
|
|
12
12
|
from reconcile.external_resources.meta import (
|
13
13
|
FLAG_DELETE_RESOURCE,
|
@@ -263,6 +263,7 @@ class ExternalResourceModuleConfiguration(BaseModel, frozen=True):
|
|
263
263
|
outputs_secret_image: str = ""
|
264
264
|
outputs_secret_version: str = ""
|
265
265
|
resources: Resources = Resources()
|
266
|
+
overridden: bool = Field(default=False, exclude=True)
|
266
267
|
|
267
268
|
@property
|
268
269
|
def image_version(self) -> str:
|
@@ -278,17 +279,19 @@ class ExternalResourceModuleConfiguration(BaseModel, frozen=True):
|
|
278
279
|
spec: ExternalResourceSpec,
|
279
280
|
settings: ExternalResourcesSettingsV1,
|
280
281
|
) -> "ExternalResourceModuleConfiguration":
|
281
|
-
module_overrides = spec.metadata.get(
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
282
|
+
module_overrides = spec.metadata.get("module_overrides")
|
283
|
+
overridden = module_overrides is not None
|
284
|
+
|
285
|
+
if module_overrides is None:
|
286
|
+
module_overrides = ExternalResourcesModuleOverrides(
|
287
|
+
module_type=None,
|
288
|
+
image=None,
|
289
|
+
version=None,
|
290
|
+
reconcile_timeout_minutes=None,
|
291
|
+
outputs_secret_image=None,
|
292
|
+
outputs_secret_version=None,
|
293
|
+
resources=None,
|
294
|
+
)
|
292
295
|
|
293
296
|
return ExternalResourceModuleConfiguration(
|
294
297
|
image=module_overrides.image or module.image,
|
@@ -307,6 +310,7 @@ class ExternalResourceModuleConfiguration(BaseModel, frozen=True):
|
|
307
310
|
or module.resources
|
308
311
|
or settings.module_default_resources
|
309
312
|
),
|
313
|
+
overridden=overridden,
|
310
314
|
)
|
311
315
|
|
312
316
|
|
@@ -358,6 +362,7 @@ class ReconcileAction(StrEnum):
|
|
358
362
|
APPLY_SPEC_CHANGED = "Resource spec has changed"
|
359
363
|
APPLY_DRIFT_DETECTION = "Resource drift detection run"
|
360
364
|
APPLY_USER_REQUESTED = "Resource reconciliation requested"
|
365
|
+
APPLY_MODULE_CONFIG_OVERRIDDEN = "Module configuration overridden"
|
361
366
|
DESTROY_CREATED = "Resource no longer exists in the configuration"
|
362
367
|
DESTROY_ERROR = "Resource status in ERROR state"
|
363
368
|
|
{qontract_reconcile-0.10.2.dev86.dist-info → qontract_reconcile-0.10.2.dev87.dist-info}/WHEEL
RENAMED
File without changes
|
File without changes
|