qontract-reconcile 0.10.2.dev117__py3-none-any.whl → 0.10.2.dev119__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.4
2
2
  Name: qontract-reconcile
3
- Version: 0.10.2.dev117
3
+ Version: 0.10.2.dev119
4
4
  Summary: Collection of tools to reconcile services with their desired state as defined in the app-interface DB.
5
5
  Project-URL: homepage, https://github.com/app-sre/qontract-reconcile
6
6
  Project-URL: repository, https://github.com/app-sre/qontract-reconcile
@@ -580,7 +580,7 @@ reconcile/unleash_feature_toggles/integration.py,sha256=nx7BhtzCsTfPbOp60vI5MkNw
580
580
  reconcile/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
581
581
  reconcile/utils/aggregated_list.py,sha256=_9UeaS1TWbJsGIESvXlzzK-omPI2lMMcCsoqc9LBclc,4022
582
582
  reconcile/utils/amtool.py,sha256=3dHViQ_esKPaMEpiOVVSnxTaySM8ELpGVVvppqqPvUY,2289
583
- reconcile/utils/aws_api.py,sha256=n2HMUPOnztcDt7c8GvGpT0qrpwArXke0hSCHQ1dSk6w,79439
583
+ reconcile/utils/aws_api.py,sha256=1sQgbDqRBLQuwJ6dfmbl6L_6LsgMrIm6G7Cn7s61Q5Q,80375
584
584
  reconcile/utils/aws_helper.py,sha256=8PvDR17ntAGX3bBzlTIxDuENl2rkK-RECsNYKm2_DZw,2955
585
585
  reconcile/utils/batches.py,sha256=TtEm64a8lWhFuNbUVpFEmXVdU2Q0sTBrP_I0Cjbgh7g,320
586
586
  reconcile/utils/binary.py,sha256=lSIevhilMeoGMePPHD7A-pxe45LVpBT0LksecYbM-EA,2477
@@ -650,7 +650,7 @@ reconcile/utils/sqs_gateway.py,sha256=XNIf3PY4UCPNufP2Ul0UJj3fKlt5larBba-VTT-41F
650
650
  reconcile/utils/state.py,sha256=az4tBmZ0EdbFcAGiBVUxs3cr2-BVWsuDQiNTvjjQq8s,16378
651
651
  reconcile/utils/structs.py,sha256=LcbLEg8WxfRqM6nW7NhcWN0YeqF7SQzxOgntmLs1SgY,352
652
652
  reconcile/utils/template.py,sha256=wTvRU4AnAV_o042tD4Mwls2dwWMuk7MKnde3MaCjaYg,331
653
- reconcile/utils/terraform_client.py,sha256=H8frsS370y8xfivKLNBD1dwlBLHvfuR6JSN_syBL5Qc,36033
653
+ reconcile/utils/terraform_client.py,sha256=IDlrNvGEc2i6ElZIL_fzaJEad1nRC3DkP9_VXhJXmU0,37329
654
654
  reconcile/utils/terrascript_aws_client.py,sha256=4NNr1zYd2NNrR7q8W-YDkZOg5DvX-pStYEBRD12sebM,287496
655
655
  reconcile/utils/three_way_diff_strategy.py,sha256=oQcHXd9LVhirJfoaOBoHUYuZVGfyL2voKr6KVI34zZE,4833
656
656
  reconcile/utils/throughput.py,sha256=iP4UWAe2LVhDo69mPPmgo9nQ7RxHD6_GS8MZe-aSiuM,344
@@ -791,7 +791,7 @@ tools/saas_promotion_state/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJ
791
791
  tools/saas_promotion_state/saas_promotion_state.py,sha256=UfwwRLS5Ya4_Nh1w5n1dvoYtchQvYE9yj1VANt2IKqI,3925
792
792
  tools/sre_checkpoints/__init__.py,sha256=CDaDaywJnmRCLyl_NCcvxi-Zc0hTi_3OdwKiFOyS39I,145
793
793
  tools/sre_checkpoints/util.py,sha256=zEDbGr18ZeHNQwW8pUsr2JRjuXIPz--WAGJxZo9sv_Y,894
794
- qontract_reconcile-0.10.2.dev117.dist-info/METADATA,sha256=S3Kx-hAT-fWFr3euw9iw6lKLHFYTSrIrIWtZT3Ib8hk,24566
795
- qontract_reconcile-0.10.2.dev117.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
796
- qontract_reconcile-0.10.2.dev117.dist-info/entry_points.txt,sha256=5i9l54La3vQrDLAdwDKQWC0iG4sV9RRfOb1BpvzOWLc,698
797
- qontract_reconcile-0.10.2.dev117.dist-info/RECORD,,
794
+ qontract_reconcile-0.10.2.dev119.dist-info/METADATA,sha256=SKqDG8b-t6tqKTkpG1py04j64dM91WT5KMO5Ir65rGc,24566
795
+ qontract_reconcile-0.10.2.dev119.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
796
+ qontract_reconcile-0.10.2.dev119.dist-info/entry_points.txt,sha256=5i9l54La3vQrDLAdwDKQWC0iG4sV9RRfOb1BpvzOWLc,698
797
+ qontract_reconcile-0.10.2.dev119.dist-info/RECORD,,
@@ -2076,6 +2076,32 @@ class AWSApi:
2076
2076
  return versions[0]["ValidUpgradeTarget"]
2077
2077
  return []
2078
2078
 
2079
+ def check_db_engine_version(
2080
+ self,
2081
+ account_name: str,
2082
+ engine: str,
2083
+ engine_version: str,
2084
+ region_name: str | None = None,
2085
+ ) -> bool:
2086
+ """
2087
+ Check the version of the database engine is available or deprecated.
2088
+ :param account_name: the name of the account in app-interface
2089
+ :param engine: the database engine (ex. mysql, postgres)
2090
+ :param engine_version: the database engine version
2091
+ :param region_name: AWS region name for the resource, otherwise fallback to default
2092
+ """
2093
+ optional_kwargs = {}
2094
+
2095
+ if region_name:
2096
+ optional_kwargs["region_name"] = region_name
2097
+
2098
+ rds = self._account_rds_client(account_name, **optional_kwargs)
2099
+ response = rds.describe_db_engine_versions(
2100
+ Engine=engine,
2101
+ EngineVersion=engine_version,
2102
+ )
2103
+ return len(response["DBEngineVersions"]) == 1
2104
+
2079
2105
  def describe_db_parameter_group(
2080
2106
  self,
2081
2107
  account_name: str,
@@ -775,7 +775,17 @@ class TerraformClient: # pylint: disable=too-many-public-methods
775
775
  before_version = before["engine_version"]
776
776
  after = resource_change["after"]
777
777
  after_version = after["engine_version"]
778
+ blue_green_update = after.get("blue_green_update", [])
779
+ changed_fields = self._resource_diff_changed_fields("update", resource_change)
780
+ # blue_green_update is not a actully rds field.
781
+ if "blue_green_update" in changed_fields:
782
+ changed_fields.remove("blue_green_update")
778
783
  if after_version == before_version:
784
+ if changed_fields and blue_green_update and blue_green_update[0]["enabled"]:
785
+ raise RdsUpgradeValidationError(
786
+ f"Cannot modify RDS instance: {resource_name} for {changed_fields} with blue/green updates. "
787
+ f"Blue/green updates are recommended only for major version upgrades."
788
+ )
779
789
  return
780
790
 
781
791
  region_name = get_region_from_availability_zone(before["availability_zone"])
@@ -806,17 +816,15 @@ class TerraformClient: # pylint: disable=too-many-public-methods
806
816
  f"{resource_name} to a new major version."
807
817
  )
808
818
 
809
- blue_green_update = after.get("blue_green_update", [])
810
819
  if blue_green_update and blue_green_update[0]["enabled"]:
811
- changed_fields = self._resource_diff_changed_fields(
812
- "update", resource_change
813
- )
814
820
  replica = before["replicas"] != [] or before["replicate_source_db"]
815
821
  self.validate_blue_green_update_requirements(
816
822
  account_name,
817
823
  resource_name,
818
824
  engine,
825
+ target["IsMajorVersionUpgrade"],
819
826
  before_version,
827
+ after_version,
820
828
  replica,
821
829
  before["parameter_group_name"],
822
830
  region_name,
@@ -828,12 +836,20 @@ class TerraformClient: # pylint: disable=too-many-public-methods
828
836
  account_name: str,
829
837
  resource_name: str,
830
838
  engine: str,
831
- version: str,
839
+ is_major_version_upgrade: bool,
840
+ before_version: str,
841
+ after_version: str,
832
842
  replica: bool,
833
843
  parameter_group: str,
834
844
  region_name: str,
835
845
  changed_fields: set[str],
836
846
  ) -> None:
847
+ if not is_major_version_upgrade:
848
+ raise RdsUpgradeValidationError(
849
+ f"Cannot upgrade RDS instance: {resource_name}. "
850
+ f"Blue/green updates are recommended only for major version upgrades."
851
+ )
852
+
837
853
  min_supported_versions = {
838
854
  "mysql": [pkg_version.parse("5.7"), pkg_version.parse("8.0.15")],
839
855
  "postgres": [
@@ -860,10 +876,18 @@ class TerraformClient: # pylint: disable=too-many-public-methods
860
876
  )
861
877
  return False
862
878
 
863
- if not is_supported(engine, version):
879
+ if not is_supported(engine=engine, version=before_version):
864
880
  raise RdsUpgradeValidationError(
865
881
  f"Cannot upgrade RDS instance: {resource_name}. "
866
- f"Engine version {version} is not supported for blue/green updates."
882
+ f"Engine version {before_version} is not supported for blue/green updates."
883
+ )
884
+
885
+ if self._aws_api and not self._aws_api.check_db_engine_version(
886
+ account_name, engine, after_version, region_name=region_name
887
+ ):
888
+ raise RdsUpgradeValidationError(
889
+ f"Cannot upgrade RDS instance: {resource_name} with blue/green updates. "
890
+ f"Target engine version {after_version} is deprecated."
867
891
  )
868
892
 
869
893
  if replica: