qontract-reconcile 0.9.1rc164__py3-none-any.whl → 0.9.1rc165__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.9.1rc164
3
+ Version: 0.9.1rc165
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
@@ -108,7 +108,7 @@ reconcile/quay_mirror.py,sha256=9pwl1gLzRpsVXF5yPULM4ET_C5F8_xPmH8Mv8AS2AfI,1340
108
108
  reconcile/quay_mirror_org.py,sha256=E1OdRe-ppxTkNCwu20iVRhEdG1fPDBroLY02NgiMN7c,10381
109
109
  reconcile/quay_permissions.py,sha256=_3PCWjNWoU7VHlYgHzUevvL_jJmEMsWfXV_nzjeiyhU,4099
110
110
  reconcile/quay_repos.py,sha256=7609RBVQihis96FNOOe-i9tCTYwcTVy4WpKAL6HpnkU,7031
111
- reconcile/queries.py,sha256=SZ0Ud0ffph6lD-UEVdjyCGXyz7zS8X8QN3FSYJ-zS5I,57742
111
+ reconcile/queries.py,sha256=NRpanRc0Q9TdBisfTUs7qLbtN6h8mxi8yxnYyrXycnA,57638
112
112
  reconcile/query_validator.py,sha256=oLEZIAsQCzxmmZ7b9dSw-OKuEjpI1dbVu4XfCfjpmi8,1503
113
113
  reconcile/requests_sender.py,sha256=m00QET0mh6rys5r0y5uurZS7RIylXf04HU1dTdhjt0A,3791
114
114
  reconcile/resource_scraper.py,sha256=vo1N9vLJCYWvXlTwFRIpEuWjx_39ZV9zxJlpoPq4g3U,2330
@@ -128,7 +128,7 @@ reconcile/terraform_aws_route53.py,sha256=U_6MoiGC61fnGTITbdEeXYogzoToG6g3a-JnVE
128
128
  reconcile/terraform_cloudflare_dns.py,sha256=fut76uLzA9FPSh3kDGo2oTyfhDMlh16_p4P5CeNbEtc,11858
129
129
  reconcile/terraform_cloudflare_resources.py,sha256=kLFW7JFRr3_zNtw1kxed8YJFyHojUFQVBL2nEyr5drs,7028
130
130
  reconcile/terraform_cloudflare_users.py,sha256=lTbrxi8OtW9Pfcr7Yp-70ihldMQKx9dJ7ZgbGHey1XE,13627
131
- reconcile/terraform_resources.py,sha256=1xiQB1Hd3VhJQdNw-DoPOp66iHg8Ue8MD-qIDZTZBRc,21818
131
+ reconcile/terraform_resources.py,sha256=GJtbB37YEUznHJ2ZNVPMVENeyEqIkB57iHUT3P4MxWI,21888
132
132
  reconcile/terraform_tgw_attachments.py,sha256=c8aDE6g0i9PmJQOQMq2GhKNeIOu8LGE-fK9RhCYHBjU,7443
133
133
  reconcile/terraform_users.py,sha256=AzDvEQCdLpsXoS3nLbIQRraQvJHa8JmL40lZFv8YXMk,9321
134
134
  reconcile/terraform_vpc_peerings.py,sha256=0W9OyOal7RqUQeWRlr3M1FZtityDHy5NZDGWtdDoO-M,21006
@@ -436,7 +436,7 @@ reconcile/utils/state.py,sha256=LKI3d0A5AbUZgUe9IHU2s9SP-zDMnYZbOrHK8hHx92Q,7195
436
436
  reconcile/utils/structs.py,sha256=B05uQsZLxl4a-wLqiUTJ8ccr1dkjG_UbleMY2jrqoe0,296
437
437
  reconcile/utils/template.py,sha256=wTvRU4AnAV_o042tD4Mwls2dwWMuk7MKnde3MaCjaYg,331
438
438
  reconcile/utils/terraform_client.py,sha256=9eDnk-3NWV0847cGvRQDC-vZPZ5DTkFYxa6ewYiYSAQ,27605
439
- reconcile/utils/terrascript_aws_client.py,sha256=KlHw_abhtrIltXsrH3DZLxUg5VJMxacKklrHos4og1c,248363
439
+ reconcile/utils/terrascript_aws_client.py,sha256=qJvEUxfkrN2fKLi3cMWYIapI9F3NXHT28-51rge_Np8,248618
440
440
  reconcile/utils/throughput.py,sha256=iP4UWAe2LVhDo69mPPmgo9nQ7RxHD6_GS8MZe-aSiuM,344
441
441
  reconcile/utils/unleash.py,sha256=xY8fXxJApZhYnhJHmqNAK1YPNWf6larzDtk0VuNvn08,2875
442
442
  reconcile/utils/vault.py,sha256=L0zamAiM39Vskv-uF_rcQf5iKvo1zSN0oU4UYRwBFhM,14375
@@ -482,8 +482,8 @@ tools/sre_checkpoints/util.py,sha256=zEDbGr18ZeHNQwW8pUsr2JRjuXIPz--WAGJxZo9sv_Y
482
482
  tools/test/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
483
483
  tools/test/test_qontract_cli.py,sha256=awwTHEc2DWlykuqGIYM0WOBoSL0KRnOraCLk3C7izis,1401
484
484
  tools/test/test_sre_checkpoints.py,sha256=SKqPPTl9ua0RFdSSofnoQX-JZE6dFLO3LRhfQzqtfh8,2607
485
- qontract_reconcile-0.9.1rc164.dist-info/METADATA,sha256=LcfNXIQP59di8kjIiUsOqFcH7S3wyZQiTH36PElzOkk,2259
486
- qontract_reconcile-0.9.1rc164.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
487
- qontract_reconcile-0.9.1rc164.dist-info/entry_points.txt,sha256=3BPvsRryM1C4S_mb5kXmP5AVv-wJBzVCrOJyv6qUmc0,195
488
- qontract_reconcile-0.9.1rc164.dist-info/top_level.txt,sha256=j0CHPIc8TsVRB50wOz_jhxjjaRyCJB3NOQeXhuHS67c,34
489
- qontract_reconcile-0.9.1rc164.dist-info/RECORD,,
485
+ qontract_reconcile-0.9.1rc165.dist-info/METADATA,sha256=JFfNy_B07IUmZyM1ZszYDfuw2ZhePNdLwbPinoFIsko,2259
486
+ qontract_reconcile-0.9.1rc165.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
487
+ qontract_reconcile-0.9.1rc165.dist-info/entry_points.txt,sha256=3BPvsRryM1C4S_mb5kXmP5AVv-wJBzVCrOJyv6qUmc0,195
488
+ qontract_reconcile-0.9.1rc165.dist-info/top_level.txt,sha256=j0CHPIc8TsVRB50wOz_jhxjjaRyCJB3NOQeXhuHS67c,34
489
+ qontract_reconcile-0.9.1rc165.dist-info/RECORD,,
reconcile/queries.py CHANGED
@@ -2586,6 +2586,23 @@ def get_unleash_instances():
2586
2586
  return gqlapi.query(UNLEASH_INSTANCES_QUERY)["unleash_instances"]
2587
2587
 
2588
2588
 
2589
+ DNS_RECORD = """
2590
+ name
2591
+ type
2592
+ ttl
2593
+ alias {
2594
+ name
2595
+ zone_id
2596
+ evaluate_target_health
2597
+ }
2598
+ weighted_routing_policy {
2599
+ weight
2600
+ }
2601
+ set_identifier
2602
+ records
2603
+ """
2604
+
2605
+
2589
2606
  DNS_ZONES_QUERY = """
2590
2607
  {
2591
2608
  zones: dns_zone_v1 {
@@ -2607,24 +2624,7 @@ DNS_ZONES_QUERY = """
2607
2624
  region
2608
2625
  }
2609
2626
  records {
2610
- name
2611
- type
2612
- ttl
2613
- alias {
2614
- name
2615
- zone_id
2616
- evaluate_target_health
2617
- }
2618
- weighted_routing_policy {
2619
- weight
2620
- }
2621
- geolocation_routing_policy {
2622
- continent
2623
- country
2624
- subdivision
2625
- }
2626
- set_identifier
2627
- records
2627
+ %s
2628
2628
  _healthcheck {
2629
2629
  fqdn
2630
2630
  port
@@ -2662,7 +2662,9 @@ DNS_ZONES_QUERY = """
2662
2662
  }
2663
2663
  }
2664
2664
  }
2665
- """
2665
+ """ % (
2666
+ indent(DNS_RECORD, 6 * " "),
2667
+ )
2666
2668
 
2667
2669
 
2668
2670
  def get_dns_zones(account_name=None):
@@ -358,6 +358,9 @@ provider
358
358
  name
359
359
  output_resource_name
360
360
  annotations
361
+ records {
362
+ %s
363
+ }
361
364
  }
362
365
  ... on NamespaceTerraformResourceRosaAuthenticator_V1 {
363
366
  region
@@ -385,7 +388,9 @@ provider
385
388
  annotations
386
389
  defaults
387
390
  }
388
- """
391
+ """ % (
392
+ indent(queries.DNS_RECORD, 4 * " "),
393
+ )
389
394
 
390
395
 
391
396
  TF_NAMESPACES_QUERY = """
@@ -229,6 +229,7 @@ VARIABLE_KEYS = [
229
229
  "vpce_id",
230
230
  "fifo_topic",
231
231
  "subscriptions",
232
+ "records",
232
233
  "extra_tags",
233
234
  ]
234
235
 
@@ -845,41 +846,50 @@ class TerrascriptClient: # pylint: disable=too-many-public-methods
845
846
  zone_resource = aws_route53_zone(zone_res_name, **zone_values)
846
847
  self.add_resource(acct_name, zone_resource)
847
848
 
848
- counts = {}
849
- for record in zone["records"]:
850
- record_fqdn = f"{record['name']}.{zone['name']}"
851
- record_id = safe_resource_id(f"{record_fqdn}_{record['type'].upper()}")
852
-
853
- # Count record names so we can generate unique IDs
854
- if record_id not in counts:
855
- counts[record_id] = 0
856
- counts[record_id] += 1
857
-
858
- # If more than one record with a given name, append _{count}
859
- if counts[record_id] > 1:
860
- record_id = f"{record_id}_{counts[record_id]}"
861
-
862
- # Use default TTL if none is specified
863
- # or if this record is an alias
864
- # None/zero is accepted but not a good default
865
- if not record.get("alias") and record.get("ttl") is None:
866
- record["ttl"] = default_ttl
867
-
868
- # Define healthcheck if needed
869
- healthcheck = record.pop("healthcheck", None)
870
- if healthcheck:
871
- healthcheck_id = record_id
872
- healthcheck_values = {**healthcheck}
873
- healthcheck_resource = aws_route53_health_check(
874
- healthcheck_id, **healthcheck_values
875
- )
876
- self.add_resource(acct_name, healthcheck_resource)
877
- # Assign the healthcheck resource ID to the record
878
- record["health_check_id"] = f"${{{healthcheck_resource.id}}}"
849
+ self.populate_route53_records(acct_name, zone, zone_resource, default_ttl)
850
+
851
+ def populate_route53_records(
852
+ self,
853
+ acct_name: str,
854
+ zone: dict[str, Any],
855
+ zone_resource: aws_route53_zone,
856
+ default_ttl: int = 300,
857
+ ):
858
+ counts = {}
859
+ for record in zone.get("records") or []:
860
+ record_fqdn = f"{record['name']}.{zone['name']}"
861
+ record_id = safe_resource_id(f"{record_fqdn}_{record['type'].upper()}")
862
+
863
+ # Count record names so we can generate unique IDs
864
+ if record_id not in counts:
865
+ counts[record_id] = 0
866
+ counts[record_id] += 1
867
+
868
+ # If more than one record with a given name, append _{count}
869
+ if counts[record_id] > 1:
870
+ record_id = f"{record_id}_{counts[record_id]}"
871
+
872
+ # Use default TTL if none is specified
873
+ # or if this record is an alias
874
+ # None/zero is accepted but not a good default
875
+ if not record.get("alias") and record.get("ttl") is None:
876
+ record["ttl"] = default_ttl
877
+
878
+ # Define healthcheck if needed
879
+ healthcheck = record.pop("healthcheck", None)
880
+ if healthcheck:
881
+ healthcheck_id = record_id
882
+ healthcheck_values = {**healthcheck}
883
+ healthcheck_resource = aws_route53_health_check(
884
+ healthcheck_id, **healthcheck_values
885
+ )
886
+ self.add_resource(acct_name, healthcheck_resource)
887
+ # Assign the healthcheck resource ID to the record
888
+ record["health_check_id"] = f"${{{healthcheck_resource.id}}}"
879
889
 
880
- record_values = {"zone_id": f"${{{zone_resource.id}}}", **record}
881
- record_resource = aws_route53_record(record_id, **record_values)
882
- self.add_resource(acct_name, record_resource)
890
+ record_values = {"zone_id": f"${{{zone_resource.id}}}", **record}
891
+ record_resource = aws_route53_record(record_id, **record_values)
892
+ self.add_resource(acct_name, record_resource)
883
893
 
884
894
  def populate_vpc_peerings(self, desired_state):
885
895
  for item in desired_state:
@@ -5114,6 +5124,7 @@ class TerrascriptClient: # pylint: disable=too-many-public-methods
5114
5124
  zone_id = safe_resource_id(identifier)
5115
5125
  zone_tf_resource = aws_route53_zone(zone_id, **values)
5116
5126
  tf_resources.append(zone_tf_resource)
5127
+ self.populate_route53_records(account, common_values, zone_tf_resource)
5117
5128
 
5118
5129
  policy = {
5119
5130
  "Version": "2012-10-17",