qontract-reconcile 0.10.2.dev97__py3-none-any.whl → 0.10.2.dev99__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.4
2
2
  Name: qontract-reconcile
3
- Version: 0.10.2.dev97
3
+ Version: 0.10.2.dev99
4
4
  Summary: Collection of tools to reconcile services with their desired state as defined in the app-interface DB.
5
5
  Project-URL: homepage, https://github.com/app-sre/qontract-reconcile
6
6
  Project-URL: repository, https://github.com/app-sre/qontract-reconcile
@@ -185,10 +185,10 @@ reconcile/cna/assets/asset_factory.py,sha256=7T7X_J6xIsoGETqBRI45_EyIKEdQcnRPt_G
185
185
  reconcile/cna/assets/null.py,sha256=85mVh97atCoC0aLuX47poTZiyOthmziJeBsUw0c924w,1658
186
186
  reconcile/dynatrace_token_provider/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
187
187
  reconcile/dynatrace_token_provider/dependencies.py,sha256=FuRUnK18EyJIIgFwQBZSskIG08mN2VQAcAcaJFTf8zc,2812
188
- reconcile/dynatrace_token_provider/integration.py,sha256=ysPto7wPZW_t3KFXyWOxRNQT140Q4OOe3Eu4BX0p6Uo,26505
188
+ reconcile/dynatrace_token_provider/integration.py,sha256=RmptOa5CYrKNMZqCQhmP_AsC3L-BCKhjmM8otj6a7OY,26514
189
189
  reconcile/dynatrace_token_provider/metrics.py,sha256=oP-6NTZENFdvWiS0krnmX6tq3xyOzQ8e6vS0CZWYUuw,1496
190
190
  reconcile/dynatrace_token_provider/model.py,sha256=gkpqo5rRRueBXnIMjp4EEHqBUBuU65TRI8zpdb8GJ0A,241
191
- reconcile/dynatrace_token_provider/ocm.py,sha256=7P0AoyAhAmvH9ffKMEE3HB9sCmWvrwYcSBscsVt5964,4729
191
+ reconcile/dynatrace_token_provider/ocm.py,sha256=bryaK7xs7ygttUyZuSD9Up4laUhP6OUTr2VBbFiclpA,4298
192
192
  reconcile/dynatrace_token_provider/validate.py,sha256=40_9QmHoB3-KBc0k_0D4QO00PpNNPS-gU9Z6cIcWga8,1920
193
193
  reconcile/endpoints_discovery/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
194
194
  reconcile/endpoints_discovery/integration.py,sha256=ecjIZK_h6JO2wUhUmJlZ9pjOh60nS5aenEWGDj6YJdw,14790
@@ -207,13 +207,13 @@ reconcile/external_resources/reconciler.py,sha256=wB8cB5pmqDJ1_t5_Aly4mrULGnI3OQ
207
207
  reconcile/external_resources/secrets_sync.py,sha256=ZDxzGZ6wC4zxLhA7-L39xDRH6rzUM285gytuzmRQdlw,16208
208
208
  reconcile/external_resources/state.py,sha256=gF3ACdl7YiUlbQ4uEGrD6i_Txxqr6mT9f8IFlTQ-8dY,13176
209
209
  reconcile/fleet_labeler/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
210
- reconcile/fleet_labeler/dependencies.py,sha256=6vD9dC1pXOztWQpQCZa2ZLbXrTf50kzjtpqewRybuJ4,3169
211
- reconcile/fleet_labeler/integration.py,sha256=vMvDnQW1NXv2qWeG8ab_gguBq45UtmYErSXy6XR83d8,14149
210
+ reconcile/fleet_labeler/dependencies.py,sha256=MFiSfT25Ks0X3iQxwayNvFX_l6bQi97f3IiaNR1wtHc,3173
211
+ reconcile/fleet_labeler/integration.py,sha256=ckmVga18DgidA2u50mFnp87oDAa2pKpnuORW-PMCKVY,14157
212
212
  reconcile/fleet_labeler/merge_request.py,sha256=SfGxXInxeJzVnsTtO0ZC9-PesUJMdpKxKY9eCB6ms-g,1538
213
213
  reconcile/fleet_labeler/meta.py,sha256=lWnpH2U0PHCPXu9Ok_CPmO494qQJQ5pOuqo28s0jzIQ,146
214
214
  reconcile/fleet_labeler/metrics.py,sha256=zhcp06woGaZywTqWZf3znh6C2S2u7OHBLXalXYKuTzQ,1934
215
215
  reconcile/fleet_labeler/ocm.py,sha256=qcg1_p7nKlZG7-MQeOZos3rz6YSPAPh-HKxE3OVJwe0,4165
216
- reconcile/fleet_labeler/validate.py,sha256=gzc2tt7h9F60h7dcyJfEmsnjnfuux5Jtc_WzrIqr-5k,2541
216
+ reconcile/fleet_labeler/validate.py,sha256=Ch4fe7jXQZKl4pnvl5IxWS-dKSIuuiwdH2B7mivZoco,1654
217
217
  reconcile/fleet_labeler/vcs.py,sha256=6UHUQ08AGAHXF7629I6X-T_E1pvx96LxjS66EeOzve4,1108
218
218
  reconcile/glitchtip/README.md,sha256=rfXT6jNP9khJW65jL7I2PgoxvxgcGGuJF8NpbzufEQ4,4335
219
219
  reconcile/glitchtip/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -224,7 +224,7 @@ reconcile/glitchtip_project_alerts/integration.py,sha256=BgMx-NyV9mTuv7Sotb2OioC
224
224
  reconcile/glitchtip_project_dsn/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
225
225
  reconcile/glitchtip_project_dsn/integration.py,sha256=2iugub-kHYkHNK33n0v9_TeWonuxCPah_VkoTPvaajE,8077
226
226
  reconcile/gql_definitions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
227
- reconcile/gql_definitions/introspection.json,sha256=xA_cHhSy0wr9PG9y_Nwk75MbnjtHQjOEMd48nLZMK8E,2239784
227
+ reconcile/gql_definitions/introspection.json,sha256=-3s2bAXc064r3TJEHURAQX7_brHpdV72c-BR5_rXzpw,2239798
228
228
  reconcile/gql_definitions/acs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
229
229
  reconcile/gql_definitions/acs/acs_instances.py,sha256=L91WW9LbhJbBSrECqShQpFtjoBOsmNIYLRpMbx1io5o,2181
230
230
  reconcile/gql_definitions/acs/acs_policies.py,sha256=bN5i4mks10Z23KJSj7jqp966Osq2dps4d-sPH9gjxEA,7008
@@ -314,7 +314,7 @@ reconcile/gql_definitions/external_resources/external_resources_settings.py,sha2
314
314
  reconcile/gql_definitions/external_resources/fragments/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
315
315
  reconcile/gql_definitions/external_resources/fragments/external_resources_module_overrides.py,sha256=T_qWCRtzU8F9frebBXG9TkeQdrKGt3R9YinSngPoFqM,1262
316
316
  reconcile/gql_definitions/fleet_labeler/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
317
- reconcile/gql_definitions/fleet_labeler/fleet_labels.py,sha256=ow9LTm376Y5rCVMWgRtrj2yWKK7_aBC5AM7svLN7pKo,4546
317
+ reconcile/gql_definitions/fleet_labeler/fleet_labels.py,sha256=XPk1YFmiCtGlwrldxdABwYaT-wgZdTjpDFHmUnq6xcM,4349
318
318
  reconcile/gql_definitions/fragments/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
319
319
  reconcile/gql_definitions/fragments/aus_organization.py,sha256=uBKbTuBa3CZmTXR5HOcGhRcu2U9kM93KbYmoWTxcpB0,4767
320
320
  reconcile/gql_definitions/fragments/aws_account_common.py,sha256=3-7ZAP6GSff7Z2Syz2VQCLY4IySqBOSVmceaRiVNQpw,2385
@@ -786,7 +786,7 @@ tools/saas_promotion_state/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJ
786
786
  tools/saas_promotion_state/saas_promotion_state.py,sha256=UfwwRLS5Ya4_Nh1w5n1dvoYtchQvYE9yj1VANt2IKqI,3925
787
787
  tools/sre_checkpoints/__init__.py,sha256=CDaDaywJnmRCLyl_NCcvxi-Zc0hTi_3OdwKiFOyS39I,145
788
788
  tools/sre_checkpoints/util.py,sha256=zEDbGr18ZeHNQwW8pUsr2JRjuXIPz--WAGJxZo9sv_Y,894
789
- qontract_reconcile-0.10.2.dev97.dist-info/METADATA,sha256=KiU0I9ajpxPWox3p0C64xeanHOSJ1CxNhJjgBDfTcrA,24565
790
- qontract_reconcile-0.10.2.dev97.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
791
- qontract_reconcile-0.10.2.dev97.dist-info/entry_points.txt,sha256=5i9l54La3vQrDLAdwDKQWC0iG4sV9RRfOb1BpvzOWLc,698
792
- qontract_reconcile-0.10.2.dev97.dist-info/RECORD,,
789
+ qontract_reconcile-0.10.2.dev99.dist-info/METADATA,sha256=DAqORQ1nXWb46jLn2koRabedQbqn4-T2-nb3KzCNClM,24565
790
+ qontract_reconcile-0.10.2.dev99.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
791
+ qontract_reconcile-0.10.2.dev99.dist-info/entry_points.txt,sha256=5i9l54La3vQrDLAdwDKQWC0iG4sV9RRfOb1BpvzOWLc,698
792
+ qontract_reconcile-0.10.2.dev99.dist-info/RECORD,,
@@ -16,7 +16,7 @@ from reconcile.dynatrace_token_provider.metrics import (
16
16
  from reconcile.dynatrace_token_provider.model import DynatraceAPIToken, K8sSecret
17
17
  from reconcile.dynatrace_token_provider.ocm import (
18
18
  DTP_LABEL_SEARCH,
19
- DTP_TENANT_LABEL,
19
+ DTP_TENANT_V2_LABEL,
20
20
  Cluster,
21
21
  OCMClient,
22
22
  )
@@ -172,10 +172,10 @@ class DynatraceTokenProviderIntegration(QontractReconcileIntegration[NoParams]):
172
172
  _expose_errors_as_service_log(
173
173
  ocm_client,
174
174
  cluster_uuid=cluster.external_id,
175
- error=f"Missing label {DTP_TENANT_LABEL}",
175
+ error=f"Missing label {DTP_TENANT_V2_LABEL}",
176
176
  )
177
177
  logging.warn(
178
- f"[{cluster.id=}] Missing value for label {DTP_TENANT_LABEL}"
178
+ f"[{cluster.id=}] Missing value for label {DTP_TENANT_V2_LABEL}"
179
179
  )
180
180
  continue
181
181
  if (
@@ -1,5 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
+ import logging
3
4
  from collections.abc import Mapping
4
5
  from datetime import timedelta
5
6
  from typing import Any
@@ -34,10 +35,7 @@ from reconcile.utils.ocm_base_client import (
34
35
  Thin abstractions of reconcile.ocm module to reduce coupling.
35
36
  """
36
37
 
37
- DTP_TENANT_LABEL = sre_capability_label_key("dtp", "tenant")
38
- DTP_SPEC_LABEL = sre_capability_label_key("dtp", "token-spec")
39
38
  DTP_LABEL_SEARCH = sre_capability_label_key("dtp", "%")
40
-
41
39
  DTP_TENANT_V2_LABEL = sre_capability_label_key("dtp.v2", "tenant")
42
40
  DTP_SPEC_V2_LABEL = sre_capability_label_key("dtp.v2", "token-spec")
43
41
 
@@ -51,24 +49,14 @@ class Cluster(BaseModel):
51
49
  is_hcp: bool
52
50
 
53
51
  @staticmethod
54
- def from_cluster_details(cluster: ClusterDetails) -> Cluster:
52
+ def from_cluster_details(cluster: ClusterDetails) -> Cluster | None:
55
53
  dt_tenant = cluster.labels.get_label_value(DTP_TENANT_V2_LABEL)
56
54
  token_spec_name = cluster.labels.get_label_value(DTP_SPEC_V2_LABEL)
57
-
58
- # TODO: remove these fallbacks APPSRE-11584
59
- if not dt_tenant:
60
- dt_tenant = cluster.labels.get_label_value(DTP_TENANT_LABEL)
61
- if not token_spec_name:
62
- token_spec_name = cluster.labels.get_label_value(DTP_SPEC_LABEL)
63
- if not token_spec_name:
64
- """
65
- We want to stay backwards compatible.
66
- Earlier version of DTP did not set a value for the label.
67
- We fall back to a default token in that case.
68
-
69
- Long-term, we want to remove this behavior.
70
- """
71
- token_spec_name = "hypershift-management-cluster-v1"
55
+ if not dt_tenant or not token_spec_name:
56
+ logging.warning(
57
+ f"[Missing DTP labels] {cluster.ocm_cluster.id=} {cluster.ocm_cluster.subscription.id=} {dt_tenant=} {token_spec_name=}"
58
+ )
59
+ return None
72
60
  return Cluster(
73
61
  id=cluster.ocm_cluster.id,
74
62
  external_id=cluster.ocm_cluster.external_id,
@@ -131,10 +119,11 @@ class OCMClient:
131
119
 
132
120
  def discover_clusters_by_labels(self, label_filter: Filter) -> list[Cluster]:
133
121
  return [
134
- Cluster.from_cluster_details(cluster)
135
- for cluster in discover_clusters_by_labels(
122
+ cluster
123
+ for ocm_cluster in discover_clusters_by_labels(
136
124
  ocm_api=self._ocm_client, label_filter=label_filter
137
125
  )
126
+ if (cluster := Cluster.from_cluster_details(ocm_cluster))
138
127
  ]
139
128
 
140
129
  def create_service_log(
@@ -61,10 +61,10 @@ def _ocm_clients(secret_reader: SecretReaderBase) -> dict[str, OCMClient]:
61
61
  for spec in get_fleet_label_specs():
62
62
  ocm_base_client = init_ocm_base_client(
63
63
  cfg=OCMClientConfig(
64
- url=spec.ocm.environment.url,
65
- access_token_client_id=spec.ocm.access_token_client_id,
66
- access_token_url=spec.ocm.access_token_url,
67
- access_token_client_secret=spec.ocm.access_token_client_secret,
64
+ url=spec.ocm_env.url,
65
+ access_token_client_id=spec.ocm_env.access_token_client_id,
66
+ access_token_url=spec.ocm_env.access_token_url,
67
+ access_token_client_secret=spec.ocm_env.access_token_client_secret,
68
68
  ),
69
69
  secret_reader=secret_reader,
70
70
  )
@@ -257,7 +257,7 @@ class FleetLabelerIntegration(QontractReconcileIntegration[NoParams]):
257
257
  f"[{spec.name}] Cluster ID {cluster_id} is matched multiple times by different label matchers:\n{label_matches}"
258
258
  )
259
259
  metrics.set_duplicate_cluster_matches_gauge(
260
- ocm_name=spec.ocm.name,
260
+ ocm_name=spec.ocm_env.name,
261
261
  spec_name=spec.name,
262
262
  value=len(clusters_with_duplicate_matches),
263
263
  )
@@ -291,7 +291,7 @@ class FleetLabelerIntegration(QontractReconcileIntegration[NoParams]):
291
291
  )
292
292
  )
293
293
  metrics.set_label_rendering_error_gauge(
294
- ocm_name=spec.ocm.name,
294
+ ocm_name=spec.ocm_env.name,
295
295
  spec_name=spec.name,
296
296
  value=label_rendering_errors_cnt,
297
297
  )
@@ -3,22 +3,9 @@ from collections.abc import Mapping
3
3
 
4
4
  from reconcile.gql_definitions.fleet_labeler.fleet_labels import (
5
5
  FleetLabelsSpecV1,
6
- OpenShiftClusterManagerV1,
7
6
  )
8
7
 
9
8
 
10
- class OCMAccessTokenClientIdMissing(Exception):
11
- pass
12
-
13
-
14
- class OCMAccessTokenClientSecretMissing(Exception):
15
- pass
16
-
17
-
18
- class OCMAccessTokenUrlMissing(Exception):
19
- pass
20
-
21
-
22
9
  class MatchLabelsNotUniqueError(Exception):
23
10
  pass
24
11
 
@@ -28,7 +15,6 @@ def validate_label_specs(specs: Mapping[str, FleetLabelsSpecV1]) -> None:
28
15
  We cannot catch all potential errors through json schema definition.
29
16
  """
30
17
  for spec in specs.values():
31
- _validate_ocm_token_spec(spec.ocm)
32
18
  _validate_match_labels(spec)
33
19
  _validate_unique_ocm_managed_label_combo(spec)
34
20
 
@@ -63,21 +49,3 @@ def _validate_match_labels(spec: FleetLabelsSpecV1) -> None:
63
49
  raise MatchLabelsNotUniqueError(
64
50
  f"The 'matchSubscriptionLabels' combinations must be unique within a spec. Found duplicates in spec {spec.name} for matchers: {duplicates}"
65
51
  )
66
-
67
-
68
- def _validate_ocm_token_spec(ocm: OpenShiftClusterManagerV1) -> None:
69
- """
70
- OCM tokens are optional in the schema. Lets verify they exist.
71
- """
72
- if not ocm.access_token_client_id:
73
- raise OCMAccessTokenClientIdMissing(
74
- f"accessTokenClientId missing in ocm spec '{ocm.name}'"
75
- )
76
- if not ocm.access_token_client_secret:
77
- raise OCMAccessTokenClientSecretMissing(
78
- f"accessTokenClientSecret missing in ocm spec '{ocm.name}'"
79
- )
80
- if not ocm.access_token_url:
81
- raise OCMAccessTokenUrlMissing(
82
- f"accessTokenUrl missing in ocm spec '{ocm.name}'"
83
- )
@@ -34,11 +34,9 @@ query FleetLabelSpecs {
34
34
  path
35
35
  managedSubscriptionLabelPrefix
36
36
  dryRunLabelSynchronization
37
- ocm {
37
+ ocmEnv {
38
38
  name
39
- environment {
40
- url
41
- }
39
+ url
42
40
  accessTokenClientId
43
41
  accessTokenClientSecret {
44
42
  ... VaultSecret
@@ -75,15 +73,11 @@ class ConfiguredBaseModel(BaseModel):
75
73
 
76
74
 
77
75
  class OpenShiftClusterManagerEnvironmentV1(ConfiguredBaseModel):
78
- url: str = Field(..., alias="url")
79
-
80
-
81
- class OpenShiftClusterManagerV1(ConfiguredBaseModel):
82
76
  name: str = Field(..., alias="name")
83
- environment: OpenShiftClusterManagerEnvironmentV1 = Field(..., alias="environment")
84
- access_token_client_id: Optional[str] = Field(..., alias="accessTokenClientId")
85
- access_token_client_secret: Optional[VaultSecret] = Field(..., alias="accessTokenClientSecret")
86
- access_token_url: Optional[str] = Field(..., alias="accessTokenUrl")
77
+ url: str = Field(..., alias="url")
78
+ access_token_client_id: str = Field(..., alias="accessTokenClientId")
79
+ access_token_client_secret: VaultSecret = Field(..., alias="accessTokenClientSecret")
80
+ access_token_url: str = Field(..., alias="accessTokenUrl")
87
81
 
88
82
 
89
83
  class ResourceV1(ConfiguredBaseModel):
@@ -115,7 +109,7 @@ class FleetLabelsSpecV1(ConfiguredBaseModel):
115
109
  path: str = Field(..., alias="path")
116
110
  managed_subscription_label_prefix: str = Field(..., alias="managedSubscriptionLabelPrefix")
117
111
  dry_run_label_synchronization: Optional[bool] = Field(..., alias="dryRunLabelSynchronization")
118
- ocm: OpenShiftClusterManagerV1 = Field(..., alias="ocm")
112
+ ocm_env: OpenShiftClusterManagerEnvironmentV1 = Field(..., alias="ocmEnv")
119
113
  label_defaults: list[FleetLabelDefaultV1] = Field(..., alias="labelDefaults")
120
114
  clusters: list[FleetClusterV1] = Field(..., alias="clusters")
121
115
 
@@ -34382,7 +34382,7 @@
34382
34382
  "deprecationReason": null
34383
34383
  },
34384
34384
  {
34385
- "name": "ocm",
34385
+ "name": "ocmEnv",
34386
34386
  "description": null,
34387
34387
  "args": [],
34388
34388
  "type": {
@@ -34390,7 +34390,7 @@
34390
34390
  "name": null,
34391
34391
  "ofType": {
34392
34392
  "kind": "OBJECT",
34393
- "name": "OpenShiftClusterManager_v1",
34393
+ "name": "OpenShiftClusterManagerEnvironment_v1",
34394
34394
  "ofType": null
34395
34395
  }
34396
34396
  },