qontract-reconcile 0.10.1rc855__py3-none-any.whl → 0.10.1rc856__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.1rc855
3
+ Version: 0.10.1rc856
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=9k1FKxkGO8yLB_-J3juHg6MoM3wTtHv7TOHLKh51t0k,103241
13
+ reconcile/cli.py,sha256=7IBz-214OFOt7EFzmFHgtk6KQh6T9fvvfV_8WWmeChM,103658
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
@@ -147,7 +147,7 @@ reconcile/aws_ami_cleanup/integration.py,sha256=IW95cpMj2P5ffs-AxsR_TDQCJnYFBhLI
147
147
  reconcile/aws_cloudwatch_log_retention/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
148
148
  reconcile/aws_cloudwatch_log_retention/integration.py,sha256=0UcSZIrGvnGY4m9fj87oejIolIP_qTxtJInpmW9jrQ0,7772
149
149
  reconcile/aws_saml_idp/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
150
- reconcile/aws_saml_idp/integration.py,sha256=uqec-EnxnfGOgQtg33S-Q1wTCv0sVBHNo02aT94hXrw,4807
150
+ reconcile/aws_saml_idp/integration.py,sha256=0Q8dNMDzEF7qXW6M9cqIU5MeVCUmr7vmX9GnoJCvFMY,6536
151
151
  reconcile/aws_saml_roles/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
152
152
  reconcile/aws_saml_roles/integration.py,sha256=kC4Rnbuy07TMvZO4rjUEcQkJev10M0Ro6r7YXcB7j_c,9530
153
153
  reconcile/aws_version_sync/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -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.1rc855.dist-info/METADATA,sha256=wEh7YpMmyML_tL2IoKASe5dDf2ObaIQ4j7I31v04jCw,2273
838
- qontract_reconcile-0.10.1rc855.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
839
- qontract_reconcile-0.10.1rc855.dist-info/entry_points.txt,sha256=GKQqCl2j2X1BJQ69een6rHcR26PmnxnONLNOQB-nRjY,491
840
- qontract_reconcile-0.10.1rc855.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
841
- qontract_reconcile-0.10.1rc855.dist-info/RECORD,,
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,,
@@ -1,3 +1,4 @@
1
+ import logging
1
2
  import sys
2
3
  from collections.abc import (
3
4
  Callable,
@@ -5,6 +6,7 @@ from collections.abc import (
5
6
  )
6
7
  from typing import (
7
8
  Any,
9
+ TypedDict,
8
10
  )
9
11
 
10
12
  import requests
@@ -21,6 +23,10 @@ from reconcile.utils import gql
21
23
  from reconcile.utils.aws_api import AWSApi
22
24
  from reconcile.utils.defer import defer
23
25
  from reconcile.utils.disabled_integrations import integration_is_enabled
26
+ from reconcile.utils.extended_early_exit import (
27
+ ExtendedEarlyExitRunnerResult,
28
+ extended_early_exit_run,
29
+ )
24
30
  from reconcile.utils.runtime.integration import (
25
31
  PydanticRunParams,
26
32
  QontractReconcileIntegration,
@@ -28,6 +34,7 @@ from reconcile.utils.runtime.integration import (
28
34
  from reconcile.utils.semver_helper import make_semver
29
35
  from reconcile.utils.terraform_client import TerraformClient
30
36
  from reconcile.utils.terrascript_aws_client import TerrascriptClient
37
+ from reconcile.utils.unleash.client import get_feature_toggle_state
31
38
 
32
39
  QONTRACT_INTEGRATION = "aws-saml-idp"
33
40
  QONTRACT_INTEGRATION_VERSION = make_semver(1, 0, 0)
@@ -41,6 +48,10 @@ class AwsSamlIdpIntegrationParams(PydanticRunParams):
41
48
  saml_idp_name: str
42
49
  saml_metadata_url: HttpUrl
43
50
  account_name: str | None = None
51
+ # extended early exit parameters
52
+ enable_extended_early_exit: bool = False
53
+ extended_early_exit_cache_ttl_seconds: int = 3600
54
+ log_cached_log_output: bool = False
44
55
 
45
56
 
46
57
  class SamlIdpConfig(BaseModel):
@@ -49,6 +60,12 @@ class SamlIdpConfig(BaseModel):
49
60
  metadata: str
50
61
 
51
62
 
63
+ class RunnerParams(TypedDict):
64
+ tf: TerraformClient
65
+ dry_run: bool
66
+ enable_deletion: bool
67
+
68
+
52
69
  class AwsSamlIdpIntegration(QontractReconcileIntegration[AwsSamlIdpIntegrationParams]):
53
70
  """Manage the SAML IDP config for all AWS accounts."""
54
71
 
@@ -146,13 +163,42 @@ class AwsSamlIdpIntegration(QontractReconcileIntegration[AwsSamlIdpIntegrationPa
146
163
  if defer:
147
164
  defer(tf.cleanup)
148
165
 
149
- _, err = tf.plan(self.params.enable_deletion)
150
- if err:
151
- sys.exit(ExitCodes.ERROR)
166
+ runner_params: RunnerParams = dict(
167
+ tf=tf,
168
+ dry_run=dry_run,
169
+ enable_deletion=self.params.enable_deletion,
170
+ )
171
+
172
+ if self.params.enable_extended_early_exit and get_feature_toggle_state(
173
+ f"{QONTRACT_INTEGRATION}-extended-early-exit", default=True
174
+ ):
175
+ extended_early_exit_run(
176
+ integration=QONTRACT_INTEGRATION,
177
+ integration_version=QONTRACT_INTEGRATION_VERSION,
178
+ dry_run=dry_run,
179
+ cache_source=ts.terraform_configurations(),
180
+ shard=self.params.account_name if self.params.account_name else "",
181
+ ttl_seconds=self.params.extended_early_exit_cache_ttl_seconds,
182
+ logger=logging.getLogger(),
183
+ runner=runner,
184
+ runner_params=runner_params,
185
+ log_cached_log_output=self.params.log_cached_log_output,
186
+ )
187
+ else:
188
+ runner(**runner_params)
189
+
190
+
191
+ def runner(
192
+ dry_run: bool, tf: TerraformClient, enable_deletion: bool
193
+ ) -> ExtendedEarlyExitRunnerResult:
194
+ _, err = tf.plan(enable_deletion)
195
+ if err:
196
+ raise RuntimeError("Terraform plan has errors")
197
+
198
+ if dry_run:
199
+ return ExtendedEarlyExitRunnerResult(payload={}, applied_count=0)
152
200
 
153
- if dry_run:
154
- return
201
+ if err := tf.apply():
202
+ raise RuntimeError("Terraform apply has errors")
155
203
 
156
- err = tf.apply()
157
- if err:
158
- sys.exit(ExitCodes.ERROR)
204
+ return ExtendedEarlyExitRunnerResult(payload={}, applied_count=tf.apply_count)
reconcile/cli.py CHANGED
@@ -737,6 +737,9 @@ def terraform_aws_route53(
737
737
  required=True,
738
738
  default="https://auth.redhat.com/auth/realms/EmployeeIDP/protocol/saml/descriptor",
739
739
  )
740
+ @enable_extended_early_exit
741
+ @extended_early_exit_cache_ttl_seconds
742
+ @log_cached_log_output
740
743
  @click.pass_context
741
744
  def aws_saml_idp(
742
745
  ctx,
@@ -746,6 +749,9 @@ def aws_saml_idp(
746
749
  account_name,
747
750
  saml_idp_name,
748
751
  saml_metadata_url,
752
+ enable_extended_early_exit,
753
+ extended_early_exit_cache_ttl_seconds,
754
+ log_cached_log_output,
749
755
  ):
750
756
  from reconcile.aws_saml_idp.integration import (
751
757
  AwsSamlIdpIntegration,
@@ -761,6 +767,9 @@ def aws_saml_idp(
761
767
  saml_idp_name=saml_idp_name,
762
768
  saml_metadata_url=saml_metadata_url,
763
769
  account_name=account_name,
770
+ enable_extended_early_exit=enable_extended_early_exit,
771
+ extended_early_exit_cache_ttl_seconds=extended_early_exit_cache_ttl_seconds,
772
+ log_cached_log_output=log_cached_log_output,
764
773
  )
765
774
  ),
766
775
  ctx=ctx.obj,