qontract-reconcile 0.10.1rc1010__py3-none-any.whl → 0.10.1rc1011__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.1rc1010
3
+ Version: 0.10.1rc1011
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
@@ -644,7 +644,7 @@ reconcile/unleash_feature_toggles/integration.py,sha256=nx7BhtzCsTfPbOp60vI5MkNw
644
644
  reconcile/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
645
645
  reconcile/utils/aggregated_list.py,sha256=km0xadW0jO4G_CqZPsXmoBURQ8c90FaTu5x4X1K1cZs,3357
646
646
  reconcile/utils/amtool.py,sha256=ngtBuVPETH6oAy5RnKzvreVbjwQCaATS_PYYwBprzjQ,2288
647
- reconcile/utils/aws_api.py,sha256=TJ0cgOBg9djdL9U_8HqSxf4aWm-NvwBCIGqP7YMcOZA,66126
647
+ reconcile/utils/aws_api.py,sha256=C90pODy5UB2YRV2Yd9Z4J5aTnMZk1CZv9YxbCN0I1-4,66822
648
648
  reconcile/utils/aws_helper.py,sha256=MDbv5jrNdqqJ5pfBxniGdJXBBO_EYc2_Uf2w9ZzeMNs,2854
649
649
  reconcile/utils/batches.py,sha256=TtEm64a8lWhFuNbUVpFEmXVdU2Q0sTBrP_I0Cjbgh7g,320
650
650
  reconcile/utils/binary.py,sha256=7MaAFBpzuBUTJ_aA6G6-eult_BPMVyiXbBLD0Y6F-DM,2301
@@ -716,7 +716,7 @@ reconcile/utils/sqs_gateway.py,sha256=XNIf3PY4UCPNufP2Ul0UJj3fKlt5larBba-VTT-41F
716
716
  reconcile/utils/state.py,sha256=a_EO5u7__Pqd0_E3MqzUttJ-0xRtuxcNx5oQi5WIahI,16392
717
717
  reconcile/utils/structs.py,sha256=LcbLEg8WxfRqM6nW7NhcWN0YeqF7SQzxOgntmLs1SgY,352
718
718
  reconcile/utils/template.py,sha256=wTvRU4AnAV_o042tD4Mwls2dwWMuk7MKnde3MaCjaYg,331
719
- reconcile/utils/terraform_client.py,sha256=tCDVrfmFCB6lGfGhJt13VRkHxGy7Psw88KIze0r-JLo,31787
719
+ reconcile/utils/terraform_client.py,sha256=QTLRB33dWOlf2AmZPntx3WWBV8d_-cwMZyLKd7eqclk,34176
720
720
  reconcile/utils/terrascript_aws_client.py,sha256=1JgXcCF_-xbaAg7V9qihL1Xz5okQlSSrT1DeXGducHc,278037
721
721
  reconcile/utils/three_way_diff_strategy.py,sha256=oQcHXd9LVhirJfoaOBoHUYuZVGfyL2voKr6KVI34zZE,4833
722
722
  reconcile/utils/throughput.py,sha256=iP4UWAe2LVhDo69mPPmgo9nQ7RxHD6_GS8MZe-aSiuM,344
@@ -859,8 +859,8 @@ tools/test/test_qontract_cli.py,sha256=_D61RFGAN5x44CY1tYbouhlGXXABwYfxKSWSQx3Jr
859
859
  tools/test/test_saas_promotion_state.py,sha256=dy4kkSSAQ7bC0Xp2CociETGN-2aABEfL6FU5D9Jl00Y,6056
860
860
  tools/test/test_sd_app_sre_alert_report.py,sha256=v363r9zM7__0kR5K6mvJoGFcM9BvE33fWAayrqkpojA,2116
861
861
  tools/test/test_sre_checkpoints.py,sha256=SKqPPTl9ua0RFdSSofnoQX-JZE6dFLO3LRhfQzqtfh8,2607
862
- qontract_reconcile-0.10.1rc1010.dist-info/METADATA,sha256=7cFnKb9RaHgWUrwtmYqUUsZ2MHpPoQNg5MZJ6U8U8Qg,2263
863
- qontract_reconcile-0.10.1rc1010.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
864
- qontract_reconcile-0.10.1rc1010.dist-info/entry_points.txt,sha256=GKQqCl2j2X1BJQ69een6rHcR26PmnxnONLNOQB-nRjY,491
865
- qontract_reconcile-0.10.1rc1010.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
866
- qontract_reconcile-0.10.1rc1010.dist-info/RECORD,,
862
+ qontract_reconcile-0.10.1rc1011.dist-info/METADATA,sha256=mei58NlsUM1RcmUd_fFIw1dobxT6K84nBBpAyJVmwW4,2263
863
+ qontract_reconcile-0.10.1rc1011.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
864
+ qontract_reconcile-0.10.1rc1011.dist-info/entry_points.txt,sha256=GKQqCl2j2X1BJQ69een6rHcR26PmnxnONLNOQB-nRjY,491
865
+ qontract_reconcile-0.10.1rc1011.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
866
+ qontract_reconcile-0.10.1rc1011.dist-info/RECORD,,
@@ -1630,6 +1630,25 @@ class AWSApi: # pylint: disable=too-many-public-methods
1630
1630
  return versions[0]["ValidUpgradeTarget"]
1631
1631
  return []
1632
1632
 
1633
+ def describe_db_parameter_group(
1634
+ self,
1635
+ account_name: str,
1636
+ db_parameter_group_name: str,
1637
+ region_name: str | None = None,
1638
+ ) -> dict[str, str]:
1639
+ optional_kwargs = {}
1640
+
1641
+ if region_name:
1642
+ optional_kwargs["region_name"] = region_name
1643
+
1644
+ rds = self._account_rds_client(account_name, **optional_kwargs)
1645
+ paginator = rds.get_paginator("describe_db_parameters")
1646
+ parameters = {}
1647
+ for page in paginator.paginate(DBParameterGroupName=db_parameter_group_name):
1648
+ for param in page.get("Parameters", []):
1649
+ parameters[param["ParameterName"]] = param["ParameterValue"]
1650
+ return parameters
1651
+
1633
1652
  def get_organization_billing_account(self, account_name: str) -> str:
1634
1653
  org = self._account_organizations_client(account_name)
1635
1654
  return org.describe_organization()["Organization"]["MasterAccountId"]
@@ -24,6 +24,7 @@ from typing import (
24
24
  )
25
25
 
26
26
  from botocore.errorfactory import ClientError
27
+ from packaging import version as pkg_version
27
28
  from sretoolbox.utils import (
28
29
  retry,
29
30
  threaded,
@@ -785,6 +786,71 @@ class TerraformClient: # pylint: disable=too-many-public-methods
785
786
  f"{resource_name} to a new major version."
786
787
  )
787
788
 
789
+ blue_green_update = after.get("blue_green_update", {}).get("enabled", False)
790
+ if blue_green_update:
791
+ self.validate_blue_green_update_requirements(
792
+ account_name,
793
+ engine,
794
+ after_version,
795
+ before["db_parameter_group_name"],
796
+ before.get("replica_source"),
797
+ region_name,
798
+ )
799
+
800
+ def validate_blue_green_update_requirements(
801
+ self,
802
+ account_name,
803
+ engine,
804
+ version,
805
+ parameter_group,
806
+ replica_source,
807
+ region_name,
808
+ ):
809
+ min_supported_versions = {
810
+ "mysql": [pkg_version.parse("5.7"), pkg_version.parse("8.0.15")],
811
+ "postgres": [
812
+ pkg_version.parse("11.21"),
813
+ pkg_version.parse("12.16"),
814
+ pkg_version.parse("13.12"),
815
+ pkg_version.parse("14.9"),
816
+ pkg_version.parse("15.4"),
817
+ pkg_version.parse("16.1"),
818
+ ],
819
+ }
820
+
821
+ def is_supported(engine, version):
822
+ parsed_version = pkg_version.parse(version)
823
+ if engine == "mysql":
824
+ return any(
825
+ parsed_version >= min_version
826
+ for min_version in min_supported_versions["mysql"]
827
+ )
828
+ elif engine == "postgres":
829
+ return any(
830
+ parsed_version >= min_version
831
+ for min_version in min_supported_versions["postgres"]
832
+ )
833
+ return False
834
+
835
+ if not is_supported(engine, version):
836
+ raise ValueError(
837
+ f"Engine version {version} is not supported for blue/green updates."
838
+ )
839
+
840
+ if replica_source:
841
+ raise ValueError(
842
+ "Blue/green updates are not supported for instances with read replicas."
843
+ )
844
+
845
+ if engine == "postgres" and parameter_group:
846
+ pg_details = self._aws_api.describe_db_parameter_group(
847
+ account_name, parameter_group, region_name
848
+ )
849
+ if pg_details.get("rds.logical_replication") != "1":
850
+ raise ValueError(
851
+ f"Parameter group {parameter_group} does not have logical replication enabled."
852
+ )
853
+
788
854
 
789
855
  class TerraformPlanFailed(Exception):
790
856
  pass