qontract-reconcile 0.10.1rc350__py3-none-any.whl → 0.10.1rc351__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.1rc350
3
+ Version: 0.10.1rc351
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
@@ -107,7 +107,7 @@ reconcile/terraform_cloudflare_dns.py,sha256=auU4bzeLwd4S8D8oqpqJbrCUoEdELXrgi7v
107
107
  reconcile/terraform_cloudflare_resources.py,sha256=0Xg_ISZViJtgj6cpYalANMHyPdNR6q19y60RXfa66Yw,14912
108
108
  reconcile/terraform_cloudflare_users.py,sha256=DfeSnYC9YQgXX6AbJh85tQbJUDv1e2FjiGXgcpVQlPg,13964
109
109
  reconcile/terraform_repo.py,sha256=fIVjcxqhG6DR6H8QtQM1RpE9ukanjkjp8iH0tQRhEl8,13042
110
- reconcile/terraform_resources.py,sha256=P93W2cdjrq97ffMfEgJPkoWp7E97S6AoOnooy0Z9LsU,17039
110
+ reconcile/terraform_resources.py,sha256=-VWkI-0EwNUovNcLksFBkYmAMZoB9GM_QG1pZa9ZMrg,17136
111
111
  reconcile/terraform_tgw_attachments.py,sha256=6PVhBYeIvNnz2PwBdPF0I222_83EzOWX6VKJnqz7UPo,13915
112
112
  reconcile/terraform_users.py,sha256=kXRUxCUchKCP2dbXXOzctynqMii4oyCP6bYZHQTrlTg,10202
113
113
  reconcile/terraform_vpc_peerings.py,sha256=LRW3GUaf8g9iZWILBWQukfv6YmEY_3fWpatC_op-66I,21611
@@ -480,8 +480,8 @@ reconcile/utils/elasticsearch_exceptions.py,sha256=UY5Z3y2hw7T73sPJ6dHmUybegiIop
480
480
  reconcile/utils/environ.py,sha256=u3h1FlnIcZnaAk1POVaSYW_HIvcQG-W-n2DhfSCqwuE,536
481
481
  reconcile/utils/exceptions.py,sha256=DwfnWUpVOotpP79RWZ2pycmG6nKCL00RBIeZLYkQPW4,635
482
482
  reconcile/utils/expiration.py,sha256=BXwKE50sNIV-Lszke97fxitNkLxYszoOLW1LBgp_yqg,1246
483
- reconcile/utils/external_resource_spec.py,sha256=U6GGi0e7FxhDHPPvmYhlBIfEeIzV--VKueX3Rj6aJjQ,6180
484
- reconcile/utils/external_resources.py,sha256=301hqVVDt78i88VLFTkSc5mq1KvVP4OiHh_DQX-B1G8,6492
483
+ reconcile/utils/external_resource_spec.py,sha256=y2ulJUKD0z-zS2a_imegUWIDwFketOIINJY8tNxwOtc,6636
484
+ reconcile/utils/external_resources.py,sha256=ik6NOEP_6Tg1fjOpUXVQWW_ybwmR2ieAwO4AotMoqtg,7425
485
485
  reconcile/utils/filtering.py,sha256=dw7Ok7HXjZb0ruvCWHFh194rtunX1COLDTRnNfOpwQU,418
486
486
  reconcile/utils/git.py,sha256=kgjN93MMB5mnkuNb1n53f5kldGGf5u0pBHj9YJbiE_c,1455
487
487
  reconcile/utils/git_secrets.py,sha256=897nRs7tycA3m7YYeVEbzOhI8RFrI9IJT2E0di1eJhc,1956
@@ -607,8 +607,8 @@ tools/test/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
607
607
  tools/test/test_qontract_cli.py,sha256=awwTHEc2DWlykuqGIYM0WOBoSL0KRnOraCLk3C7izis,1401
608
608
  tools/test/test_sd_app_sre_alert_report.py,sha256=JeLhgzpKCPgLvptwg_4ZvJHLVWKNG1T5845HXTkMBxA,1826
609
609
  tools/test/test_sre_checkpoints.py,sha256=SKqPPTl9ua0RFdSSofnoQX-JZE6dFLO3LRhfQzqtfh8,2607
610
- qontract_reconcile-0.10.1rc350.dist-info/METADATA,sha256=hyazkojCTs415shSZg18vJN8MKMmXtzFIeEE88a59Yk,2347
611
- qontract_reconcile-0.10.1rc350.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
612
- qontract_reconcile-0.10.1rc350.dist-info/entry_points.txt,sha256=ErVY2Jp-0Rtuq5KOtMlW5yvna4nIEuc_1YbEdEdcy9o,301
613
- qontract_reconcile-0.10.1rc350.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
614
- qontract_reconcile-0.10.1rc350.dist-info/RECORD,,
610
+ qontract_reconcile-0.10.1rc351.dist-info/METADATA,sha256=ODns-HsSTrrrk-z-CoQcRhP636UnedN65JArxgGDTSY,2347
611
+ qontract_reconcile-0.10.1rc351.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
612
+ qontract_reconcile-0.10.1rc351.dist-info/entry_points.txt,sha256=ErVY2Jp-0Rtuq5KOtMlW5yvna4nIEuc_1YbEdEdcy9o,301
613
+ qontract_reconcile-0.10.1rc351.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
614
+ qontract_reconcile-0.10.1rc351.dist-info/RECORD,,
@@ -41,6 +41,7 @@ from reconcile.utils.external_resources import (
41
41
  PROVIDER_AWS,
42
42
  get_external_resource_specs,
43
43
  managed_external_resources,
44
+ publish_metrics,
44
45
  )
45
46
  from reconcile.utils.oc import StatusCodeError
46
47
  from reconcile.utils.oc_map import (
@@ -399,6 +400,7 @@ def run(
399
400
  account_names,
400
401
  exclude_accounts,
401
402
  )
403
+ publish_metrics(resource_specs, QONTRACT_INTEGRATION.replace("_", "-"))
402
404
 
403
405
  if not dry_run and oc_map and defer:
404
406
  defer(oc_map.cleanup)
@@ -12,9 +12,11 @@ from typing import (
12
12
  )
13
13
 
14
14
  import yaml
15
+ from pydantic import BaseModel
15
16
  from pydantic.dataclasses import dataclass
16
17
 
17
18
  from reconcile import openshift_resources_base
19
+ from reconcile.utils.metrics import GaugeMetric
18
20
  from reconcile.utils.openshift_resource import (
19
21
  SECRET_MAX_KEY_LENGTH,
20
22
  OpenshiftResource,
@@ -188,6 +190,24 @@ class ExternalResourceUniqueKey:
188
190
  )
189
191
 
190
192
 
193
+ class ExternalResourceBaseMetric(BaseModel):
194
+ "Base class External Resource metrics"
195
+
196
+ integration: str
197
+
198
+
199
+ class ExternalResourceInventoryGauge(ExternalResourceBaseMetric, GaugeMetric):
200
+ "Inventory Gauge"
201
+
202
+ provision_provider: str
203
+ provisioner_name: str
204
+ provider: str
205
+
206
+ @classmethod
207
+ def name(cls) -> str:
208
+ return "external_resource_inventory"
209
+
210
+
191
211
  ExternalResourceSpecInventory = MutableMapping[
192
212
  ExternalResourceUniqueKey, ExternalResourceSpec
193
213
  ]
@@ -1,4 +1,5 @@
1
1
  import json
2
+ from collections import Counter
2
3
  from collections.abc import (
3
4
  Mapping,
4
5
  MutableMapping,
@@ -10,9 +11,16 @@ from typing import (
10
11
 
11
12
  import anymarkup
12
13
 
13
- from reconcile.utils import gql
14
+ from reconcile.utils import (
15
+ gql,
16
+ metrics,
17
+ )
14
18
  from reconcile.utils.exceptions import FetchResourceError
15
- from reconcile.utils.external_resource_spec import ExternalResourceSpec
19
+ from reconcile.utils.external_resource_spec import (
20
+ ExternalResourceInventoryGauge,
21
+ ExternalResourceSpec,
22
+ ExternalResourceSpecInventory,
23
+ )
16
24
 
17
25
  PROVIDER_AWS = "aws"
18
26
  PROVIDER_CLOUDFLARE = "cloudflare"
@@ -61,6 +69,29 @@ def managed_external_resources(namespace_info: Mapping[str, Any]) -> bool:
61
69
  return False
62
70
 
63
71
 
72
+ def get_inventory_count_combinations(
73
+ inventory: ExternalResourceSpecInventory,
74
+ ) -> Counter[tuple]:
75
+ return Counter(
76
+ (k.provision_provider, k.provisioner_name, k.provider) for k in inventory
77
+ )
78
+
79
+
80
+ def publish_metrics(inventory: ExternalResourceSpecInventory, integration: str) -> None:
81
+ count_combinations = get_inventory_count_combinations(inventory)
82
+ for combination, count in count_combinations.items():
83
+ provision_provider, provisioner_name, provider = combination
84
+ metrics.set_gauge(
85
+ ExternalResourceInventoryGauge(
86
+ integration=integration,
87
+ provision_provider=provision_provider,
88
+ provisioner_name=provisioner_name,
89
+ provider=provider,
90
+ ),
91
+ count,
92
+ )
93
+
94
+
64
95
  class ResourceValueResolver:
65
96
  """
66
97
  ExternalResourceSpec have data that's contained in different fields including the