qontract-reconcile 0.10.1rc1171__py3-none-any.whl → 0.10.1rc1173__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: qontract-reconcile
3
- Version: 0.10.1rc1171
3
+ Version: 0.10.1rc1173
4
4
  Summary: Collection of tools to reconcile services with their desired state as defined in the app-interface DB.
5
5
  Home-page: https://github.com/app-sre/qontract-reconcile
6
6
  Author: Red Hat App-SRE Team
@@ -196,13 +196,13 @@ reconcile/external_resources/aws.py,sha256=309Zui7rE8XFJA1ZBLupl55Vp8Y5KKgXdsKQW
196
196
  reconcile/external_resources/factories.py,sha256=KrJDh52_8PeCEVjwfeVr1jwAJDdhMXRQ_XcBETfnKY4,4988
197
197
  reconcile/external_resources/integration.py,sha256=gBVO5dE8JyZ3xYcYik-MTIp_18oU7_hpYc_oztyfElQ,6753
198
198
  reconcile/external_resources/integration_secrets_sync.py,sha256=dX09O3r6KURziUYYfiki10orNjOGVma-XojhVqd0ww4,1667
199
- reconcile/external_resources/manager.py,sha256=tgHOFvP-dcPLLIhcjMn6EIELTBCycbXFNAuS-NX7l2s,17929
199
+ reconcile/external_resources/manager.py,sha256=fXUm09w-9FRWYfJAwtV4_td1UHNLzdoGhWYpw5VR9jg,17757
200
200
  reconcile/external_resources/meta.py,sha256=noaytFzmShpzLA_ebGh7wuP45mOfHIOnnoUxivjDa1I,672
201
201
  reconcile/external_resources/metrics.py,sha256=nMbyonGZEJDD1lYzpQY2eR9TNwvxYC4ZCcpi6wrExcM,1037
202
202
  reconcile/external_resources/model.py,sha256=H3elpiqehg_jACy28fGV5_77n8gKclVO77-7cfbaMNA,9178
203
203
  reconcile/external_resources/reconciler.py,sha256=Lhzg0O9Sw65KrCae-J14g9PV82xdp29O4jS_T5YNgEY,9661
204
204
  reconcile/external_resources/secrets_sync.py,sha256=6n0oDPLjd9Ql0lf6zsr1AZw8A6EEe3yCzl20XodtgkE,16229
205
- reconcile/external_resources/state.py,sha256=UupSa6tl4-73_J6Fhisn-qHal3v3uAUS5s5sk85LGDs,9343
205
+ reconcile/external_resources/state.py,sha256=z086bnIUTOkzFmQvS9rSAhFsM3Aw_9PLKHBACJ-0tQc,9690
206
206
  reconcile/glitchtip/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
207
207
  reconcile/glitchtip/integration.py,sha256=XtewM9nfTPLnPSpYebP50GrveYOnhTvKNq3seSvL6u8,8343
208
208
  reconcile/glitchtip/reconciler.py,sha256=nUvDv7qG1ly0cA16MmlL6NV71yl1mJYLT2mui7lmi0Y,12402
@@ -880,8 +880,8 @@ tools/test/test_qontract_cli.py,sha256=iuzKbQ6ahinvjoQmQLBrG4shey0z-1rB6qCgS8T6d
880
880
  tools/test/test_saas_promotion_state.py,sha256=dy4kkSSAQ7bC0Xp2CociETGN-2aABEfL6FU5D9Jl00Y,6056
881
881
  tools/test/test_sd_app_sre_alert_report.py,sha256=v363r9zM7__0kR5K6mvJoGFcM9BvE33fWAayrqkpojA,2116
882
882
  tools/test/test_sre_checkpoints.py,sha256=SKqPPTl9ua0RFdSSofnoQX-JZE6dFLO3LRhfQzqtfh8,2607
883
- qontract_reconcile-0.10.1rc1171.dist-info/METADATA,sha256=GxrtQ-z9G_ZC9ukO5-h9-1qjrqcK-lkkr8bjunKNfjQ,2213
884
- qontract_reconcile-0.10.1rc1171.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
885
- qontract_reconcile-0.10.1rc1171.dist-info/entry_points.txt,sha256=GKQqCl2j2X1BJQ69een6rHcR26PmnxnONLNOQB-nRjY,491
886
- qontract_reconcile-0.10.1rc1171.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
887
- qontract_reconcile-0.10.1rc1171.dist-info/RECORD,,
883
+ qontract_reconcile-0.10.1rc1173.dist-info/METADATA,sha256=UAjgR0lD9syc08q6s2PuH2Q3_cOi0HN8W2Q7fqJcLh8,2213
884
+ qontract_reconcile-0.10.1rc1173.dist-info/WHEEL,sha256=bFJAMchF8aTQGUgMZzHJyDDMPTO3ToJ7x23SLJa1SVo,92
885
+ qontract_reconcile-0.10.1rc1173.dist-info/entry_points.txt,sha256=GKQqCl2j2X1BJQ69een6rHcR26PmnxnONLNOQB-nRjY,491
886
+ qontract_reconcile-0.10.1rc1173.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
887
+ qontract_reconcile-0.10.1rc1173.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.44.0)
2
+ Generator: bdist_wheel (0.45.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -93,14 +93,6 @@ class ReconciliationStatus(BaseModel):
93
93
  reconcile_time: int = 0
94
94
  resource_status: ResourceStatus
95
95
 
96
- @property
97
- def has_errors(self) -> bool:
98
- return self.resource_status == ResourceStatus.ERROR
99
-
100
- @property
101
- def needs_secret_sync(self) -> bool:
102
- return self.resource_status == ResourceStatus.PENDING_SECRET_SYNC
103
-
104
96
  def publish_metrics(self, r: Reconciliation, spec: ExternalResourceSpec) -> None:
105
97
  job_name = ReconciliationK8sJob(reconciliation=r).name()
106
98
 
@@ -133,7 +125,7 @@ class ReconciliationStatus(BaseModel):
133
125
  self.reconcile_time,
134
126
  )
135
127
 
136
- if self.has_errors:
128
+ if self.resource_status.has_errors:
137
129
  metrics.inc_counter(
138
130
  ExternalResourcesReconcileErrorsCounter(
139
131
  app=spec.namespace["app"]["name"],
@@ -277,21 +269,15 @@ class ExternalResourcesManager:
277
269
  r: Reconciliation,
278
270
  state: ExternalResourceState,
279
271
  ) -> ReconciliationStatus:
280
- """Gets the resource reconciliation state from the Job and updates the
281
- Resource state accordingly. It also returns if the target outputs secret needs
282
- to be reconciled.
283
-
272
+ """Gets the reconciliation job status and returns a ReconciliationStatus object with the new
273
+ resource status and other reconciliation data.
284
274
  :param r: Reconciliation object
285
275
  :param state: State object
286
276
  :return: ReconciliationStatus
287
277
  """
288
278
 
289
279
  status = ReconciliationStatus(resource_status=state.resource_status)
290
-
291
- if state.resource_status not in {
292
- ResourceStatus.DELETE_IN_PROGRESS,
293
- ResourceStatus.IN_PROGRESS,
294
- }:
280
+ if not state.resource_status.is_in_progress:
295
281
  return status
296
282
 
297
283
  logging.info(
@@ -339,20 +325,21 @@ class ExternalResourcesManager:
339
325
  self,
340
326
  r: Reconciliation,
341
327
  state: ExternalResourceState,
342
- status: ReconciliationStatus,
328
+ reconciliation_status: ReconciliationStatus,
343
329
  ) -> None:
344
- # There is no need to update the state
345
- # if it's marked in progress
346
- if state.resource_status in {
347
- ResourceStatus.DELETE_IN_PROGRESS,
348
- ResourceStatus.IN_PROGRESS,
349
- }:
330
+ if (
331
+ state.resource_status.is_in_progress
332
+ and reconciliation_status.resource_status.is_in_progress
333
+ ):
334
+ logging.debug(
335
+ "Reconciliation is still in progress. There is no need to update the state"
336
+ )
350
337
  return
351
338
  state.ts = datetime.now(UTC)
352
- if status.resource_status == ResourceStatus.DELETED:
339
+ if reconciliation_status.resource_status == ResourceStatus.DELETED:
353
340
  self.state_mgr.del_external_resource_state(r.key)
354
341
  else:
355
- state.resource_status = status.resource_status
342
+ state.resource_status = reconciliation_status.resource_status
356
343
  self.state_mgr.set_external_resource_state(state)
357
344
 
358
345
  def _set_resource_reconciliation_in_progress(
@@ -416,10 +403,10 @@ class ExternalResourcesManager:
416
403
  to_sync_keys: set[ExternalResourceKey] = set()
417
404
  for r in desired_r.union(deleted_r):
418
405
  state = self.state_mgr.get_external_resource_state(r.key)
419
- status = self._get_reconciliation_status(r, state)
420
- self._update_resource_state(r, state, status)
406
+ reconciliation_status = self._get_reconciliation_status(r, state)
407
+ self._update_resource_state(r, state, reconciliation_status)
421
408
 
422
- if status.needs_secret_sync:
409
+ if reconciliation_status.resource_status.needs_secret_sync:
423
410
  to_sync_keys.add(r.key)
424
411
 
425
412
  if self._resource_needs_reconciliation(reconciliation=r, state=state):
@@ -427,7 +414,7 @@ class ExternalResourcesManager:
427
414
  self._set_resource_reconciliation_in_progress(r, state)
428
415
 
429
416
  if spec := self.er_inventory.get(r.key):
430
- status.publish_metrics(r, spec)
417
+ reconciliation_status.publish_metrics(r, spec)
431
418
 
432
419
  pending_sync_keys = self.state_mgr.get_keys_by_status(
433
420
  ResourceStatus.PENDING_SECRET_SYNC
@@ -38,6 +38,18 @@ class ResourceStatus(StrEnum):
38
38
  PENDING_SECRET_SYNC: str = "PENDING_SECRET_SYNC"
39
39
  RECONCILIATION_REQUESTED: str = "RECONCILIATION_REQUESTED"
40
40
 
41
+ @property
42
+ def is_in_progress(self) -> bool:
43
+ return self in {ResourceStatus.IN_PROGRESS, ResourceStatus.DELETE_IN_PROGRESS}
44
+
45
+ @property
46
+ def needs_secret_sync(self) -> bool:
47
+ return self == ResourceStatus.PENDING_SECRET_SYNC
48
+
49
+ @property
50
+ def has_errors(self) -> bool:
51
+ return self == ResourceStatus.ERROR
52
+
41
53
 
42
54
  class ExternalResourceState(BaseModel):
43
55
  key: ExternalResourceKey