qontract-reconcile 0.10.1rc703__py3-none-any.whl → 0.10.1rc705__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.1rc703
3
+ Version: 0.10.1rc705
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
@@ -92,7 +92,7 @@ reconcile/quay_mirror.py,sha256=9NzbNoxl-NdD8CwImcXNG5xTdHmUJxBfeVk5XHH41J8,1488
92
92
  reconcile/quay_mirror_org.py,sha256=Oq-t3kSkgfeSAOUDjLCDRBeEvOIEBacfX38qrX_s0oc,10801
93
93
  reconcile/quay_permissions.py,sha256=9KOutS1w4RFQqkvMSy54VtsKNx56-phzP6yI_rEW-B8,4244
94
94
  reconcile/quay_repos.py,sha256=cuEYG0HUe0ut5yvLdEwOF5-CmccpXQHRb_wDazvDrvQ,6895
95
- reconcile/queries.py,sha256=NFYbAkPkffZDU6rW1tn9r16jjLSmqWLPKBO6FkSbUWg,50829
95
+ reconcile/queries.py,sha256=hgQizeUT5_a1ZI9i8wH-ajr7e956u5ynIp90zKMeRCA,50560
96
96
  reconcile/query_validator.py,sha256=BAjGrU8_VhzTOv5k0-uz0hY9ziZyconv8VAhgre1Auc,1497
97
97
  reconcile/requests_sender.py,sha256=914iluuF4UVgG3VyxxtnHOu4yf6YKS2fIy6PViSsFTQ,3875
98
98
  reconcile/resource_scraper.py,sha256=vo1N9vLJCYWvXlTwFRIpEuWjx_39ZV9zxJlpoPq4g3U,2330
@@ -136,8 +136,9 @@ reconcile/aus/version_gates/ingress_gate_handler.py,sha256=ZCtyggBzzcb0prtdbMpJs
136
136
  reconcile/aus/version_gates/ocp_gate_handler.py,sha256=RW1ppDaCZXVegV9AzzqYXxDUu_Z_7d43Z5h2Pk_piKc,716
137
137
  reconcile/aus/version_gates/sts_version_gate_handler.py,sha256=PhJ7yBh2q-rv9CJcfFhc0H11nyDyG7NAryNS3F74xdY,3697
138
138
  reconcile/aws_account_manager/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
139
- reconcile/aws_account_manager/integration.py,sha256=TLlhxnHXRCVz2GYJQei-dBdSpeLseEkoVUwHhgi41fk,13804
139
+ reconcile/aws_account_manager/integration.py,sha256=eYWP5zrLwSOYcAN8ym0RxU1Gri_Fwovho_X1AxUQMXc,15049
140
140
  reconcile/aws_account_manager/merge_request_manager.py,sha256=zZct3NxWMBQupl4QfD7ULxnt4ipt_2FBoH_NusboIuw,3781
141
+ reconcile/aws_account_manager/metrics.py,sha256=YB10ea4kIGwJfs5N14RF-RoXPb-QQWaDBz1jLZ3YWE0,917
141
142
  reconcile/aws_account_manager/reconciler.py,sha256=AqAA3TIEfuYzIogHSBgwYTebxbTy1D6JhcxdLiOfCsc,13588
142
143
  reconcile/aws_account_manager/utils.py,sha256=K4rAjEMK-eQ_Sv4lOf6dPynQy97xZ4h-n6cJn5Z6zVw,1248
143
144
  reconcile/aws_ami_cleanup/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -145,7 +146,7 @@ reconcile/aws_ami_cleanup/integration.py,sha256=IW95cpMj2P5ffs-AxsR_TDQCJnYFBhLI
145
146
  reconcile/aws_cloudwatch_log_retention/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
146
147
  reconcile/aws_cloudwatch_log_retention/integration.py,sha256=0UcSZIrGvnGY4m9fj87oejIolIP_qTxtJInpmW9jrQ0,7772
147
148
  reconcile/aws_saml_idp/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
148
- reconcile/aws_saml_idp/integration.py,sha256=q0usjBp79aydlcD8kAq-5T2NKhZgEblGLvBBPHiJdKw,4956
149
+ reconcile/aws_saml_idp/integration.py,sha256=uqec-EnxnfGOgQtg33S-Q1wTCv0sVBHNo02aT94hXrw,4807
149
150
  reconcile/aws_saml_roles/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
150
151
  reconcile/aws_saml_roles/integration.py,sha256=kC4Rnbuy07TMvZO4rjUEcQkJev10M0Ro6r7YXcB7j_c,9530
151
152
  reconcile/aws_version_sync/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -753,8 +754,8 @@ tools/test/test_app_interface_metrics_exporter.py,sha256=SX7qL3D1SIRKFo95FoQztvf
753
754
  tools/test/test_qontract_cli.py,sha256=UEwAW7PA_GIrbqzaLxpkCxbuVjEFLNvnVG-6VyoCGIc,4147
754
755
  tools/test/test_sd_app_sre_alert_report.py,sha256=v363r9zM7__0kR5K6mvJoGFcM9BvE33fWAayrqkpojA,2116
755
756
  tools/test/test_sre_checkpoints.py,sha256=SKqPPTl9ua0RFdSSofnoQX-JZE6dFLO3LRhfQzqtfh8,2607
756
- qontract_reconcile-0.10.1rc703.dist-info/METADATA,sha256=yoAayu5zHJZhZK0IqR21e6WKXEMXcnLSXPoQ9gd52a8,2382
757
- qontract_reconcile-0.10.1rc703.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
758
- qontract_reconcile-0.10.1rc703.dist-info/entry_points.txt,sha256=rIxI5zWtHNlfpDeq1a7pZXAPoqf7HG32KMTN3MeWK_8,429
759
- qontract_reconcile-0.10.1rc703.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
760
- qontract_reconcile-0.10.1rc703.dist-info/RECORD,,
757
+ qontract_reconcile-0.10.1rc705.dist-info/METADATA,sha256=YtGSBbEgiTX-KjpVXGWDJUurUpGAlTHRnByM79rRMd4,2382
758
+ qontract_reconcile-0.10.1rc705.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
759
+ qontract_reconcile-0.10.1rc705.dist-info/entry_points.txt,sha256=rIxI5zWtHNlfpDeq1a7pZXAPoqf7HG32KMTN3MeWK_8,429
760
+ qontract_reconcile-0.10.1rc705.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
761
+ qontract_reconcile-0.10.1rc705.dist-info/RECORD,,
@@ -5,6 +5,11 @@ from typing import Any
5
5
  import jinja2
6
6
 
7
7
  from reconcile.aws_account_manager.merge_request_manager import MergeRequestManager
8
+ from reconcile.aws_account_manager.metrics import (
9
+ NonOrgAccountCounter,
10
+ OrgAccountCounter,
11
+ PayerAccountCounter,
12
+ )
8
13
  from reconcile.aws_account_manager.reconciler import AWSReconciler
9
14
  from reconcile.aws_account_manager.utils import validate
10
15
  from reconcile.gql_definitions.aws_account_manager.aws_accounts import (
@@ -18,7 +23,7 @@ from reconcile.gql_definitions.aws_account_manager.aws_accounts import (
18
23
  from reconcile.typed_queries.app_interface_repo_url import get_app_interface_repo_url
19
24
  from reconcile.typed_queries.github_orgs import get_github_orgs
20
25
  from reconcile.typed_queries.gitlab_instances import get_gitlab_instances
21
- from reconcile.utils import gql
26
+ from reconcile.utils import gql, metrics
22
27
  from reconcile.utils.aws_api_typed.api import AWSApi, AWSStaticCredentials
23
28
  from reconcile.utils.aws_api_typed.iam import AWSAccessKey
24
29
  from reconcile.utils.defer import defer
@@ -297,6 +302,31 @@ class AwsAccountMgmtIntegration(
297
302
  ) as account_aws_api:
298
303
  self.reconcile_account(account_aws_api, reconciler, account)
299
304
 
305
+ def expose_metrics(
306
+ self,
307
+ payer_accounts: list[AWSAccountV1],
308
+ non_organization_accounts: list[AWSAccountV1],
309
+ ) -> None:
310
+ """Expose metrics."""
311
+ with metrics.transactional_metrics(self.name) as metrics_container:
312
+ metrics_container.set_gauge(
313
+ PayerAccountCounter(flavor=self.params.flavor),
314
+ value=len(payer_accounts),
315
+ )
316
+
317
+ for payer_account in payer_accounts:
318
+ metrics_container.set_gauge(
319
+ OrgAccountCounter(
320
+ flavor=self.params.flavor,
321
+ payer_account=payer_account.name,
322
+ ),
323
+ value=sum([len(payer_account.organization_accounts or [])]),
324
+ )
325
+ metrics_container.set_gauge(
326
+ NonOrgAccountCounter(flavor=self.params.flavor),
327
+ value=len(non_organization_accounts),
328
+ )
329
+
300
330
  @defer
301
331
  def run(self, dry_run: bool, defer: Callable | None = None) -> None:
302
332
  """Run the integration."""
@@ -328,6 +358,11 @@ class AwsAccountMgmtIntegration(
328
358
  account_template = gql_api.get_resource(path=self.params.account_tmpl_resource)[
329
359
  "content"
330
360
  ]
361
+
362
+ self.expose_metrics(
363
+ payer_accounts=payer_accounts,
364
+ non_organization_accounts=non_organization_accounts,
365
+ )
331
366
  self.reconcile_payer_accounts(
332
367
  reconciler=reconciler,
333
368
  merge_request_manager=merge_request_manager,
@@ -0,0 +1,39 @@
1
+ from pydantic import BaseModel
2
+
3
+ from reconcile.utils.metrics import GaugeMetric
4
+
5
+
6
+ class BaseMetric(BaseModel):
7
+ """Base class for all AWS account manager metrics."""
8
+
9
+ flavor: str
10
+
11
+ @classmethod
12
+ def name(cls) -> str:
13
+ return "aws_account_manager"
14
+
15
+
16
+ class PayerAccountCounter(BaseMetric, GaugeMetric):
17
+ """Number of managed payer accounts."""
18
+
19
+ @classmethod
20
+ def name(cls) -> str:
21
+ return super().name() + "_payer_account_count"
22
+
23
+
24
+ class OrgAccountCounter(BaseMetric, GaugeMetric):
25
+ """Number of managed organization accounts per payer account."""
26
+
27
+ payer_account: str
28
+
29
+ @classmethod
30
+ def name(cls) -> str:
31
+ return super().name() + "_org_account_count"
32
+
33
+
34
+ class NonOrgAccountCounter(BaseMetric, GaugeMetric):
35
+ """Number of managed non-organization accounts."""
36
+
37
+ @classmethod
38
+ def name(cls) -> str:
39
+ return super().name() + "_non_org_account_count"
@@ -76,8 +76,6 @@ class AwsSamlIdpIntegration(QontractReconcileIntegration[AwsSamlIdpIntegrationPa
76
76
  for account in data.accounts or []
77
77
  if integration_is_enabled(self.name, account)
78
78
  and (not account_name or account.name == account_name)
79
- # a new account does not have a terraform state yet, ignore it until terraform-init does its job
80
- and account.terraform_state
81
79
  ]
82
80
 
83
81
  def build_saml_idp_config(
reconcile/queries.py CHANGED
@@ -583,13 +583,7 @@ def get_aws_accounts(
583
583
  ecrs=ecrs,
584
584
  cleanup=cleanup,
585
585
  )
586
- accounts = gqlapi.query(query)["accounts"]
587
- if terraform_state:
588
- # a new account does not have a terraform state yet, ignore it until terraform-init does its job
589
- return [
590
- account for account in accounts if account.get("terraformState") is not None
591
- ]
592
- return accounts
586
+ return gqlapi.query(query)["accounts"]
593
587
 
594
588
 
595
589
  def get_state_aws_accounts(reset_passwords=False):