qontract-reconcile 0.10.1rc570__py3-none-any.whl → 0.10.1rc572__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.1rc570
3
+ Version: 0.10.1rc572
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
@@ -111,7 +111,7 @@ reconcile/terraform_cloudflare_dns.py,sha256=auU4bzeLwd4S8D8oqpqJbrCUoEdELXrgi7v
111
111
  reconcile/terraform_cloudflare_resources.py,sha256=EbQQaoDnZ7brvRCpbFtwlD7KLk2hDVNcjhrJGaAywEk,15023
112
112
  reconcile/terraform_cloudflare_users.py,sha256=1EbTHwJgiPkJpMP-Ag340QNgGK3mXn3dcC3DpLakudM,13987
113
113
  reconcile/terraform_repo.py,sha256=c0GZFuY3rCm6VHjHqYbsgOHrEkRWKF_1LrMThsn2XDw,16127
114
- reconcile/terraform_resources.py,sha256=FcKs-uOs9nfSiw0dptxGTWx81SyEbYEpsBzf36QgEAQ,19277
114
+ reconcile/terraform_resources.py,sha256=UJfygWCnLJAouAXU7EYpF-GBtqujeypMsWq04HZTE-A,18981
115
115
  reconcile/terraform_tgw_attachments.py,sha256=_g7QSHM03YZzTU7O189S4HYtUn7WmwOBq67G4AieU24,15298
116
116
  reconcile/terraform_users.py,sha256=kXRUxCUchKCP2dbXXOzctynqMii4oyCP6bYZHQTrlTg,10202
117
117
  reconcile/terraform_vpc_peerings.py,sha256=rnDH1u93OyzrBM8Hib0HwSnlxZtx4ScRQaZAcn3mx-k,25402
@@ -684,8 +684,8 @@ tools/test/test_app_interface_metrics_exporter.py,sha256=SX7qL3D1SIRKFo95FoQztvf
684
684
  tools/test/test_qontract_cli.py,sha256=EzJwaPxQw5CLPahLjh91oRT0pi1WCgOXZ_KgiNXZMAw,2948
685
685
  tools/test/test_sd_app_sre_alert_report.py,sha256=v363r9zM7__0kR5K6mvJoGFcM9BvE33fWAayrqkpojA,2116
686
686
  tools/test/test_sre_checkpoints.py,sha256=SKqPPTl9ua0RFdSSofnoQX-JZE6dFLO3LRhfQzqtfh8,2607
687
- qontract_reconcile-0.10.1rc570.dist-info/METADATA,sha256=MlJjPGrNHvVZL-tF-LOn6-xk9mijT6zEQxw6kR61t9Q,2349
688
- qontract_reconcile-0.10.1rc570.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
689
- qontract_reconcile-0.10.1rc570.dist-info/entry_points.txt,sha256=rTjAv28I_CHLM8ID3OPqMI_suoQ9s7tFbim4aYjn9kk,376
690
- qontract_reconcile-0.10.1rc570.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
691
- qontract_reconcile-0.10.1rc570.dist-info/RECORD,,
687
+ qontract_reconcile-0.10.1rc572.dist-info/METADATA,sha256=U_kZ2W_VzF9JNSsRJk_sIZoEY0O04tGxQSHQmaTDxqo,2349
688
+ qontract_reconcile-0.10.1rc572.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
689
+ qontract_reconcile-0.10.1rc572.dist-info/entry_points.txt,sha256=rTjAv28I_CHLM8ID3OPqMI_suoQ9s7tFbim4aYjn9kk,376
690
+ qontract_reconcile-0.10.1rc572.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
691
+ qontract_reconcile-0.10.1rc572.dist-info/RECORD,,
@@ -4,6 +4,7 @@ from collections.abc import (
4
4
  Iterable,
5
5
  Mapping,
6
6
  )
7
+ from dataclasses import asdict
7
8
  from typing import (
8
9
  Any,
9
10
  Collection,
@@ -13,6 +14,7 @@ from typing import (
13
14
  cast,
14
15
  )
15
16
 
17
+ from deepdiff import DeepHash
16
18
  from sretoolbox.utils import (
17
19
  retry,
18
20
  threaded,
@@ -21,7 +23,6 @@ from sretoolbox.utils import (
21
23
  import reconcile.openshift_base as ob
22
24
  from reconcile import queries
23
25
  from reconcile.aws_iam_keys import run as disable_keys
24
- from reconcile.change_owners.diff import IDENTIFIER_FIELD_NAME
25
26
  from reconcile.gql_definitions.terraform_resources.terraform_resources_namespaces import (
26
27
  NamespaceV1,
27
28
  )
@@ -37,7 +38,6 @@ from reconcile.utils.extended_early_exit import (
37
38
  extended_early_exit_run,
38
39
  )
39
40
  from reconcile.utils.external_resource_spec import (
40
- ExternalResourceSpec,
41
41
  ExternalResourceSpecInventory,
42
42
  )
43
43
  from reconcile.utils.external_resources import (
@@ -533,38 +533,41 @@ def runner(
533
533
 
534
534
  def early_exit_desired_state(*args: Any, **kwargs: Any) -> dict[str, Any]:
535
535
  gqlapi = gql.get_api()
536
- namespaces = get_tf_namespaces()
537
- resources = []
538
- for ns_info in namespaces:
536
+ state_for_accounts = {
537
+ account["name"]: {
538
+ "meta": account,
539
+ "specs": {},
540
+ }
541
+ for account in queries.get_aws_accounts(terraform_state=True)
542
+ }
543
+ for ns_info in get_tf_namespaces():
539
544
  for spec in get_external_resource_specs(
540
545
  ns_info.dict(by_alias=True), provision_provider=PROVIDER_AWS
541
546
  ):
542
-
543
- def register_resource(
544
- spec: ExternalResourceSpec, resource: Optional[dict[str, Any]]
545
- ) -> None:
546
- if resource:
547
- resources.append({
548
- IDENTIFIER_FIELD_NAME: f"{spec.cluster_name}/{spec.namespace_name}/{spec.provisioner_name}/{spec.provider}/{spec.identifier}/{resource.get('path')}",
549
- "content_sha": resource.get("sha256sum"),
550
- "provisioner": spec.provisioner_name,
551
- })
552
-
553
- defaults = spec.resource.get("defaults")
554
- if defaults:
555
- register_resource(spec, gqlapi.get_resource(defaults))
556
- parameter_group = spec.resource.get("parameter_group")
557
- if parameter_group:
558
- register_resource(spec, gqlapi.get_resource(parameter_group))
559
- for spec_item in spec.resource.get("specs") or []:
560
- defaults = spec_item.get("defaults")
561
- if defaults:
562
- register_resource(spec, gqlapi.get_resource(defaults))
547
+ resource_paths = [
548
+ spec.resource.get("defaults"),
549
+ spec.resource.get("parameter_group"),
550
+ ] + [
551
+ spec_item.get("defaults")
552
+ for spec_item in spec.resource.get("specs") or []
553
+ ]
554
+ resources = {
555
+ resource["path"]: resource["sha256sum"]
556
+ for path in resource_paths
557
+ if path and (resource := gqlapi.get_resource(path))
558
+ }
559
+ spec_state = {
560
+ "spec": asdict(spec),
561
+ "resources": resources,
562
+ }
563
+ spec_id = f"{spec.cluster_name}/{spec.namespace_name}/{spec.provisioner_name}/{spec.provider}/{spec.identifier}"
564
+ state_for_accounts[spec.provisioner_name][spec_id] = spec_state
563
565
 
564
566
  return {
565
- "accounts": queries.get_aws_accounts(terraform_state=True),
566
- "namespaces": [ns.dict(by_alias=True) for ns in namespaces],
567
- "resources": resources,
567
+ "state": {
568
+ account: {"shard": account, "hash": DeepHash(state).get(state)}
569
+ for account, state in state_for_accounts.items()
570
+ }
568
571
  }
569
572
 
570
573
 
@@ -572,10 +575,6 @@ def desired_state_shard_config() -> DesiredStateShardConfig:
572
575
  return DesiredStateShardConfig(
573
576
  shard_arg_name="account_name",
574
577
  shard_arg_is_collection=True,
575
- shard_path_selectors={
576
- "accounts[*].name",
577
- "namespaces[*].externalResources[*].provisioner.name",
578
- "resources[*].provisioner",
579
- },
578
+ shard_path_selectors={"state.*.shard"},
580
579
  sharded_run_review=lambda proposal: len(proposal.proposed_shards) <= 2,
581
580
  )