qontract-reconcile 0.10.1rc1050__py3-none-any.whl → 0.10.1rc1052__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.1rc1050
3
+ Version: 0.10.1rc1052
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=q96mwr2KeEQ5bpNniGlgIMZTxiuLSodcYfX-t
10
10
  reconcile/aws_support_cases_sos.py,sha256=hl_9L53yQYRQxKs3IWrd69Cc60XK067g_bJRM9B0udo,2975
11
11
  reconcile/blackbox_exporter_endpoint_monitoring.py,sha256=O1wFp52EyF538c6txaWBs8eMtUIy19gyHZ6VzJ6QXS8,3512
12
12
  reconcile/checkpoint.py,sha256=_JhMxrye5BgkRMxWYuf7Upli6XayPINKSsuo3ynHTRc,5010
13
- reconcile/cli.py,sha256=2Qxyuwrp90j9Pox_2px5LZDn8oomwrQuFtdY85xMBOE,107389
13
+ reconcile/cli.py,sha256=JCKHmEpzb1MnjtyBlyRPo27J2z03J1rrQ680Nlu7_m8,106890
14
14
  reconcile/closedbox_endpoint_monitoring_base.py,sha256=rLh16BOlBOxTmJ8Si3wWyyEpmMlhh4Znx1Gc36qsmOc,4865
15
15
  reconcile/cluster_deployment_mapper.py,sha256=5gumAaRCcFXsabUJ1dnuUy9WrP_FEEM5JnOnE8ch9sE,2326
16
16
  reconcile/dashdotdb_base.py,sha256=l34QDu1G96_Ctnh7ZXdxXgSeCE93GQMdLAkWxmN6vDA,4775
@@ -181,7 +181,7 @@ reconcile/cna/assets/asset_factory.py,sha256=7T7X_J6xIsoGETqBRI45_EyIKEdQcnRPt_G
181
181
  reconcile/cna/assets/null.py,sha256=85mVh97atCoC0aLuX47poTZiyOthmziJeBsUw0c924w,1658
182
182
  reconcile/dynatrace_token_provider/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
183
183
  reconcile/dynatrace_token_provider/dependencies.py,sha256=FuRUnK18EyJIIgFwQBZSskIG08mN2VQAcAcaJFTf8zc,2812
184
- reconcile/dynatrace_token_provider/integration.py,sha256=Il2DIgeeOjaVtI8A7ou4SbWCo7vpiAopwDxhn5geaEo,25691
184
+ reconcile/dynatrace_token_provider/integration.py,sha256=Wgjv6UkMmPa8V0baHt0zk9sv5KENVeaStdIY1j7DKqE,26049
185
185
  reconcile/dynatrace_token_provider/metrics.py,sha256=oP-6NTZENFdvWiS0krnmX6tq3xyOzQ8e6vS0CZWYUuw,1496
186
186
  reconcile/dynatrace_token_provider/model.py,sha256=gkpqo5rRRueBXnIMjp4EEHqBUBuU65TRI8zpdb8GJ0A,241
187
187
  reconcile/dynatrace_token_provider/ocm.py,sha256=66XfJact_PZoa9c8Wz0t_n8N6aSMRQpfPLgKHYtWf8s,4307
@@ -665,7 +665,7 @@ reconcile/utils/differ.py,sha256=kJmUp9ZffFPSUEviaAw3s9c92ErwRJeHaRexGPai7wA,764
665
665
  reconcile/utils/disabled_integrations.py,sha256=z1ZGUOKjZ99R-YZ68w1xnLQ_wUccI27NcmdzfK9TARs,1077
666
666
  reconcile/utils/dnsutils.py,sha256=VX4gDQXpiMYVuT0pvNbzzSgfqmsWOM2qtjNQHUyIYF8,370
667
667
  reconcile/utils/early_exit_cache.py,sha256=9zj4ksXCq2qK2oGO0zW9aZ5tkjC5sRCms0ismZOmBv4,8725
668
- reconcile/utils/elasticsearch_exceptions.py,sha256=UY5Z3y2hw7T73sPJ6dHmUybegiIophrKFdTfdsOa6UY,379
668
+ reconcile/utils/elasticsearch_exceptions.py,sha256=zMuP0B8Y3U0u64ZrmAyzw2RWALPs9uS7IzKcF7Prx0U,501
669
669
  reconcile/utils/environ.py,sha256=psk07d2xyjbUzjOCDdNWgavaNolL_t2sq3sn2gFfY9k,507
670
670
  reconcile/utils/exceptions.py,sha256=DwfnWUpVOotpP79RWZ2pycmG6nKCL00RBIeZLYkQPW4,635
671
671
  reconcile/utils/expiration.py,sha256=3JaXH4psksR7z262k7FmdyREjCLqm66OpVMEbcfdWRo,1213
@@ -725,7 +725,7 @@ reconcile/utils/state.py,sha256=W0_awkLAPX18hNOF_60o73tkPxDUylqbzYNHfl_sDsk,1638
725
725
  reconcile/utils/structs.py,sha256=LcbLEg8WxfRqM6nW7NhcWN0YeqF7SQzxOgntmLs1SgY,352
726
726
  reconcile/utils/template.py,sha256=wTvRU4AnAV_o042tD4Mwls2dwWMuk7MKnde3MaCjaYg,331
727
727
  reconcile/utils/terraform_client.py,sha256=jHTkqqJk1HQh2vZP1FkEeDOiMlO-SKmX8oYuS7lzO_o,34672
728
- reconcile/utils/terrascript_aws_client.py,sha256=eshIGXo9HQkAAANhO_mdL3a7M7A6NbMMlc8nj61k6Lk,278034
728
+ reconcile/utils/terrascript_aws_client.py,sha256=ctNT-TQSMxNicVIjR1gM2OZWzNc_BG820COSXb_E-CE,278933
729
729
  reconcile/utils/three_way_diff_strategy.py,sha256=oQcHXd9LVhirJfoaOBoHUYuZVGfyL2voKr6KVI34zZE,4833
730
730
  reconcile/utils/throughput.py,sha256=iP4UWAe2LVhDo69mPPmgo9nQ7RxHD6_GS8MZe-aSiuM,344
731
731
  reconcile/utils/vault.py,sha256=9GSNHku8tw5KM2LKpZ1myWYDLtLGUJgpSnD0DxbzeO0,14956
@@ -867,8 +867,8 @@ tools/test/test_qontract_cli.py,sha256=_D61RFGAN5x44CY1tYbouhlGXXABwYfxKSWSQx3Jr
867
867
  tools/test/test_saas_promotion_state.py,sha256=dy4kkSSAQ7bC0Xp2CociETGN-2aABEfL6FU5D9Jl00Y,6056
868
868
  tools/test/test_sd_app_sre_alert_report.py,sha256=v363r9zM7__0kR5K6mvJoGFcM9BvE33fWAayrqkpojA,2116
869
869
  tools/test/test_sre_checkpoints.py,sha256=SKqPPTl9ua0RFdSSofnoQX-JZE6dFLO3LRhfQzqtfh8,2607
870
- qontract_reconcile-0.10.1rc1050.dist-info/METADATA,sha256=jaTxzV1Ruwt2BUFyy5WMHueI5w-NoghTWsBX968vJqg,2213
871
- qontract_reconcile-0.10.1rc1050.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
872
- qontract_reconcile-0.10.1rc1050.dist-info/entry_points.txt,sha256=GKQqCl2j2X1BJQ69een6rHcR26PmnxnONLNOQB-nRjY,491
873
- qontract_reconcile-0.10.1rc1050.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
874
- qontract_reconcile-0.10.1rc1050.dist-info/RECORD,,
870
+ qontract_reconcile-0.10.1rc1052.dist-info/METADATA,sha256=vApqFMxNENnXiau-v2JHl7G_NMa4KoDW4q9N9CAFcvM,2213
871
+ qontract_reconcile-0.10.1rc1052.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
872
+ qontract_reconcile-0.10.1rc1052.dist-info/entry_points.txt,sha256=GKQqCl2j2X1BJQ69een6rHcR26PmnxnONLNOQB-nRjY,491
873
+ qontract_reconcile-0.10.1rc1052.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
874
+ qontract_reconcile-0.10.1rc1052.dist-info/RECORD,,
reconcile/cli.py CHANGED
@@ -3107,26 +3107,14 @@ def cluster_auth_rhidp(ctx):
3107
3107
  @integration.command(
3108
3108
  short_help="Automatically provide dedicated Dynatrace tokens to management clusters"
3109
3109
  )
3110
- @click.option(
3111
- "--ocm-org-ids",
3112
- help="A comma seperated list of OCM organization IDs DTP should operate on. If none is specified, all organizations are considered.",
3113
- required=False,
3114
- envvar="DTP_OCM_ORG_IDS",
3115
- )
3116
3110
  @click.pass_context
3117
- def dynatrace_token_provider(ctx, ocm_org_ids):
3111
+ def dynatrace_token_provider(ctx):
3118
3112
  from reconcile.dynatrace_token_provider.integration import (
3119
3113
  DynatraceTokenProviderIntegration,
3120
- DynatraceTokenProviderIntegrationParams,
3121
3114
  )
3122
3115
 
3123
- parsed_ocm_org_ids = set(ocm_org_ids.split(",")) if ocm_org_ids else None
3124
3116
  run_class_integration(
3125
- integration=DynatraceTokenProviderIntegration(
3126
- DynatraceTokenProviderIntegrationParams(
3127
- ocm_organization_ids=parsed_ocm_org_ids,
3128
- )
3129
- ),
3117
+ integration=DynatraceTokenProviderIntegration(),
3130
3118
  ctx=ctx.obj,
3131
3119
  )
3132
3120
 
@@ -38,7 +38,7 @@ from reconcile.utils.ocm.base import (
38
38
  )
39
39
  from reconcile.utils.ocm.labels import subscription_label_filter
40
40
  from reconcile.utils.runtime.integration import (
41
- PydanticRunParams,
41
+ NoParams,
42
42
  QontractReconcileIntegration,
43
43
  )
44
44
 
@@ -46,10 +46,6 @@ QONTRACT_INTEGRATION = "dynatrace-token-provider"
46
46
  SYNCSET_AND_MANIFEST_ID = "ext-dynatrace-tokens-dtp"
47
47
 
48
48
 
49
- class DynatraceTokenProviderIntegrationParams(PydanticRunParams):
50
- ocm_organization_ids: set[str] | None = None
51
-
52
-
53
49
  class ReconcileErrorSummary(Exception):
54
50
  def __init__(self, exceptions: Iterable[str]) -> None:
55
51
  self.exceptions = exceptions
@@ -59,11 +55,9 @@ class ReconcileErrorSummary(Exception):
59
55
  return f"Reconcile exceptions:\n{formatted_exceptions}"
60
56
 
61
57
 
62
- class DynatraceTokenProviderIntegration(
63
- QontractReconcileIntegration[DynatraceTokenProviderIntegrationParams]
64
- ):
65
- def __init__(self, params: DynatraceTokenProviderIntegrationParams) -> None:
66
- super().__init__(params=params)
58
+ class DynatraceTokenProviderIntegration(QontractReconcileIntegration[NoParams]):
59
+ def __init__(self) -> None:
60
+ super().__init__(NoParams())
67
61
  self._lock = Lock()
68
62
  self._managed_tokens_cnt: dict[str, Counter[str]] = defaultdict(Counter)
69
63
 
@@ -106,6 +100,27 @@ class DynatraceTokenProviderIntegration(
106
100
  cnt,
107
101
  )
108
102
 
103
+ def _filter_clusters(
104
+ self,
105
+ clusters: Iterable[Cluster],
106
+ token_spec_by_name: Mapping[str, DynatraceTokenProviderTokenSpecV1],
107
+ ) -> list[Cluster]:
108
+ filtered_clusters = []
109
+ for cluster in clusters:
110
+ token_spec = token_spec_by_name.get(cluster.token_spec_name)
111
+ if not token_spec:
112
+ logging.debug(
113
+ f"[{cluster.external_id=}] Skipping cluster. {cluster.token_spec_name=} does not exist."
114
+ )
115
+ continue
116
+ if cluster.organization_id in token_spec.ocm_org_ids:
117
+ filtered_clusters.append(cluster)
118
+ else:
119
+ logging.debug(
120
+ f"[{cluster.external_id=}] Skipping cluster for {token_spec.name=}. {cluster.organization_id=} is not defined in {token_spec.ocm_org_ids=}."
121
+ )
122
+ return filtered_clusters
123
+
109
124
  def reconcile(self, dry_run: bool, dependencies: Dependencies) -> None:
110
125
  token_specs = list(dependencies.token_spec_by_name.values())
111
126
  validate_token_specs(specs=token_specs)
@@ -124,12 +139,10 @@ class DynatraceTokenProviderIntegration(
124
139
  unhandled_exceptions.append(f"{ocm_env_name}: {e}")
125
140
  if not clusters:
126
141
  continue
127
- if self.params.ocm_organization_ids:
128
- clusters = [
129
- cluster
130
- for cluster in clusters
131
- if cluster.organization_id in self.params.ocm_organization_ids
132
- ]
142
+ filtered_clusters = self._filter_clusters(
143
+ clusters=clusters,
144
+ token_spec_by_name=dependencies.token_spec_by_name,
145
+ )
133
146
 
134
147
  existing_dtp_tokens: dict[str, dict[str, str]] = {}
135
148
 
@@ -140,7 +153,7 @@ class DynatraceTokenProviderIntegration(
140
153
  ),
141
154
  len(clusters),
142
155
  )
143
- for cluster in clusters:
156
+ for cluster in filtered_clusters:
144
157
  try:
145
158
  with DTPOrganizationErrorRate(
146
159
  integration=self.name,
@@ -230,11 +243,6 @@ class DynatraceTokenProviderIntegration(
230
243
  token_spec: DynatraceTokenProviderTokenSpecV1,
231
244
  ocm_env_name: str,
232
245
  ) -> None:
233
- if cluster.organization_id not in token_spec.ocm_org_ids:
234
- logging.info(
235
- f"[{token_spec.name=}] Cluster {cluster.external_id} is not part of ocm orgs defined in {token_spec.ocm_org_ids=}"
236
- )
237
- return
238
246
  existing_data = {}
239
247
  if cluster.is_hcp:
240
248
  existing_data = self.get_manifest(ocm_client=ocm_client, cluster=cluster)
@@ -11,3 +11,8 @@ class ElasticSearchResourceMissingSubnetIdError(Exception):
11
11
  class ElasticSearchResourceZoneAwareSubnetInvalidError(Exception):
12
12
  def __init__(self, msg):
13
13
  super().__init__(str(msg))
14
+
15
+
16
+ class ElasticSearchResourceColdStorageError(Exception):
17
+ def __init__(self, msg):
18
+ super().__init__(str(msg))
@@ -161,6 +161,7 @@ from reconcile.utils.cloud_resource_best_practice.aws_rds import (
161
161
  )
162
162
  from reconcile.utils.disabled_integrations import integration_is_enabled
163
163
  from reconcile.utils.elasticsearch_exceptions import (
164
+ ElasticSearchResourceColdStorageError,
164
165
  ElasticSearchResourceMissingSubnetIdError,
165
166
  ElasticSearchResourceNameInvalidError,
166
167
  ElasticSearchResourceZoneAwareSubnetInvalidError,
@@ -4632,6 +4633,24 @@ class TerrascriptClient: # pylint: disable=too-many-public-methods
4632
4633
  )
4633
4634
  cluster_vaules["warm_count"] = cluster_config.get("warm_count", 2)
4634
4635
 
4636
+ cold_storage_options = cluster_config.get("cold_storage_options", {})
4637
+ if cold_storage_options.get("enabled", False):
4638
+ if not dedicated_master_enabled:
4639
+ raise ElasticSearchResourceColdStorageError(
4640
+ f"[{account}] Cold storage can only be enabled when "
4641
+ + "dedicated_master_enabled is set to true for resource"
4642
+ f" {values['identifier']}"
4643
+ )
4644
+ if not warm_enabled:
4645
+ raise ElasticSearchResourceColdStorageError(
4646
+ f"[{account}] Cold storage can only be enabled when "
4647
+ + "warm_enabled is set to true for resource"
4648
+ f" {values['identifier']}"
4649
+ )
4650
+ cluster_vaules["cold_storage_options"] = {
4651
+ "enabled": True,
4652
+ }
4653
+
4635
4654
  es_values["cluster_config"] = cluster_vaules
4636
4655
 
4637
4656
  snapshot_options = values.get("snapshot_options", {})