qontract-reconcile 0.10.1rc1009__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.1rc1009
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
@@ -808,7 +808,7 @@ reconcile/utils/runtime/sharding.py,sha256=r0ieUtNed7NvknSw6qQrCkKpVXE1shuHGnfFc
808
808
  reconcile/utils/saasherder/__init__.py,sha256=J3MBZBFa5YmhqYm08QsjBXz8mFcVOCiOCkyIcw41t7E,343
809
809
  reconcile/utils/saasherder/interfaces.py,sha256=C2wrw34OXypshVocAsPrVZsSHptgw4g9u7Haa2wulZQ,9087
810
810
  reconcile/utils/saasherder/models.py,sha256=z8ln03zi2a8cu716NcNUDHp8Dv1VcVbhqdWVxCl7x9A,10148
811
- reconcile/utils/saasherder/saasherder.py,sha256=vaTQtDrJdm5wU8z0ROqEI-ewbzCkKAlHsEpP01Royvg,85048
811
+ reconcile/utils/saasherder/saasherder.py,sha256=rTsBaQrCY7StLWkkHnMLVil8luLMsZ9hRED6SDw4Cds,85698
812
812
  reconcile/utils/terraform/__init__.py,sha256=zNbiyTWo35AT1sFTElL2j_AA0jJ_yWE_bfFn-nD2xik,250
813
813
  reconcile/utils/terraform/config.py,sha256=5UVrd563TMcvi4ooa5JvWVDW1I3bIWg484u79evfV_8,164
814
814
  reconcile/utils/terraform/config_client.py,sha256=gRL1rQ0AqvShei_rcGqC3HDYGskOFKE1nPrJyJE9yno,4676
@@ -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.1rc1009.dist-info/METADATA,sha256=kaExAbwxrmdFEH6fxY0-AV4mlc67NsMZyobWXQeLRGY,2263
863
- qontract_reconcile-0.10.1rc1009.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
864
- qontract_reconcile-0.10.1rc1009.dist-info/entry_points.txt,sha256=GKQqCl2j2X1BJQ69een6rHcR26PmnxnONLNOQB-nRjY,491
865
- qontract_reconcile-0.10.1rc1009.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
866
- qontract_reconcile-0.10.1rc1009.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"]
@@ -1947,6 +1947,21 @@ class SaasHerder: # pylint: disable=too-many-public-methods
1947
1947
  if current_state and current_state.has_succeeded_once:
1948
1948
  has_succeeded_once = True
1949
1949
 
1950
+ check_in = str(now)
1951
+ if (
1952
+ success
1953
+ and current_state
1954
+ and current_state.check_in
1955
+ and current_state.success
1956
+ ):
1957
+ # We want to avoid an override of the timestamp.
1958
+ # This can happen on re-deployments of the same ref.
1959
+ # We only re-use the check_in time if the previous
1960
+ # and current deployment was successful.
1961
+ # On unsuccessful deployments, we
1962
+ # update the check_in time to current time.
1963
+ check_in = current_state.check_in
1964
+
1950
1965
  # publish to state to pass promotion gate
1951
1966
  self._promotion_state.publish_promotion_data(
1952
1967
  sha=promotion.commit_sha,
@@ -1957,8 +1972,7 @@ class SaasHerder: # pylint: disable=too-many-public-methods
1957
1972
  success=success,
1958
1973
  target_config_hash=promotion.target_config_hash,
1959
1974
  has_succeeded_once=has_succeeded_once,
1960
- # TODO: do not override - check if timestamp already exists
1961
- check_in=str(now),
1975
+ check_in=check_in,
1962
1976
  ),
1963
1977
  )
1964
1978
  logging.info(
@@ -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