qontract-reconcile 0.10.1rc856__py3-none-any.whl → 0.10.1rc857__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.1rc856
3
+ Version: 0.10.1rc857
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=7IBz-214OFOt7EFzmFHgtk6KQh6T9fvvfV_8WWmeChM,103658
13
+ reconcile/cli.py,sha256=F5s-i-OlL6RhqiYkEhXMaNLegiPazbS0ahEtRrO2LeE,104075
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=R2JuwiXAEYAFiCtnztM_IIr1rtVzPpaWAmgxuDa2FgY,4813
@@ -149,7 +149,7 @@ reconcile/aws_cloudwatch_log_retention/integration.py,sha256=0UcSZIrGvnGY4m9fj87
149
149
  reconcile/aws_saml_idp/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
150
150
  reconcile/aws_saml_idp/integration.py,sha256=0Q8dNMDzEF7qXW6M9cqIU5MeVCUmr7vmX9GnoJCvFMY,6536
151
151
  reconcile/aws_saml_roles/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
152
- reconcile/aws_saml_roles/integration.py,sha256=kC4Rnbuy07TMvZO4rjUEcQkJev10M0Ro6r7YXcB7j_c,9530
152
+ reconcile/aws_saml_roles/integration.py,sha256=d_mBdQTF0Uj2h4NYR1xF0KDuciW1H39CohCDz40HgYA,11259
153
153
  reconcile/aws_version_sync/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
154
154
  reconcile/aws_version_sync/integration.py,sha256=uI6k0nNS_jRrVaIcgm30Hj_M6GIJmexU2X-6Dxe0CZo,17271
155
155
  reconcile/aws_version_sync/utils.py,sha256=sVv-48PKi2VITlqqvmpbjnFDOPeGqfKzgkpIszlmjL0,1708
@@ -834,8 +834,8 @@ tools/test/test_app_interface_metrics_exporter.py,sha256=SX7qL3D1SIRKFo95FoQztvf
834
834
  tools/test/test_qontract_cli.py,sha256=_D61RFGAN5x44CY1tYbouhlGXXABwYfxKSWSQx3Jrss,4941
835
835
  tools/test/test_sd_app_sre_alert_report.py,sha256=v363r9zM7__0kR5K6mvJoGFcM9BvE33fWAayrqkpojA,2116
836
836
  tools/test/test_sre_checkpoints.py,sha256=SKqPPTl9ua0RFdSSofnoQX-JZE6dFLO3LRhfQzqtfh8,2607
837
- qontract_reconcile-0.10.1rc856.dist-info/METADATA,sha256=JfccMX9Vsbbv10UZZNVKK7jFNwzW1hVHTz-fDsMSukI,2273
838
- qontract_reconcile-0.10.1rc856.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
839
- qontract_reconcile-0.10.1rc856.dist-info/entry_points.txt,sha256=GKQqCl2j2X1BJQ69een6rHcR26PmnxnONLNOQB-nRjY,491
840
- qontract_reconcile-0.10.1rc856.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
841
- qontract_reconcile-0.10.1rc856.dist-info/RECORD,,
837
+ qontract_reconcile-0.10.1rc857.dist-info/METADATA,sha256=y5SBuYTlPDgO4AIat2E18IJErGFgADPtsZaWmhGNUqI,2273
838
+ qontract_reconcile-0.10.1rc857.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
839
+ qontract_reconcile-0.10.1rc857.dist-info/entry_points.txt,sha256=GKQqCl2j2X1BJQ69een6rHcR26PmnxnONLNOQB-nRjY,491
840
+ qontract_reconcile-0.10.1rc857.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
841
+ qontract_reconcile-0.10.1rc857.dist-info/RECORD,,
@@ -1,4 +1,5 @@
1
1
  import json
2
+ import logging
2
3
  import sys
3
4
  from collections.abc import (
4
5
  Callable,
@@ -6,6 +7,7 @@ from collections.abc import (
6
7
  )
7
8
  from typing import (
8
9
  Any,
10
+ TypedDict,
9
11
  )
10
12
 
11
13
  from pydantic import BaseModel, root_validator, validator
@@ -25,6 +27,10 @@ from reconcile.utils.aws_api import AWSApi
25
27
  from reconcile.utils.aws_helper import unique_sso_aws_accounts
26
28
  from reconcile.utils.defer import defer
27
29
  from reconcile.utils.disabled_integrations import integration_is_enabled
30
+ from reconcile.utils.extended_early_exit import (
31
+ ExtendedEarlyExitRunnerResult,
32
+ extended_early_exit_run,
33
+ )
28
34
  from reconcile.utils.runtime.integration import (
29
35
  PydanticRunParams,
30
36
  QontractReconcileIntegration,
@@ -32,6 +38,7 @@ from reconcile.utils.runtime.integration import (
32
38
  from reconcile.utils.semver_helper import make_semver
33
39
  from reconcile.utils.terraform_client import TerraformClient
34
40
  from reconcile.utils.terrascript_aws_client import TerrascriptClient
41
+ from reconcile.utils.unleash.client import get_feature_toggle_state
35
42
 
36
43
  QONTRACT_INTEGRATION = "aws-saml-roles"
37
44
  QONTRACT_INTEGRATION_VERSION = make_semver(1, 0, 0)
@@ -45,6 +52,10 @@ class AwsSamlRolesIntegrationParams(PydanticRunParams):
45
52
  saml_idp_name: str
46
53
  max_session_duration_hours: int = 1
47
54
  account_name: str | None = None
55
+ # extended early exit parameters
56
+ enable_extended_early_exit: bool = False
57
+ extended_early_exit_cache_ttl_seconds: int = 3600
58
+ log_cached_log_output: bool = False
48
59
 
49
60
  @validator("max_session_duration_hours")
50
61
  def max_session_duration_range(cls, v: str | int) -> int:
@@ -129,6 +140,12 @@ class AwsRole(BaseModel):
129
140
  return values
130
141
 
131
142
 
143
+ class RunnerParams(TypedDict):
144
+ tf: TerraformClient
145
+ dry_run: bool
146
+ enable_deletion: bool
147
+
148
+
132
149
  class AwsSamlRolesIntegration(
133
150
  QontractReconcileIntegration[AwsSamlRolesIntegrationParams]
134
151
  ):
@@ -264,13 +281,42 @@ class AwsSamlRolesIntegration(
264
281
  if defer:
265
282
  defer(tf.cleanup)
266
283
 
267
- _, err = tf.plan(self.params.enable_deletion)
268
- if err:
269
- sys.exit(ExitCodes.ERROR)
284
+ runner_params: RunnerParams = dict(
285
+ tf=tf,
286
+ dry_run=dry_run,
287
+ enable_deletion=self.params.enable_deletion,
288
+ )
289
+
290
+ if self.params.enable_extended_early_exit and get_feature_toggle_state(
291
+ f"{QONTRACT_INTEGRATION}-extended-early-exit", default=True
292
+ ):
293
+ extended_early_exit_run(
294
+ integration=QONTRACT_INTEGRATION,
295
+ integration_version=QONTRACT_INTEGRATION_VERSION,
296
+ dry_run=dry_run,
297
+ cache_source=ts.terraform_configurations(),
298
+ shard=self.params.account_name if self.params.account_name else "",
299
+ ttl_seconds=self.params.extended_early_exit_cache_ttl_seconds,
300
+ logger=logging.getLogger(),
301
+ runner=runner,
302
+ runner_params=runner_params,
303
+ log_cached_log_output=self.params.log_cached_log_output,
304
+ )
305
+ else:
306
+ runner(**runner_params)
307
+
308
+
309
+ def runner(
310
+ dry_run: bool, tf: TerraformClient, enable_deletion: bool
311
+ ) -> ExtendedEarlyExitRunnerResult:
312
+ _, err = tf.plan(enable_deletion)
313
+ if err:
314
+ raise RuntimeError("Terraform plan has errors")
315
+
316
+ if dry_run:
317
+ return ExtendedEarlyExitRunnerResult(payload={}, applied_count=0)
270
318
 
271
- if dry_run:
272
- return
319
+ if err := tf.apply():
320
+ raise RuntimeError("Terraform apply has errors")
273
321
 
274
- err = tf.apply()
275
- if err:
276
- sys.exit(ExitCodes.ERROR)
322
+ return ExtendedEarlyExitRunnerResult(payload={}, applied_count=tf.apply_count)
reconcile/cli.py CHANGED
@@ -933,6 +933,9 @@ def openshift_serviceaccount_tokens(
933
933
  required=True,
934
934
  default=6,
935
935
  )
936
+ @enable_extended_early_exit
937
+ @extended_early_exit_cache_ttl_seconds
938
+ @log_cached_log_output
936
939
  @click.pass_context
937
940
  def aws_saml_roles(
938
941
  ctx,
@@ -942,6 +945,9 @@ def aws_saml_roles(
942
945
  account_name,
943
946
  saml_idp_name,
944
947
  max_session_duration_hours,
948
+ enable_extended_early_exit,
949
+ extended_early_exit_cache_ttl_seconds,
950
+ log_cached_log_output,
945
951
  ):
946
952
  from reconcile.aws_saml_roles.integration import (
947
953
  AwsSamlRolesIntegration,
@@ -957,6 +963,9 @@ def aws_saml_roles(
957
963
  saml_idp_name=saml_idp_name,
958
964
  max_session_duration_hours=max_session_duration_hours,
959
965
  account_name=account_name,
966
+ enable_extended_early_exit=enable_extended_early_exit,
967
+ extended_early_exit_cache_ttl_seconds=extended_early_exit_cache_ttl_seconds,
968
+ log_cached_log_output=log_cached_log_output,
960
969
  )
961
970
  ),
962
971
  ctx=ctx.obj,