qontract-reconcile 0.10.2.dev69__py3-none-any.whl → 0.10.2.dev71__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.dev69
3
+ Version: 0.10.2.dev71
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
@@ -11,9 +11,7 @@ Classifier: Development Status :: 2 - Pre-Alpha
11
11
  Classifier: Programming Language :: Python
12
12
  Classifier: Programming Language :: Python :: 3
13
13
  Classifier: Programming Language :: Python :: 3.11
14
- Classifier: Programming Language :: Python :: 3.12
15
- Classifier: Programming Language :: Python :: 3.13
16
- Requires-Python: >=3.11
14
+ Requires-Python: ==3.11.*
17
15
  Requires-Dist: anymarkup<0.9.0,>=0.7.0
18
16
  Requires-Dist: boto3==1.34.94
19
17
  Requires-Dist: botocore==1.34.94
@@ -127,7 +127,7 @@ reconcile/aus/base.py,sha256=2h_8GuwEHJBLmiwTwaFT9EjiCHcmIEXF8Zo7rZ974kQ,48832
127
127
  reconcile/aus/cluster_version_data.py,sha256=VZWbUEIbrDKO-sroMpQtiWCTqDraTMd8tssKV0HyTQ0,7140
128
128
  reconcile/aus/healthchecks.py,sha256=jR9c-syh9impnkV0fd6XW3Bnk7iRN5zv8oCRYM-yIRY,2700
129
129
  reconcile/aus/metrics.py,sha256=nKT4m2zGT-QOMR0c-z-npVNKWsNMubzdffpU_f9n4II,3927
130
- reconcile/aus/models.py,sha256=MSKX7SY0GDw7BgpIuKeLT3i_v8E1LFz4M0DQAL7JWUM,7783
130
+ reconcile/aus/models.py,sha256=R72G-2_mx4KHvdIFOzOd2neubu-BBlw5i7hqKVk7W3s,8149
131
131
  reconcile/aus/node_pool_spec.py,sha256=FkMggklG-4BgQwud2Swp2m3AAAKzZmeaXgohl9uwxZ8,1138
132
132
  reconcile/aus/ocm_addons_upgrade_scheduler_org.py,sha256=-xliq44ev35P6YzwrGLppReRUWrKDTNptNjaivwICIc,10263
133
133
  reconcile/aus/ocm_upgrade_scheduler.py,sha256=2uPn13y3QGCHLoKwCc1Z7q9wQsoQf_F1HATMYUbl53s,3695
@@ -709,7 +709,7 @@ reconcile/utils/ocm/identity_providers.py,sha256=dKed09N8iWmn39tI_MpwgVe47x23eLs
709
709
  reconcile/utils/ocm/label_sources.py,sha256=ES_5VP4X6gsRxMFZ95WgbwE_HqqIUo_JRjHjdGYw6Ss,1846
710
710
  reconcile/utils/ocm/labels.py,sha256=CmAgaOEPiaUb4gLtKab9vNkSDJceuREPd4ApgGcIA1U,6240
711
711
  reconcile/utils/ocm/manifests.py,sha256=Q6kgOeiAwLbJY_vO_BEW2oePvbLDZcMZk20YpJJGpOA,1195
712
- reconcile/utils/ocm/ocm.py,sha256=EwhCymt7r8cL8UF2XbwmQ6IiRE016AUuPEiMAtYMepE,36707
712
+ reconcile/utils/ocm/ocm.py,sha256=qDD7x4uhnr7WJenc5mN9XSttu4NhI8FDEUIc33nWKpM,33211
713
713
  reconcile/utils/ocm/products.py,sha256=Ki9o0VV4z_FsXQaJtSFzlUnxLvpk1H-RamvJpUwwbuQ,26006
714
714
  reconcile/utils/ocm/search_filters.py,sha256=uUCJ-XOEp4D5uxPW7lDqNe6s-mQWLOCqMu9_xvO6PXU,14798
715
715
  reconcile/utils/ocm/service_log.py,sha256=RG1f0MMn6joKaRCAm2xveSJCavdOPP1BVo9FXecDxaI,2018
@@ -777,7 +777,7 @@ tools/saas_promotion_state/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJ
777
777
  tools/saas_promotion_state/saas_promotion_state.py,sha256=UfwwRLS5Ya4_Nh1w5n1dvoYtchQvYE9yj1VANt2IKqI,3925
778
778
  tools/sre_checkpoints/__init__.py,sha256=CDaDaywJnmRCLyl_NCcvxi-Zc0hTi_3OdwKiFOyS39I,145
779
779
  tools/sre_checkpoints/util.py,sha256=zEDbGr18ZeHNQwW8pUsr2JRjuXIPz--WAGJxZo9sv_Y,894
780
- qontract_reconcile-0.10.2.dev69.dist-info/METADATA,sha256=__Xodwd_e1SiI9n8rqIwezBhNtoH4c6JYPZvxk3vxl4,24665
781
- qontract_reconcile-0.10.2.dev69.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
782
- qontract_reconcile-0.10.2.dev69.dist-info/entry_points.txt,sha256=5i9l54La3vQrDLAdwDKQWC0iG4sV9RRfOb1BpvzOWLc,698
783
- qontract_reconcile-0.10.2.dev69.dist-info/RECORD,,
780
+ qontract_reconcile-0.10.2.dev71.dist-info/METADATA,sha256=X2KpCP8AgWG2loIUtoCmEHxD6QOGjjixvfz9rTmUxyw,24565
781
+ qontract_reconcile-0.10.2.dev71.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
782
+ qontract_reconcile-0.10.2.dev71.dist-info/entry_points.txt,sha256=5i9l54La3vQrDLAdwDKQWC0iG4sV9RRfOb1BpvzOWLc,698
783
+ qontract_reconcile-0.10.2.dev71.dist-info/RECORD,,
reconcile/aus/models.py CHANGED
@@ -77,9 +77,19 @@ class ClusterUpgradeSpec(BaseModel):
77
77
  return mutexes
78
78
 
79
79
 
80
+ # TODO: Addon not is-a Cluster, extract a common base to inherit
80
81
  class ClusterAddonUpgradeSpec(ClusterUpgradeSpec):
81
82
  addon: OCMAddonInstallation
82
83
 
84
+ def version_blocked(self, version: str) -> bool:
85
+ addon_id = self.addon.id
86
+ v = f"{addon_id}/{version}"
87
+ return any(
88
+ re.search(b, v)
89
+ for b in self.blocked_versions
90
+ if b.startswith(f"{addon_id}/") or b.startswith(f"^{addon_id}/")
91
+ )
92
+
83
93
  def get_available_upgrades(self) -> list[str]:
84
94
  return self.addon.addon_version.available_upgrades
85
95
 
@@ -1,7 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import functools
4
- import re
5
4
  from collections.abc import Mapping
6
5
  from typing import Any
7
6
 
@@ -58,7 +57,6 @@ ADDON_UPGRADE_POLICY_DESIRED_KEYS = {
58
57
  "version",
59
58
  }
60
59
  ROUTER_DESIRED_KEYS = {"id", "listening", "dns_name", "route_selectors"}
61
- AUTOSCALE_DESIRED_KEYS = {"min_replicas", "max_replicas"}
62
60
  CLUSTER_ADDON_DESIRED_KEYS = {"id", "parameters"}
63
61
 
64
62
  DISABLE_UWM_ATTR = "disable_user_workload_monitoring"
@@ -71,16 +69,15 @@ class OCM: # pylint: disable=too-many-public-methods
71
69
  OCM is an instance of OpenShift Cluster Manager.
72
70
 
73
71
  :param name: OCM instance name
74
- :param url: OCM instance URL
75
72
  :param org_id: OCM org ID
73
+ :param ocm_env: OCM env
76
74
  :param ocm_client: the OCM API client to talk to OCM
77
75
  :param init_provision_shards: should initiate provision shards
78
76
  :param init_addons: should initiate addons
79
- :param blocked_versions: versions to block upgrades for
77
+ :param init_version_gates: should initiate version gates
80
78
  :type init_provision_shards: bool
81
79
  :type init_addons: bool
82
80
  :type init_version_gates: bool
83
- :type blocked_version: list
84
81
  """
85
82
 
86
83
  def __init__(
@@ -92,8 +89,6 @@ class OCM: # pylint: disable=too-many-public-methods
92
89
  init_provision_shards=False,
93
90
  init_addons=False,
94
91
  init_version_gates=False,
95
- blocked_versions=None,
96
- inheritVersionData: list[dict[str, Any]] | None = None,
97
92
  product_portfolio: OCMProductPortfolio | None = None,
98
93
  ):
99
94
  """Initiates access token and gets clusters information."""
@@ -110,8 +105,6 @@ class OCM: # pylint: disable=too-many-public-methods
110
105
  if init_addons:
111
106
  self._init_addons()
112
107
 
113
- self._init_blocked_versions(blocked_versions)
114
-
115
108
  self.init_version_gates = init_version_gates
116
109
  self.version_gates: list[Any] = []
117
110
  if init_version_gates:
@@ -160,16 +153,6 @@ class OCM: # pylint: disable=too-many-public-methods
160
153
  else:
161
154
  self.not_ready_clusters.add(cluster_name)
162
155
 
163
- @property
164
- def non_blocked_cluster_upgrades(self) -> dict[str, list[str]]:
165
- return {
166
- cluster: [v for v in versions or [] if not self.version_blocked(v)]
167
- for cluster, versions in self.available_cluster_upgrades.items()
168
- }
169
-
170
- def is_ready(self, cluster):
171
- return cluster in self.clusters
172
-
173
156
  def get_product_impl(
174
157
  self, product: str, hypershift: bool | None = False
175
158
  ) -> OCMProduct:
@@ -615,45 +598,6 @@ class OCM: # pylint: disable=too-many-public-methods
615
598
  api = f"{CS_API_BASE}/v1/clusters/{cluster_id}/node_pools/" + f"{node_pool_id}"
616
599
  self._patch(api, spec)
617
600
 
618
- def addon_version_blocked(self, version: str, addon_id: str) -> bool:
619
- """Check if an addon version is blocked
620
-
621
- Args:
622
- version (string): version to check
623
- addon_id (string): addon_id to check
624
-
625
- Returns:
626
- bool: is version blocked
627
- """
628
- v = f"{addon_id}/{version}"
629
- return any(
630
- re.search(b, v)
631
- for b in self.blocked_versions
632
- if b.startswith(f"{addon_id}/") or b.startswith(f"^{addon_id}/")
633
- )
634
-
635
- def version_blocked(self, version: str) -> bool:
636
- """Check if a version is blocked
637
-
638
- Args:
639
- version (string): version to check
640
-
641
- Returns:
642
- bool: is version blocked
643
- """
644
- return any(re.search(b, version) for b in self.blocked_versions)
645
-
646
- def get_available_upgrades(self, cluster_name: str) -> list[str]:
647
- """Get available versions to upgrade for a specific cluster.
648
-
649
- Args:
650
- cluster_name (string): cluster display name to get available upgrades for
651
-
652
- Returns:
653
- list: a non-null but potentially empty list of available versions to upgrade to
654
- """
655
- return self.available_cluster_upgrades.get(cluster_name) or []
656
-
657
601
  def get_additional_routers(self, cluster):
658
602
  """Returns a list of Additional Application Routers
659
603
 
@@ -706,23 +650,6 @@ class OCM: # pylint: disable=too-many-public-methods
706
650
  api = f"{CS_API_BASE}/v1/clusters/{cluster_id}/" + f"ingresses/{router_id}"
707
651
  self._delete(api)
708
652
 
709
- @staticmethod
710
- def _get_autoscale(cluster):
711
- autoscale = cluster["nodes"].get("autoscale_compute", None)
712
- if autoscale is None:
713
- return None
714
- return {k: v for k, v in autoscale.items() if k in AUTOSCALE_DESIRED_KEYS}
715
-
716
- def whoami(self):
717
- api = f"{AMS_API_BASE}/v1/current_account"
718
- return self._get_json(api)
719
-
720
- def get_pull_secrets(
721
- self,
722
- ):
723
- api = f"{AMS_API_BASE}/v1/access_token"
724
- return self._post(api)
725
-
726
653
  def _init_addons(self):
727
654
  """Returns a list of Addons"""
728
655
  api = f"{CS_API_BASE}/v1/addons"
@@ -742,25 +669,6 @@ class OCM: # pylint: disable=too-many-public-methods
742
669
  return addon
743
670
  return None
744
671
 
745
- def get_addon_version(self, id):
746
- for addon in self.addons:
747
- addon_id = addon["id"]
748
- if id == addon_id:
749
- return addon["version"]["id"]
750
- return None
751
-
752
- def get_version_gates(
753
- self, version_prefix: str, sts_only: bool = False
754
- ) -> list[dict[str, Any]]:
755
- if not self.init_version_gates:
756
- self._init_version_gates()
757
- return [
758
- g
759
- for g in self.version_gates
760
- if g["version_raw_id_prefix"] == version_prefix
761
- and g["sts_only"] == sts_only
762
- ]
763
-
764
672
  def get_cluster_addons(
765
673
  self,
766
674
  cluster: str,
@@ -818,20 +726,6 @@ class OCM: # pylint: disable=too-many-public-methods
818
726
  data["parameters"]["items"] = parameters
819
727
  self._post(api, data)
820
728
 
821
- def _init_blocked_versions(self, blocked_versions):
822
- try:
823
- self.blocked_versions = set(blocked_versions)
824
- except TypeError:
825
- self.blocked_versions = set()
826
-
827
- for b in self.blocked_versions:
828
- try:
829
- re.compile(b)
830
- except re.error:
831
- raise TypeError(
832
- f"blocked version is not a valid regex expression: {b}"
833
- ) from None
834
-
835
729
  @retry(max_attempts=10)
836
730
  def _do_get_request(self, api: str, params: Mapping[str, str]) -> dict[str, Any]:
837
731
  return self._ocm_client.get(
@@ -1055,9 +949,7 @@ class OCMMap: # pylint: disable=too-many-public-methods
1055
949
  ocm_client,
1056
950
  init_provision_shards=init_provision_shards,
1057
951
  init_addons=init_addons,
1058
- blocked_versions=ocm_info.get("blockedVersions"),
1059
952
  init_version_gates=init_version_gates,
1060
- inheritVersionData=ocm_info.get("inheritVersionData"),
1061
953
  product_portfolio=product_portfolio,
1062
954
  )
1063
955