qontract-reconcile 0.10.2.dev332__py3-none-any.whl → 0.10.2.dev334__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.4
2
2
  Name: qontract-reconcile
3
- Version: 0.10.2.dev332
3
+ Version: 0.10.2.dev334
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
@@ -152,7 +152,7 @@ reconcile/aws_saml_idp/integration.py,sha256=rop8ahl7v0WUheSgVLb-4MU3Ldy6Eb3LknF
152
152
  reconcile/aws_saml_roles/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
153
153
  reconcile/aws_saml_roles/integration.py,sha256=mLRCnSfClp2ia8UynSmY5HZe5YmrJTc1RwxyMeU2yBw,11319
154
154
  reconcile/aws_version_sync/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
155
- reconcile/aws_version_sync/integration.py,sha256=hB97__QCJXAd1pRGs7h1-T5SWVYqZBb2eigXYW7YO7g,20011
155
+ reconcile/aws_version_sync/integration.py,sha256=s53FHoEFyeqGN3Mql9Fxo3wTpG7e9IIePhoA9Cbh-Gc,21364
156
156
  reconcile/aws_version_sync/utils.py,sha256=x-45QT7zAwdNvCg7w_qJNwLaksFcfz1_6KQoD_0IVuA,1727
157
157
  reconcile/aws_version_sync/merge_request_manager/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
158
158
  reconcile/aws_version_sync/merge_request_manager/merge_request.py,sha256=2FbqLLdqxycWNvX1eNbwMjWSVBb7q0p-8t5Db0m7b4Q,4842
@@ -796,7 +796,7 @@ tools/saas_promotion_state/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJ
796
796
  tools/saas_promotion_state/saas_promotion_state.py,sha256=uQv2QJAmUXP1g2GPIH30WTlvL9soY6m9lefpZEVDM5w,3965
797
797
  tools/sre_checkpoints/__init__.py,sha256=CDaDaywJnmRCLyl_NCcvxi-Zc0hTi_3OdwKiFOyS39I,145
798
798
  tools/sre_checkpoints/util.py,sha256=KcYVfa3UmJHVP_ocgrKe8NkrO5IDB9aWEDydSokPcRk,975
799
- qontract_reconcile-0.10.2.dev332.dist-info/METADATA,sha256=hwAOcicRlD8UQ2VE8S2-LRRSpFHahqnOdNWnMfK4Zlc,24916
800
- qontract_reconcile-0.10.2.dev332.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
801
- qontract_reconcile-0.10.2.dev332.dist-info/entry_points.txt,sha256=5i9l54La3vQrDLAdwDKQWC0iG4sV9RRfOb1BpvzOWLc,698
802
- qontract_reconcile-0.10.2.dev332.dist-info/RECORD,,
799
+ qontract_reconcile-0.10.2.dev334.dist-info/METADATA,sha256=t36GOtTwC5j50jVkjdrq7IyTsg3-heBRHIfHmvzbl6I,24916
800
+ qontract_reconcile-0.10.2.dev334.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
801
+ qontract_reconcile-0.10.2.dev334.dist-info/entry_points.txt,sha256=5i9l54La3vQrDLAdwDKQWC0iG4sV9RRfOb1BpvzOWLc,698
802
+ qontract_reconcile-0.10.2.dev334.dist-info/RECORD,,
@@ -104,7 +104,6 @@ class ExternalResource(BaseModel):
104
104
  self.provisioner.uid,
105
105
  self.resource_provider,
106
106
  self.resource_identifier,
107
- self.resource_engine,
108
107
  )
109
108
 
110
109
  @validator("resource_engine_version", pre=True)
@@ -220,6 +219,7 @@ class AVSIntegration(QontractReconcileIntegration[AVSIntegrationParams]):
220
219
  clusters: Iterable[ClusterV1],
221
220
  timeout: int,
222
221
  elasticache_replication_group_id_to_identifier: ReplicationGroupIdToIdentifier,
222
+ supported_providers: Iterable[str],
223
223
  prom_get_func: Callable = prom_get,
224
224
  ) -> list[ExternalResource]:
225
225
  metrics: list[ExternalResource] = []
@@ -232,81 +232,123 @@ class AVSIntegration(QontractReconcileIntegration[AVSIntegrationParams]):
232
232
  )
233
233
 
234
234
  # RDS resources
235
- try:
236
- rds_metrics = prom_get_func(
237
- url=cluster.prometheus_url,
238
- params={"query": "aws_resources_exporter_rds_engineversion"},
239
- token=token,
240
- timeout=timeout,
235
+ if SupportedResourceProvider.RDS in supported_providers:
236
+ metrics.extend(
237
+ self._fetch_rds_metrics(cluster, token, timeout, prom_get_func)
241
238
  )
242
239
 
243
- for m in rds_metrics:
244
- try:
245
- metrics.append(
246
- ExternalResource(
247
- provider="aws",
248
- provisioner=ExternalResourceProvisioner(
249
- uid=m["aws_account_id"]
250
- ),
251
- resource_provider=SupportedResourceProvider.RDS,
252
- resource_identifier=m["dbinstance_identifier"],
253
- resource_engine=m["engine"],
254
- resource_engine_version=m["engine_version"],
255
- )
256
- )
257
- except ValidationError:
258
- # don't try to parse AWS extended support version numbers
259
- # See https://aws.amazon.com/about-aws/whats-new/2025/04/amazon-rds-postgresql-extended-support-11-22-rds-20250220-12-22-rds-20250220/ for more info
260
- if (
261
- EXTENDED_SUPPORT_VERSION_INDICATOR
262
- not in m["engine_version"]
263
- ):
264
- raise
265
- except Exception as e:
266
- logging.error(
267
- f"Failed to parse RDS metric for {m['dbinstance_identifier']}: {e}"
268
- )
269
- except Exception as e:
240
+ # ElastiCache resources
241
+ if SupportedResourceProvider.ELASTICACHE in supported_providers:
242
+ metrics.extend(
243
+ self._fetch_elasticache_metrics(
244
+ cluster,
245
+ token,
246
+ timeout,
247
+ elasticache_replication_group_id_to_identifier,
248
+ prom_get_func,
249
+ )
250
+ )
251
+
252
+ return metrics
253
+
254
+ def _fetch_rds_metrics(
255
+ self,
256
+ cluster: ClusterV1,
257
+ token: str | None,
258
+ timeout: int,
259
+ prom_get_func: Callable,
260
+ ) -> list[ExternalResource]:
261
+ """Fetch RDS metrics from the AWS resource exporter."""
262
+ metrics: list[ExternalResource] = []
263
+ try:
264
+ rds_metrics = prom_get_func(
265
+ url=cluster.prometheus_url,
266
+ params={"query": "aws_resources_exporter_rds_engineversion"},
267
+ token=token,
268
+ timeout=timeout,
269
+ )
270
+ except Exception as e:
271
+ logging.error(
272
+ f"Failed to get 'aws_resources_exporter_rds_engineversion' metrics for cluster {cluster.name}: {e}"
273
+ )
274
+ return []
275
+
276
+ for m in rds_metrics:
277
+ try:
278
+ metrics.append(
279
+ ExternalResource(
280
+ provider="aws",
281
+ provisioner=ExternalResourceProvisioner(
282
+ uid=m["aws_account_id"]
283
+ ),
284
+ resource_provider=SupportedResourceProvider.RDS,
285
+ resource_identifier=m["dbinstance_identifier"],
286
+ resource_engine=m["engine"],
287
+ resource_engine_version=m["engine_version"],
288
+ )
289
+ )
290
+ except ValidationError as e:
291
+ if EXTENDED_SUPPORT_VERSION_INDICATOR in m["engine_version"]:
292
+ # don't try to parse AWS extended support version numbers
293
+ # See https://aws.amazon.com/about-aws/whats-new/2025/04/amazon-rds-postgresql-extended-support-11-22-rds-20250220-12-22-rds-20250220/ for more info
294
+ pass
295
+ else:
296
+ logging.error(
297
+ f"Failed to parse RDS metric for {m['dbinstance_identifier']}: {e}"
298
+ )
299
+ except KeyError as e:
270
300
  logging.error(
271
- f"Failed to get 'aws_resources_exporter_rds_engineversion' metrics for cluster {cluster.name}: {e}"
301
+ f"Failed to parse RDS metric for {m['dbinstance_identifier']}: {e}"
272
302
  )
303
+ return metrics
273
304
 
274
- # ElastiCache resources
305
+ def _fetch_elasticache_metrics(
306
+ self,
307
+ cluster: ClusterV1,
308
+ token: str | None,
309
+ timeout: int,
310
+ elasticache_replication_group_id_to_identifier: ReplicationGroupIdToIdentifier,
311
+ prom_get_func: Callable,
312
+ ) -> list[ExternalResource]:
313
+ """Fetch ElastiCache metrics from the AWS resource exporter."""
314
+ metrics: list[ExternalResource] = []
315
+ try:
316
+ elasticache_metrics = prom_get_func(
317
+ url=cluster.prometheus_url,
318
+ params={"query": "aws_resources_exporter_elasticache_redisversion"},
319
+ token=token,
320
+ timeout=timeout,
321
+ )
322
+ except Exception as e:
323
+ logging.error(
324
+ f"Failed to get 'aws_resources_exporter_elasticache_redisversion' metrics for cluster {cluster.name}: {e}"
325
+ )
326
+ return []
327
+
328
+ for m in elasticache_metrics:
275
329
  try:
276
- elasticache_metrics = prom_get_func(
277
- url=cluster.prometheus_url,
278
- params={"query": "aws_resources_exporter_elasticache_redisversion"},
279
- token=token,
280
- timeout=timeout,
330
+ metrics.append(
331
+ ExternalResource(
332
+ provider="aws",
333
+ provisioner=ExternalResourceProvisioner(
334
+ uid=m["aws_account_id"]
335
+ ),
336
+ resource_provider=SupportedResourceProvider.ELASTICACHE,
337
+ # replication_group_id != resource_identifier!
338
+ resource_identifier=elasticache_replication_group_id_to_identifier.get(
339
+ (
340
+ m["aws_account_id"],
341
+ m["replication_group_id"],
342
+ ),
343
+ m["replication_group_id"],
344
+ ),
345
+ resource_engine=m["engine"],
346
+ resource_engine_version=m["engine_version"],
347
+ )
281
348
  )
282
- for m in elasticache_metrics:
283
- try:
284
- metrics.append(
285
- ExternalResource(
286
- provider="aws",
287
- provisioner=ExternalResourceProvisioner(
288
- uid=m["aws_account_id"]
289
- ),
290
- resource_provider=SupportedResourceProvider.ELASTICACHE,
291
- # replication_group_id != resource_identifier!
292
- resource_identifier=elasticache_replication_group_id_to_identifier.get(
293
- (
294
- m["aws_account_id"],
295
- m["replication_group_id"],
296
- ),
297
- m["replication_group_id"],
298
- ),
299
- resource_engine=m["engine"],
300
- resource_engine_version=m["engine_version"],
301
- )
302
- )
303
- except Exception as e:
304
- logging.error(
305
- f"Failed to parse ElastiCache metrics for {m['replication_group_id']}: {e}"
306
- )
307
- except Exception as e:
349
+ except (ValidationError, KeyError) as e:
308
350
  logging.error(
309
- f"Failed to get 'aws_resources_exporter_elasticache_redisversion' metrics for cluster {cluster.name}: {e}"
351
+ f"Failed to parse ElastiCache metrics for {m['replication_group_id']}: {e}"
310
352
  )
311
353
 
312
354
  return metrics
@@ -353,8 +395,8 @@ class AVSIntegration(QontractReconcileIntegration[AVSIntegrationParams]):
353
395
  resource.provider == SupportedResourceProvider.ELASTICACHE
354
396
  and str(values["engine_version"]).lower().endswith("x")
355
397
  ):
356
- # AWS ElastiCache Redis 6 could use a version like 6.x. Then, we don't need to manage it
357
- continue
398
+ # AWS ElastiCache Redis 6 could use a version like 6.x. Let's patch it to a fix version
399
+ values["engine_version"] = "6.2"
358
400
 
359
401
  if (
360
402
  resource.provider == SupportedResourceProvider.RDS
@@ -400,7 +442,9 @@ class AVSIntegration(QontractReconcileIntegration[AVSIntegrationParams]):
400
442
  key=lambda r: r.key,
401
443
  equal=lambda external_resources_app_interface,
402
444
  external_resources_aws: external_resources_app_interface.resource_engine_version_string
403
- == external_resources_aws.resource_engine_version_string,
445
+ == external_resources_aws.resource_engine_version_string
446
+ and external_resources_app_interface.resource_engine
447
+ == external_resources_aws.resource_engine,
404
448
  )
405
449
  for diff_pair in diff.change.values():
406
450
  aws_resource = diff_pair.desired
@@ -408,6 +452,8 @@ class AVSIntegration(QontractReconcileIntegration[AVSIntegrationParams]):
408
452
  if (
409
453
  aws_resource.resource_engine_version
410
454
  <= app_interface_resource.resource_engine_version
455
+ and aws_resource.resource_engine
456
+ == app_interface_resource.resource_engine
411
457
  ):
412
458
  # do not downgrade the version
413
459
  continue
@@ -422,7 +468,7 @@ class AVSIntegration(QontractReconcileIntegration[AVSIntegrationParams]):
422
468
  provisioner_uid=app_interface_resource.provisioner.uid,
423
469
  resource_provider=app_interface_resource.resource_provider,
424
470
  resource_identifier=app_interface_resource.resource_identifier,
425
- resource_engine=app_interface_resource.resource_engine,
471
+ resource_engine=aws_resource.resource_engine,
426
472
  resource_engine_version=aws_resource.resource_engine_version_string,
427
473
  )
428
474
  )
@@ -475,6 +521,7 @@ class AVSIntegration(QontractReconcileIntegration[AVSIntegrationParams]):
475
521
  for external_resource in external_resources_app_interface
476
522
  if external_resource.redis_replication_group_id
477
523
  },
524
+ supported_providers=self.params.supported_providers,
478
525
  )
479
526
 
480
527
  self.reconcile(