qontract-reconcile 0.10.2.dev405__py3-none-any.whl → 0.10.2.dev406__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.

Potentially problematic release.


This version of qontract-reconcile might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: qontract-reconcile
3
- Version: 0.10.2.dev405
3
+ Version: 0.10.2.dev406
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
@@ -54,7 +54,7 @@ reconcile/ocm_groups.py,sha256=gDnkhkYUEoMkI6y6ctyoKIFpJNS18SVnedW4OzJ8VWs,4174
54
54
  reconcile/ocm_machine_pools.py,sha256=KnTYAOw25N-QRb3Y7zbNY8w8xCR55WyqVjycYz24Yxk,17243
55
55
  reconcile/ocm_update_recommended_version.py,sha256=Vi3Y2sX-OQxx1mv_xiPQXnmrpsZzGIE38No0yBcTaD4,4204
56
56
  reconcile/ocm_upgrade_scheduler_org_updater.py,sha256=j4qthqx8qREB6mSbV9NT-Giq1Tu5y2EhPgIObkvmjyU,4371
57
- reconcile/openshift_base.py,sha256=m-w8VXmph1ngdiFcb_LpRqfx_XrocIrmtukz4VmFE24,55042
57
+ reconcile/openshift_base.py,sha256=TTw6da2Efyy5CMxh18CUCtuZgToMnbtszBosflLDkUs,55989
58
58
  reconcile/openshift_cluster_bots.py,sha256=POs2kBwKjzD--lElGDQbF7HOuCcOpMEclw4a9usntos,10933
59
59
  reconcile/openshift_clusterrolebindings.py,sha256=jwSaYQvUUY7noQGc148Dkqm6woYxvOEd1sume7k_sUk,6212
60
60
  reconcile/openshift_groups.py,sha256=XpIyhgnWY1XUQio1wi6sHoDtoMYdk-lpHp0-1d1RC7o,9471
@@ -628,12 +628,12 @@ reconcile/utils/make.py,sha256=QaEwucrzbl8-VHS66Wfdjfo0ubmAcvt_hZGpiGsKU50,231
628
628
  reconcile/utils/metrics.py,sha256=kiOoWO0b0mO-MDZWxyClYz9SeohQ0QU-xji0p-cSiLo,18462
629
629
  reconcile/utils/models.py,sha256=N-cOLsLbZAzVazFImue4d1pllCGd_vVcIrFKykYZXZo,4682
630
630
  reconcile/utils/oauth2_backend_application_session.py,sha256=6W16sMpnWEPFDUX7qi5Cui2yOnmLfpgUxWtB3Ii35D0,4177
631
- reconcile/utils/oc.py,sha256=ThVUVPEk7b25SPryPau0Ly1ozsX_-fp6MeeSJxQzmQI,69355
631
+ reconcile/utils/oc.py,sha256=tk1En7ShB-ny0vKL2tTPvVBHMMZcfdRS4JkTwkZ6mYU,69639
632
632
  reconcile/utils/oc_connection_parameters.py,sha256=-H2crz0UOVKWlNrexf04ip8Vu57rE2QZLJuurvin1_c,9705
633
633
  reconcile/utils/oc_filters.py,sha256=DXIA2--jlYadPGsKynnnXW_LIZra6N2wmD0MVngir5Y,1427
634
634
  reconcile/utils/oc_map.py,sha256=ougQ-Wlsa8ymoE_lPQ7g2LlpsUOsHVeRCLYW_6fjeWU,8976
635
635
  reconcile/utils/ocm_base_client.py,sha256=niBN-yHiML5ljqKMOabFTaYW9iQ8JAway37BQF2NvtM,6713
636
- reconcile/utils/openshift_resource.py,sha256=B_2yg85b93F07k6wIHQputFymC2ysl-nzvu4o0cfKAw,26027
636
+ reconcile/utils/openshift_resource.py,sha256=XTFLkaWOjNbkOD5XmCwMGdc9gKbgtKg819pWNcQVfpc,26189
637
637
  reconcile/utils/openssl.py,sha256=qdEdSmNXDgx_hhj2psEea6O12cmn3pb4GNhQJtI5l_E,399
638
638
  reconcile/utils/output.py,sha256=Rcz9BWaUDLlEWov5NSUSVy5ucx2WKeKNlUddrDjIQtk,2242
639
639
  reconcile/utils/pagerduty_api.py,sha256=kPMdegdnb9muL4PttbMVlOAbxMHltMPFLiUyQu6S7wo,7641
@@ -800,7 +800,7 @@ tools/saas_promotion_state/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJ
800
800
  tools/saas_promotion_state/saas_promotion_state.py,sha256=uQv2QJAmUXP1g2GPIH30WTlvL9soY6m9lefpZEVDM5w,3965
801
801
  tools/sre_checkpoints/__init__.py,sha256=CDaDaywJnmRCLyl_NCcvxi-Zc0hTi_3OdwKiFOyS39I,145
802
802
  tools/sre_checkpoints/util.py,sha256=KcYVfa3UmJHVP_ocgrKe8NkrO5IDB9aWEDydSokPcRk,975
803
- qontract_reconcile-0.10.2.dev405.dist-info/METADATA,sha256=eH-WJsCyUi-2jX12Didk4LiLJaaQ7VKVZOOoFN_b4n4,24946
804
- qontract_reconcile-0.10.2.dev405.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
805
- qontract_reconcile-0.10.2.dev405.dist-info/entry_points.txt,sha256=5i9l54La3vQrDLAdwDKQWC0iG4sV9RRfOb1BpvzOWLc,698
806
- qontract_reconcile-0.10.2.dev405.dist-info/RECORD,,
803
+ qontract_reconcile-0.10.2.dev406.dist-info/METADATA,sha256=FWPHfQFsB0Ne8mEHAmD6ndESIZmPM78am7UxYl5MkBc,24946
804
+ qontract_reconcile-0.10.2.dev406.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
805
+ qontract_reconcile-0.10.2.dev406.dist-info/entry_points.txt,sha256=5i9l54La3vQrDLAdwDKQWC0iG4sV9RRfOb1BpvzOWLc,698
806
+ qontract_reconcile-0.10.2.dev406.dist-info/RECORD,,
@@ -30,9 +30,11 @@ from reconcile.utils import (
30
30
  )
31
31
  from reconcile.utils.constants import DEFAULT_THREAD_POOL_SIZE
32
32
  from reconcile.utils.oc import (
33
+ AmbiguousResourceTypeError,
33
34
  DeploymentFieldIsImmutableError,
34
35
  FieldIsImmutableError,
35
36
  InvalidValueApplyError,
37
+ KindNotFoundError,
36
38
  MayNotChangeOnceSetError,
37
39
  MetaDataAnnotationsTooLongApplyError,
38
40
  OC_Map,
@@ -188,6 +190,24 @@ def init_specs_to_fetch(
188
190
  continue
189
191
 
190
192
  managed_resource_names = namespace_info.get("managedResourceNames") or []
193
+ try:
194
+ validate_managed_resource_types(
195
+ oc,
196
+ managed_types,
197
+ managed_resource_names,
198
+ cluster_scope_resource_validation=cluster_scope_resource_validation,
199
+ )
200
+ except KindNotFoundError:
201
+ # We must allow kinds that are not supported by the cluster because:
202
+ # 1. We install CRD with an operator in the same MR
203
+ # 2. SAAS files initialize the namespace objects with managedResourceTypes from the SAAS file
204
+ # and we can't expect that all of those are valid for all clusters
205
+ pass
206
+ except (AmbiguousResourceTypeError, ValidationError) as e:
207
+ ri.register_error()
208
+ logging.error(f"[{cluster}/{namespace_info['name']}] {e}")
209
+ continue
210
+
191
211
  namespace = namespace_info["name"]
192
212
  # These may exit but have a value of None
193
213
  managed_resource_type_overrides = (
reconcile/utils/oc.py CHANGED
@@ -146,6 +146,14 @@ class RequestEntityTooLargeError(Exception):
146
146
  pass
147
147
 
148
148
 
149
+ class KindNotFoundError(Exception):
150
+ pass
151
+
152
+
153
+ class AmbiguousResourceTypeError(Exception):
154
+ pass
155
+
156
+
149
157
  class OCDecorators:
150
158
  @classmethod
151
159
  def process_reconcile_time(cls, function: Callable) -> Callable:
@@ -1232,7 +1240,7 @@ class OCCli:
1232
1240
  try:
1233
1241
  self.get_api_resource(kind)
1234
1242
  return True
1235
- except RuntimeError:
1243
+ except KindNotFoundError:
1236
1244
  return False
1237
1245
 
1238
1246
  def is_kind_namespaced(self, kind: str) -> bool:
@@ -1253,25 +1261,26 @@ class OCCli:
1253
1261
  kind, group, _ = self.parse_kind(kind)
1254
1262
 
1255
1263
  if not (resources := self.api_resources.get(kind)):
1256
- raise RuntimeError(f"Unsupported resource type: {kind}")
1264
+ # the kind not found at all
1265
+ raise KindNotFoundError(f"Unsupported resource type: {kind}")
1257
1266
 
1258
1267
  if len(resources) == 1 and group == DEFAULT_GROUP:
1259
1268
  return resources[0]
1260
1269
 
1261
- resource = next(
1262
- (r for r in resources if r.group == group),
1263
- None,
1264
- )
1265
- if resource is None:
1270
+ # get the resource with the specified group
1271
+ if resource := next((r for r in resources if r.group == group), None):
1272
+ return resource
1273
+
1274
+ # no resource with the specified group found
1275
+ if group == DEFAULT_GROUP:
1266
1276
  message = (
1267
1277
  f"Ambiguous resource type: {kind}. "
1268
1278
  "Please fully qualify it with its API group. E.g., ClusterRoleBinding -> ClusterRoleBinding.rbac.authorization.k8s.io"
1269
- if group == DEFAULT_GROUP
1270
- else f"Unsupported resource type: {kind}"
1271
1279
  )
1272
- raise RuntimeError(message)
1280
+ raise AmbiguousResourceTypeError(message)
1273
1281
 
1274
- return resource
1282
+ # group was specified but no matching resource found
1283
+ raise KindNotFoundError(f"Unsupported resource type: {kind}")
1275
1284
 
1276
1285
 
1277
1286
  REQUEST_TIMEOUT = 60
@@ -5,6 +5,7 @@ import base64
5
5
  import contextlib
6
6
  import copy
7
7
  import hashlib
8
+ import logging
8
9
  import re
9
10
  from threading import Lock
10
11
  from typing import TYPE_CHECKING, Any
@@ -601,6 +602,10 @@ class ResourceInventory:
601
602
  resource: OpenshiftResource,
602
603
  privileged: bool = False,
603
604
  ) -> None:
605
+ if cluster not in self._clusters:
606
+ logging.error(f"Cluster {cluster} not initialized in ResourceInventory")
607
+ return
608
+
604
609
  if resource.kind_and_group in self._clusters[cluster][namespace]:
605
610
  kind = resource.kind_and_group
606
611
  else: