qontract-reconcile 0.10.2.dev277__py3-none-any.whl → 0.10.2.dev279__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.dev277
3
+ Version: 0.10.2.dev279
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
@@ -82,10 +82,10 @@ reconcile/openshift_tekton_resources.py,sha256=z9OidaI7Ju2O0O0PfIcdoyH62VA4TxLTD
82
82
  reconcile/openshift_upgrade_watcher.py,sha256=dGTQQdCOl95Bz0wOqg6JaMdBSSDgnAveH_hprUafhW0,6624
83
83
  reconcile/openshift_users.py,sha256=h4dH3gTCFFQID76PFuYeMWNzFQ9DgTUtsOcvxfj-3cs,5385
84
84
  reconcile/openshift_vault_secrets.py,sha256=Ax-_EBWWU1VRHYyKaUkGJkIjHGwWM3bZgjXL5CkPW8k,1883
85
- reconcile/quay_base.py,sha256=h5xNjb7EZm8L2JgpO42r6w0UA4im5dabZXJSIW69zKU,1987
86
- reconcile/quay_membership.py,sha256=1ajUJwPPudN7zmMZp81EipYljD0hAxzowaL-RbcroVA,6382
85
+ reconcile/quay_base.py,sha256=GQkUpuEzC1V_QrHEu_PoELVGnlNRvgFnTqVKp-xkgC4,2070
86
+ reconcile/quay_membership.py,sha256=No2sgEyTVj-hr5VPLy_xdrYAPvt-xo-CPpOt0X3x_6o,6623
87
87
  reconcile/quay_mirror.py,sha256=PBooiA0ShZpWYfO6oeKFqYYT6Syi7Q8JJD9kj0wRRLg,14030
88
- reconcile/quay_mirror_org.py,sha256=I-tEqRHLL6uFqbSi7qCfPuDNoae7EAI2U68NbDOhmv8,10809
88
+ reconcile/quay_mirror_org.py,sha256=PG_WpzE4TymICs74mFt3lh7XA4Rg91y4EVREMEd8PFk,10815
89
89
  reconcile/quay_permissions.py,sha256=9KOutS1w4RFQqkvMSy54VtsKNx56-phzP6yI_rEW-B8,4244
90
90
  reconcile/quay_repos.py,sha256=cuEYG0HUe0ut5yvLdEwOF5-CmccpXQHRb_wDazvDrvQ,6895
91
91
  reconcile/queries.py,sha256=aaffpfMIlmHy73CUxos--NnUsTR5ms3VPeaUY3dnvIs,49879
@@ -117,7 +117,7 @@ reconcile/vpc_peerings_validator.py,sha256=aESqrhm1tpkc2iqSL1UV5to_HjNgjRSffD0cr
117
117
  reconcile/aus/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
118
118
  reconcile/aus/advanced_upgrade_service.py,sha256=Cx-WthkvlcX58PrnnNeo_bQG17Xw3BGNu3f53Jc1VoA,23985
119
119
  reconcile/aus/aus_label_source.py,sha256=o0S2f0qwcII_8nzhHZhRQ83gEZ1DrSXyO4xzSwLebuU,4382
120
- reconcile/aus/base.py,sha256=RAtYkwCM2CIqv37XkgyzFyTiNNnImCD-yMQ698QYgAY,51451
120
+ reconcile/aus/base.py,sha256=Gd76QvSO2PjINjsth7sEeJPrD1a0TLYtpgNzTWIzj2w,50016
121
121
  reconcile/aus/cluster_version_data.py,sha256=VZWbUEIbrDKO-sroMpQtiWCTqDraTMd8tssKV0HyTQ0,7140
122
122
  reconcile/aus/healthchecks.py,sha256=jR9c-syh9impnkV0fd6XW3Bnk7iRN5zv8oCRYM-yIRY,2700
123
123
  reconcile/aus/metrics.py,sha256=BhIvZVTn25fIzijz3xFynJngS2sXDBTxxprUUVWJcFo,4246
@@ -737,7 +737,7 @@ reconcile/utils/ocm/sre_capability_labels.py,sha256=nqh0imrYczNeeeC7ZNX3pEwuAIVk
737
737
  reconcile/utils/ocm/status_board.py,sha256=8DYeIrOsW8Bh5PCtKdvGGpaxb9Wugcc5rLxZJ8Z7b_s,4181
738
738
  reconcile/utils/ocm/subscriptions.py,sha256=hehKXsDXIhnhqvWOuiYvx6y2FGq3zt0APGYj7WiBIdI,2765
739
739
  reconcile/utils/ocm/syncsets.py,sha256=9IQm1l5BodOVZa2OFbQmow3afmh4nXe5pn-CCJ5LxTI,1169
740
- reconcile/utils/ocm/upgrades.py,sha256=UEgfSJuC8nH6jW9JjEx91_9QeeHR1UJ_9FVOX_PlvTU,4712
740
+ reconcile/utils/ocm/upgrades.py,sha256=W8-sLgETI_418ftY9vBlXswyjx_KdhJTJO9cwBL3hfY,4162
741
741
  reconcile/utils/rosa/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
742
742
  reconcile/utils/rosa/rosa_cli.py,sha256=zV8kKG5s3oFJwyW3E7xxNzqSE7JydrmBx169Jxm8sew,11331
743
743
  reconcile/utils/rosa/session.py,sha256=CwlQJ7eEfaMjVOt_6KoNJZc4oQj-iC-EOZq8eSGzjuI,6861
@@ -797,7 +797,7 @@ tools/saas_promotion_state/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJ
797
797
  tools/saas_promotion_state/saas_promotion_state.py,sha256=oF7C4hpIgyMTwTRm3Aun3cDCHIjVar65JoLp6NcJHlU,3909
798
798
  tools/sre_checkpoints/__init__.py,sha256=CDaDaywJnmRCLyl_NCcvxi-Zc0hTi_3OdwKiFOyS39I,145
799
799
  tools/sre_checkpoints/util.py,sha256=zEDbGr18ZeHNQwW8pUsr2JRjuXIPz--WAGJxZo9sv_Y,894
800
- qontract_reconcile-0.10.2.dev277.dist-info/METADATA,sha256=0r2ZpiyGn-ZqHRMYtgMTPoV7kOLnhwFRzHA0JQYlIsQ,24501
801
- qontract_reconcile-0.10.2.dev277.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
802
- qontract_reconcile-0.10.2.dev277.dist-info/entry_points.txt,sha256=5i9l54La3vQrDLAdwDKQWC0iG4sV9RRfOb1BpvzOWLc,698
803
- qontract_reconcile-0.10.2.dev277.dist-info/RECORD,,
800
+ qontract_reconcile-0.10.2.dev279.dist-info/METADATA,sha256=4VMuEqWlD_8n_w3YF3iolN1wiU0tvQrGBovEfdKuYHE,24501
801
+ qontract_reconcile-0.10.2.dev279.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
802
+ qontract_reconcile-0.10.2.dev279.dist-info/entry_points.txt,sha256=5i9l54La3vQrDLAdwDKQWC0iG4sV9RRfOb1BpvzOWLc,698
803
+ qontract_reconcile-0.10.2.dev279.dist-info/RECORD,,
reconcile/aus/base.py CHANGED
@@ -83,8 +83,6 @@ from reconcile.utils.ocm.upgrades import (
83
83
  create_control_plane_upgrade_policy,
84
84
  create_node_pool_upgrade_policy,
85
85
  create_upgrade_policy,
86
- delete_control_plane_upgrade_policy,
87
- delete_upgrade_policy,
88
86
  get_control_plane_upgrade_policies,
89
87
  get_node_pool_upgrade_policies,
90
88
  get_upgrade_policies,
@@ -467,7 +465,7 @@ class AddonUpgradePolicy(AbstractUpgradePolicy):
467
465
 
468
466
 
469
467
  class ClusterUpgradePolicy(AbstractUpgradePolicy):
470
- """Class to create and delete ClusterUpgradePolicies in OCM"""
468
+ """Class to create ClusterUpgradePolicies in OCM"""
471
469
 
472
470
  def create(self, ocm_api: OCMBaseClient) -> None:
473
471
  policy = {
@@ -478,11 +476,7 @@ class ClusterUpgradePolicy(AbstractUpgradePolicy):
478
476
  create_upgrade_policy(ocm_api, self.cluster.id, policy)
479
477
 
480
478
  def delete(self, ocm_api: OCMBaseClient) -> None:
481
- if not self.id:
482
- raise ValueError(
483
- "Cannot delete cluster upgrade policy without id (not created yet)"
484
- )
485
- delete_upgrade_policy(ocm_api, self.cluster.id, self.id)
479
+ raise NotImplementedError("ClusterUpgradePolicy.delete() not implemented")
486
480
 
487
481
  def summarize(self) -> str:
488
482
  details = {
@@ -509,11 +503,7 @@ class ControlPlaneUpgradePolicy(AbstractUpgradePolicy):
509
503
  create_control_plane_upgrade_policy(ocm_api, self.cluster.id, policy)
510
504
 
511
505
  def delete(self, ocm_api: OCMBaseClient) -> None:
512
- if not self.id:
513
- raise ValueError(
514
- "Cannot delete controlplane upgrade policy without id (not created yet)"
515
- )
516
- delete_control_plane_upgrade_policy(ocm_api, self.cluster.id, self.id)
506
+ raise NotImplementedError("ControlPlaneUpgradePolicy.delete() not implemented")
517
507
 
518
508
  def summarize(self) -> str:
519
509
  details = {
@@ -527,7 +517,7 @@ class ControlPlaneUpgradePolicy(AbstractUpgradePolicy):
527
517
 
528
518
  class NodePoolUpgradePolicy(AbstractUpgradePolicy):
529
519
  node_pool: str
530
- """Class to create and delete NodePoolUpgradePolicies in OCM"""
520
+ """Class to create NodePoolUpgradePolicies in OCM"""
531
521
 
532
522
  def create(self, ocm_api: OCMBaseClient) -> None:
533
523
  policy = {
@@ -910,38 +900,21 @@ def upgradeable_version(
910
900
  def verify_current_should_skip(
911
901
  current_state: Sequence[AbstractUpgradePolicy],
912
902
  desired: ClusterUpgradeSpec,
913
- now: datetime,
914
- addon_id: str = "",
915
- ) -> tuple[bool, UpgradePolicyHandler | None]:
903
+ ) -> bool:
916
904
  current_policies = [c for c in current_state if c.cluster.id == desired.cluster.id]
917
905
  if not current_policies:
918
- return False, None
906
+ return False
919
907
 
920
908
  # there can only be one upgrade policy per cluster
921
909
  if len(current_policies) != 1:
922
910
  raise ValueError(
923
911
  f"[{desired.org.org_id}/{desired.cluster.name}] expected only one upgrade policy"
924
912
  )
925
- current = current_policies[0]
926
- version = current.version # may not exist in automatic upgrades
927
- if version and not addon_id and desired.version_blocked(version):
928
- next_run = current.next_run
929
- if next_run and datetime.strptime(next_run, "%Y-%m-%dT%H:%M:%SZ") < now:
930
- logging.warning(
931
- f"[{desired.org.org_id}/{desired.org.name}/{desired.cluster.name}] currently upgrading to blocked version '{version}'"
932
- )
933
- return True, None
934
- logging.debug(
935
- f"[{desired.org.org_id}/{desired.org.name}/{desired.cluster.name}] found planned upgrade policy "
936
- + f"with blocked version {version}"
937
- )
938
- return False, UpgradePolicyHandler(action="delete", policy=current)
939
913
 
940
- # else
941
914
  logging.debug(
942
915
  f"[{desired.org.org_id}/{desired.org.name}/{desired.cluster.name}] skipping cluster with existing upgrade policy"
943
916
  )
944
- return True, None
917
+ return True
945
918
 
946
919
 
947
920
  def verify_schedule_should_skip(
@@ -1129,14 +1102,8 @@ def calculate_diff(
1129
1102
  set_upgrading(spec.cluster.id, spec.effective_mutexes, sector_name)
1130
1103
  continue
1131
1104
 
1132
- # ignore clusters with an existing upgrade policy
1133
- skip, delete_policy = verify_current_should_skip(
1134
- current_state, spec, now, addon_id
1135
- )
1136
- if skip:
1105
+ if verify_current_should_skip(current_state, spec):
1137
1106
  continue
1138
- if delete_policy:
1139
- diffs.append(delete_policy)
1140
1107
 
1141
1108
  next_schedule = verify_schedule_should_skip(spec, now, addon_id)
1142
1109
  if not next_schedule:
reconcile/quay_base.py CHANGED
@@ -1,13 +1,15 @@
1
1
  from collections import namedtuple
2
+ from typing import Any
2
3
 
3
4
  from reconcile import queries
4
5
  from reconcile.utils.quay_api import QuayApi
5
6
  from reconcile.utils.secret_reader import SecretReader
6
7
 
7
8
  OrgKey = namedtuple("OrgKey", ["instance", "org_name"])
9
+ QuayApiStore = dict[OrgKey, dict[str, Any]]
8
10
 
9
11
 
10
- def get_quay_api_store():
12
+ def get_quay_api_store() -> QuayApiStore:
11
13
  """
12
14
  Returns a dictionary with a key for each Quay organization
13
15
  managed in app-interface.
@@ -1,6 +1,7 @@
1
1
  import logging
2
2
  import sys
3
3
  from collections.abc import Sequence
4
+ from typing import Any
4
5
 
5
6
  from reconcile.gql_definitions.quay_membership import quay_membership
6
7
  from reconcile.gql_definitions.quay_membership.quay_membership import (
@@ -9,13 +10,14 @@ from reconcile.gql_definitions.quay_membership.quay_membership import (
9
10
  PermissionQuayOrgTeamV1,
10
11
  UserV1,
11
12
  )
12
- from reconcile.quay_base import get_quay_api_store
13
+ from reconcile.quay_base import QuayApiStore, get_quay_api_store
13
14
  from reconcile.status import ExitCodes
14
15
  from reconcile.utils import (
15
16
  expiration,
16
17
  gql,
17
18
  )
18
19
  from reconcile.utils.aggregated_list import (
20
+ Action,
19
21
  AggregatedDiffRunner,
20
22
  AggregatedList,
21
23
  RunnerError,
@@ -33,7 +35,7 @@ def get_permissions_for_quay_membership() -> list[PermissionQuayOrgTeamV1]:
33
35
  return [p for p in query_data.permissions if isinstance(p, PermissionQuayOrgTeamV1)]
34
36
 
35
37
 
36
- def process_permission(permission: PermissionQuayOrgTeamV1):
38
+ def process_permission(permission: PermissionQuayOrgTeamV1) -> dict[str, Any]:
37
39
  """Returns a new permission object with the right keys
38
40
 
39
41
  State needs these fields: service, org, team.
@@ -52,7 +54,7 @@ def process_permission(permission: PermissionQuayOrgTeamV1):
52
54
  }
53
55
 
54
56
 
55
- def fetch_current_state(quay_api_store):
57
+ def fetch_current_state(quay_api_store: QuayApiStore) -> AggregatedList:
56
58
  state = AggregatedList()
57
59
 
58
60
  for org_key, org_data in quay_api_store.items():
@@ -85,7 +87,7 @@ def get_usernames(users: Sequence[UserV1 | BotV1 | ExternalUserV1]) -> list[str]
85
87
  return [u.quay_username for u in users if u.quay_username]
86
88
 
87
89
 
88
- def fetch_desired_state():
90
+ def fetch_desired_state() -> AggregatedList:
89
91
  permissions = get_permissions_for_quay_membership()
90
92
  state = AggregatedList()
91
93
 
@@ -105,14 +107,14 @@ def fetch_desired_state():
105
107
 
106
108
 
107
109
  class RunnerAction:
108
- def __init__(self, dry_run, quay_api_store):
110
+ def __init__(self, dry_run: bool, quay_api_store: QuayApiStore):
109
111
  self.dry_run = dry_run
110
112
  self.quay_api_store = quay_api_store
111
113
 
112
- def add_to_team(self):
114
+ def add_to_team(self) -> Action:
113
115
  label = "add_to_team"
114
116
 
115
- def action(params, items):
117
+ def action(params: dict, items: list) -> bool:
116
118
  org = params["org"]
117
119
  team = params["team"]
118
120
 
@@ -134,7 +136,7 @@ class RunnerAction:
134
136
 
135
137
  return action
136
138
 
137
- def create_team(self):
139
+ def create_team(self) -> Action:
138
140
  """
139
141
  Create an empty team in Quay. This method avoids adding users to the
140
142
  new team. add_to_team() will handle updating the member list the
@@ -142,7 +144,7 @@ class RunnerAction:
142
144
  """
143
145
  label = "create_team"
144
146
 
145
- def action(params, items):
147
+ def action(params: dict, items: list) -> bool:
146
148
  org = params["org"]
147
149
  team = params["team"]
148
150
 
@@ -164,10 +166,10 @@ class RunnerAction:
164
166
 
165
167
  return action
166
168
 
167
- def del_from_team(self):
169
+ def del_from_team(self) -> Action:
168
170
  label = "del_from_team"
169
171
 
170
- def action(params, items):
172
+ def action(params: dict, items: list) -> bool:
171
173
  org = params["org"]
172
174
  team = params["team"]
173
175
 
@@ -185,7 +187,7 @@ class RunnerAction:
185
187
  return action
186
188
 
187
189
 
188
- def run(dry_run):
190
+ def run(dry_run: bool) -> None:
189
191
  quay_api_store = get_quay_api_store()
190
192
 
191
193
  current_state = fetch_current_state(quay_api_store)
@@ -290,7 +290,7 @@ class QuayMirrorOrg:
290
290
 
291
291
 
292
292
  def run(
293
- dry_run,
293
+ dry_run: bool,
294
294
  control_file_dir: str | None,
295
295
  compare_tags: bool | None,
296
296
  compare_tags_interval: int,
@@ -77,15 +77,6 @@ def create_upgrade_policy(ocm_api: OCMBaseClient, cluster_id: str, spec: dict) -
77
77
  ocm_api.post(f"{build_cluster_url(cluster_id)}/upgrade_policies", spec)
78
78
 
79
79
 
80
- def delete_upgrade_policy(
81
- ocm_api: OCMBaseClient, cluster_id: str, policy_id: str
82
- ) -> None:
83
- """
84
- Deletes an existing Upgrade Policy
85
- """
86
- ocm_api.delete(f"{build_cluster_url(cluster_id)}/upgrade_policies/{policy_id}")
87
-
88
-
89
80
  #
90
81
  # CONTROL PLANE UPGRADE POLICIES
91
82
  #
@@ -120,17 +111,6 @@ def create_control_plane_upgrade_policy(
120
111
  )
121
112
 
122
113
 
123
- def delete_control_plane_upgrade_policy(
124
- ocm_api: OCMBaseClient, cluster_id: str, upgrade_policy_id: str
125
- ) -> None:
126
- """
127
- Deletes an existing Control Plane Upgrade Policy
128
- """
129
- ocm_api.delete(
130
- f"{build_cluster_url(cluster_id)}/control_plane/upgrade_policies/{upgrade_policy_id}"
131
- )
132
-
133
-
134
114
  #
135
115
  # NODE POOLUPGRADE POLICIES
136
116
  #