qontract-reconcile 0.10.1rc807__py3-none-any.whl → 0.10.1rc809__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.1rc807
3
+ Version: 0.10.1rc809
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
@@ -10,7 +10,7 @@ reconcile/aws_iam_password_reset.py,sha256=NwErtrqgBiXr7eGCAHdtGGOx0S7-4JnSc29Ie
10
10
  reconcile/aws_support_cases_sos.py,sha256=Jk6_XjDeJSYxgRGqcEAOcynt9qJF2r5HPIPcSKmoBv8,2974
11
11
  reconcile/blackbox_exporter_endpoint_monitoring.py,sha256=W_VJagnsJR1v5oqjlI3RJJE0_nhtJ0m81RS8zWA5u5c,3538
12
12
  reconcile/checkpoint.py,sha256=R2WFXUXLTB4sWMi4GeA4eegsuf_1-Q4vH8M0Toh3Ij4,5036
13
- reconcile/cli.py,sha256=n64KqkdnqF_H2WHoqlSxQ2PP0uYuY9THPGeyiLP9zJA,101154
13
+ reconcile/cli.py,sha256=q0DYN65kPT_4GmnE4tb-VczkNwEDqfAQq7d9lJ6AM-I,101474
14
14
  reconcile/closedbox_endpoint_monitoring_base.py,sha256=SMhkcQqprWvThrIJa3U_3uh5w1h-alleW1QnCJFY4Qw,4909
15
15
  reconcile/cluster_deployment_mapper.py,sha256=2Ah-nu-Mdig0pjuiZl_XLrmVAjYzFjORR3dMlCgkmw0,2352
16
16
  reconcile/dashdotdb_base.py,sha256=a5aPLVxyqPSbjdB0Ty-uliOtxwvEbbEljHJKxdK3-Zk,4813
@@ -390,7 +390,7 @@ reconcile/ocm/types.py,sha256=ibJYvzfAZyyMFkcF1bP8u3rkXciYJRplt_7Z1pKHFh0,2484
390
390
  reconcile/ocm_internal_notifications/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
391
391
  reconcile/ocm_internal_notifications/integration.py,sha256=Gw2oB1Oe1Vvbj-fN_undhkQ2y5tCVhUfW5DenKu9ybM,4395
392
392
  reconcile/ocm_labels/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
393
- reconcile/ocm_labels/integration.py,sha256=JmqjY_8QI8lgnCgXroiEfj58wkd98fOe5mTiKvkLeOQ,14946
393
+ reconcile/ocm_labels/integration.py,sha256=aOfQqZj6ftwyzm6DoV3dOpmJvfxwAdJM_nveVDN5aBQ,15212
394
394
  reconcile/oum/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
395
395
  reconcile/oum/base.py,sha256=gw5qDx3VKtIk-VW_g0j5iPdM4qAweqy0YROHJhKHt0M,13596
396
396
  reconcile/oum/labelset.py,sha256=MTOMEyBMbge3JOq0mOKWja-kV3cs0ZId9Ozxv7FJ9Kw,2185
@@ -794,8 +794,8 @@ tools/saas_metrics_exporter/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMp
794
794
  tools/saas_metrics_exporter/main.py,sha256=piocx6meMdJxoxeNz52gQGUjt5n7Fma4kgqYamszPrM,3180
795
795
  tools/saas_metrics_exporter/commit_distance/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
796
796
  tools/saas_metrics_exporter/commit_distance/channel.py,sha256=XEAh3eL8TmgMe7V2BsyxuXYWgvBBVdSJETd6Ec7cI04,2171
797
- tools/saas_metrics_exporter/commit_distance/commit_distance.py,sha256=snkcHKS7zxSIomS7psEQ13efN-j9MxKZHe0nLw55dAk,4042
798
- tools/saas_metrics_exporter/commit_distance/metrics.py,sha256=rQTcinrv3uGLnHFumS37NN3QyVv1z6HGqy8MtfOwcxM,544
797
+ tools/saas_metrics_exporter/commit_distance/commit_distance.py,sha256=nyw9N1ESrcxweWfESI-zlldDdSQGLtiuC6x7DXIjtDw,3074
798
+ tools/saas_metrics_exporter/commit_distance/metrics.py,sha256=5-y6n-sGACAS3eJ5ndY-2BFxcd0fxLfhvZmmBHu4JuA,426
799
799
  tools/sre_checkpoints/__init__.py,sha256=CDaDaywJnmRCLyl_NCcvxi-Zc0hTi_3OdwKiFOyS39I,145
800
800
  tools/sre_checkpoints/util.py,sha256=zEDbGr18ZeHNQwW8pUsr2JRjuXIPz--WAGJxZo9sv_Y,894
801
801
  tools/test/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -804,8 +804,8 @@ tools/test/test_app_interface_metrics_exporter.py,sha256=SX7qL3D1SIRKFo95FoQztvf
804
804
  tools/test/test_qontract_cli.py,sha256=_D61RFGAN5x44CY1tYbouhlGXXABwYfxKSWSQx3Jrss,4941
805
805
  tools/test/test_sd_app_sre_alert_report.py,sha256=v363r9zM7__0kR5K6mvJoGFcM9BvE33fWAayrqkpojA,2116
806
806
  tools/test/test_sre_checkpoints.py,sha256=SKqPPTl9ua0RFdSSofnoQX-JZE6dFLO3LRhfQzqtfh8,2607
807
- qontract_reconcile-0.10.1rc807.dist-info/METADATA,sha256=2hjumgGnpdb2xNCQjgY_-ihI36Osy4S-xLrUaas-wDk,2314
808
- qontract_reconcile-0.10.1rc807.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
809
- qontract_reconcile-0.10.1rc807.dist-info/entry_points.txt,sha256=GKQqCl2j2X1BJQ69een6rHcR26PmnxnONLNOQB-nRjY,491
810
- qontract_reconcile-0.10.1rc807.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
811
- qontract_reconcile-0.10.1rc807.dist-info/RECORD,,
807
+ qontract_reconcile-0.10.1rc809.dist-info/METADATA,sha256=ZiXxi9rVJ5nR4cgVYg1t46b3cdGvOuDfoPlDESF-bA8,2314
808
+ qontract_reconcile-0.10.1rc809.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
809
+ qontract_reconcile-0.10.1rc809.dist-info/entry_points.txt,sha256=GKQqCl2j2X1BJQ69een6rHcR26PmnxnONLNOQB-nRjY,491
810
+ qontract_reconcile-0.10.1rc809.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
811
+ qontract_reconcile-0.10.1rc809.dist-info/RECORD,,
reconcile/cli.py CHANGED
@@ -3489,8 +3489,15 @@ def skupper_network(ctx, thread_pool_size, internal, use_jump_host):
3489
3489
  envvar="OL_MANAGED_LABEL_PREFIXES",
3490
3490
  default="sre-capabilities",
3491
3491
  )
3492
+ @click.option(
3493
+ "--ignored-label-prefixes",
3494
+ help="A comma list of label prefixes that must be ignored.",
3495
+ required=True,
3496
+ envvar="OL_IGNORED_LABEL_PREFIXES",
3497
+ default="sre-capabilities.rhidp",
3498
+ )
3492
3499
  @click.pass_context
3493
- def ocm_labels(ctx, managed_label_prefixes):
3500
+ def ocm_labels(ctx, managed_label_prefixes, ignored_label_prefixes):
3494
3501
  from reconcile.ocm_labels.integration import (
3495
3502
  OcmLabelsIntegration,
3496
3503
  OcmLabelsIntegrationParams,
@@ -3500,6 +3507,7 @@ def ocm_labels(ctx, managed_label_prefixes):
3500
3507
  integration=OcmLabelsIntegration(
3501
3508
  OcmLabelsIntegrationParams(
3502
3509
  managed_label_prefixes=list(set(managed_label_prefixes.split(","))),
3510
+ ignored_label_prefixes=list(set(ignored_label_prefixes.split(","))),
3503
3511
  )
3504
3512
  ),
3505
3513
  ctx=ctx.obj,
@@ -63,8 +63,9 @@ QONTRACT_INTEGRATION = "ocm-labels"
63
63
 
64
64
  class OcmLabelsIntegrationParams(PydanticRunParams):
65
65
  managed_label_prefixes: list[str] = []
66
+ ignored_label_prefixes: list[str] = []
66
67
 
67
- @validator("managed_label_prefixes")
68
+ @validator("managed_label_prefixes", "ignored_label_prefixes")
68
69
  def must_end_with_dot( # pylint: disable=no-self-argument
69
70
  cls, v: list[str]
70
71
  ) -> list[str]:
@@ -250,7 +251,9 @@ class OcmLabelsIntegration(QontractReconcileIntegration[OcmLabelsIntegrationPara
250
251
  e.g. if a cluster can't be found in OCM or is not considered ready yet.
251
252
  """
252
253
  current_state = self.fetch_subscription_label_current_state(
253
- clusters, self.params.managed_label_prefixes
254
+ clusters,
255
+ self.params.managed_label_prefixes,
256
+ self.params.ignored_label_prefixes,
254
257
  )
255
258
  desired_state = self.fetch_desired_state(
256
259
  self.subscription_label_sources(clusters, query_func)
@@ -258,7 +261,10 @@ class OcmLabelsIntegration(QontractReconcileIntegration[OcmLabelsIntegrationPara
258
261
  return current_state, desired_state
259
262
 
260
263
  def fetch_subscription_label_current_state(
261
- self, clusters: Iterable[ClusterV1], managed_label_prefixes: list[str]
264
+ self,
265
+ clusters: Iterable[ClusterV1],
266
+ managed_label_prefixes: list[str],
267
+ ignored_label_prefixes: list[str],
262
268
  ) -> LabelState:
263
269
  """
264
270
  Fetches the current state of subscription labels for the given clusters.
@@ -287,6 +293,7 @@ class OcmLabelsIntegration(QontractReconcileIntegration[OcmLabelsIntegrationPara
287
293
  label: value
288
294
  for label, value in cluster_details.subscription_labels.get_values_dict().items()
289
295
  if label.startswith(tuple(managed_label_prefixes))
296
+ and not label.startswith(tuple(ignored_label_prefixes))
290
297
  }
291
298
  states[
292
299
  ClusterRef(
@@ -7,124 +7,97 @@ from reconcile.typed_queries.saas_files import SaasFile
7
7
  from reconcile.utils.secret_reader import HasSecret
8
8
  from reconcile.utils.vcs import VCS
9
9
  from tools.saas_metrics_exporter.commit_distance.channel import (
10
- Channel,
11
10
  SaasTarget,
12
11
  build_channels,
13
12
  )
14
13
  from tools.saas_metrics_exporter.commit_distance.metrics import SaasCommitDistanceGauge
15
14
 
16
15
 
17
- @dataclass
18
- class Distance:
19
- publisher: SaasTarget
20
- subscriber: SaasTarget
21
- channel: Channel
22
- distance: int = 0
23
-
24
-
25
16
  @dataclass
26
17
  class CommitDistanceMetric:
27
18
  value: float
28
19
  metric: SaasCommitDistanceGauge
29
20
 
30
21
 
31
- @dataclass
32
- class ThreadData:
22
+ @dataclass(frozen=True)
23
+ class DistanceKey:
33
24
  repo_url: str
34
25
  auth_code: HasSecret | None
35
26
  ref_from: str
36
27
  ref_to: str
37
- distance: int = 0
38
-
39
- def __hash__(self) -> int:
40
- return hash((self.repo_url, self.ref_from, self.ref_to))
41
28
 
42
29
 
43
30
  class CommitDistanceFetcher:
44
31
  def __init__(self, vcs: VCS):
45
32
  self._vcs = vcs
46
33
 
47
- def _data_key(self, repo_url: str, ref_from: str, ref_to: str) -> str:
48
- return f"{repo_url}/{ref_from}/{ref_to}"
49
-
50
- def _calculate_commit_distance(self, data: ThreadData) -> None:
51
- if data.ref_from == data.ref_to:
52
- data.distance = 0
53
- return
34
+ def _calculate_commit_distance(self, key: DistanceKey) -> tuple[DistanceKey, int]:
35
+ if key.ref_from == key.ref_to:
36
+ return key, 0
54
37
 
55
38
  commits = self._vcs.get_commits_between(
56
- repo_url=data.repo_url,
57
- auth_code=data.auth_code,
58
- commit_from=data.ref_from,
59
- commit_to=data.ref_to,
39
+ repo_url=key.repo_url,
40
+ auth_code=key.auth_code,
41
+ commit_from=key.ref_from,
42
+ commit_to=key.ref_to,
43
+ )
44
+ return key, len(commits)
45
+
46
+ @staticmethod
47
+ def _build_distance_key(
48
+ publisher: SaasTarget, subscriber: SaasTarget
49
+ ) -> DistanceKey:
50
+ return DistanceKey(
51
+ repo_url=publisher.repo_url,
52
+ auth_code=publisher.auth_code,
53
+ ref_from=subscriber.ref,
54
+ ref_to=publisher.ref,
60
55
  )
61
- data.distance = len(commits)
62
-
63
- def _populate_distances(
64
- self, distances: Iterable[Distance], thread_data: Iterable[ThreadData]
65
- ) -> None:
66
- m = {
67
- self._data_key(
68
- repo_url=d.repo_url, ref_from=d.ref_from, ref_to=d.ref_to
69
- ): d.distance
70
- for d in thread_data
71
- }
72
- for distance in distances:
73
- distance.distance = m[
74
- self._data_key(
75
- repo_url=distance.publisher.repo_url,
76
- ref_from=distance.subscriber.ref,
77
- ref_to=distance.publisher.ref,
78
- )
79
- ]
80
56
 
81
57
  def fetch(
82
- self, saas_files: Iterable[SaasFile], thread_pool_size: int
58
+ self,
59
+ saas_files: Iterable[SaasFile],
60
+ thread_pool_size: int,
83
61
  ) -> list[CommitDistanceMetric]:
84
62
  channels = build_channels(saas_files=saas_files)
85
- distances: list[Distance] = []
86
- thread_data: set[ThreadData] = set()
87
-
88
- for channel in channels:
89
- for subscriber in channel.subscribers:
90
- for publisher in channel.publishers:
91
- thread_data.add(
92
- ThreadData(
93
- repo_url=publisher.repo_url,
94
- auth_code=publisher.auth_code,
95
- ref_from=subscriber.ref,
96
- ref_to=publisher.ref,
97
- )
98
- )
99
- distances.append(
100
- Distance(
101
- publisher=publisher,
102
- subscriber=subscriber,
103
- channel=channel,
104
- )
105
- )
106
63
 
107
- threaded.run(
108
- self._calculate_commit_distance,
109
- thread_data,
110
- thread_pool_size=thread_pool_size,
111
- )
64
+ distance_keys = {
65
+ self._build_distance_key(publisher=publisher, subscriber=subscriber)
66
+ for channel in channels
67
+ for subscriber in channel.subscribers
68
+ for publisher in channel.publishers
69
+ }
112
70
 
113
- self._populate_distances(distances=distances, thread_data=thread_data)
71
+ distance_by_key = dict(
72
+ threaded.run(
73
+ self._calculate_commit_distance,
74
+ distance_keys,
75
+ thread_pool_size=thread_pool_size,
76
+ )
77
+ )
114
78
 
115
79
  commit_distance_metrics = [
116
80
  CommitDistanceMetric(
117
- value=float(distance.distance),
81
+ value=float(
82
+ distance_by_key[
83
+ self._build_distance_key(
84
+ publisher=publisher,
85
+ subscriber=subscriber,
86
+ )
87
+ ]
88
+ ),
118
89
  metric=SaasCommitDistanceGauge(
119
- channel=distance.channel.name,
120
- app=distance.publisher.app_name,
121
- publisher=distance.publisher.target_name,
122
- publisher_namespace=distance.publisher.namespace_name,
123
- subscriber=distance.subscriber.target_name,
124
- subscriber_namespace=distance.subscriber.namespace_name,
90
+ channel=channel.name,
91
+ app=publisher.app_name,
92
+ publisher=publisher.target_name,
93
+ publisher_namespace=publisher.namespace_name,
94
+ subscriber=subscriber.target_name,
95
+ subscriber_namespace=subscriber.namespace_name,
125
96
  ),
126
97
  )
127
- for distance in distances
98
+ for channel in channels
99
+ for subscriber in channel.subscribers
100
+ for publisher in channel.publishers
128
101
  ]
129
102
 
130
103
  return commit_distance_metrics
@@ -1,19 +1,12 @@
1
- from pydantic import BaseModel
2
-
3
1
  from reconcile.utils.metrics import (
4
2
  GaugeMetric,
5
3
  )
6
4
 
7
5
 
8
- class SaasBaseMetric(BaseModel):
9
- "Base class for Saas metrics"
10
-
11
- integration: str = "saas_metrics_exporter"
12
-
13
-
14
- class SaasCommitDistanceGauge(SaasBaseMetric, GaugeMetric):
6
+ class SaasCommitDistanceGauge(GaugeMetric):
15
7
  "Gauge for the commit distance between saas targets in a channel"
16
8
 
9
+ integration: str = "saas_metrics_exporter"
17
10
  channel: str
18
11
  publisher: str
19
12
  publisher_namespace: str