qontract-reconcile 0.10.2.dev144__py3-none-any.whl → 0.10.2.dev145__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.dev144
3
+ Version: 0.10.2.dev145
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
@@ -628,7 +628,7 @@ 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=BYsgjWyuwO7obMhqADsqEQ-_YJrmy8LmFKHSLMFbo1g,4645
630
630
  reconcile/utils/oauth2_backend_application_session.py,sha256=6W16sMpnWEPFDUX7qi5Cui2yOnmLfpgUxWtB3Ii35D0,4177
631
- reconcile/utils/oc.py,sha256=SbEtMshm3CagudXU-y0C0F6_IkeuvAKKVG2xNvnxXwU,65673
631
+ reconcile/utils/oc.py,sha256=aMv6vlpYm6o-w8yWXjNQy3ev3hsmjtd1IktSOitsXq4,65560
632
632
  reconcile/utils/oc_connection_parameters.py,sha256=7DiEGo--TJelfYoZXJFyTBPeTw9kXL3L58vy2fiJnes,9643
633
633
  reconcile/utils/oc_filters.py,sha256=Tz3OwtbUaYKmxENFls5CtPVzkZDeFXknw53dJe-wbT8,1382
634
634
  reconcile/utils/oc_map.py,sha256=ougQ-Wlsa8ymoE_lPQ7g2LlpsUOsHVeRCLYW_6fjeWU,8976
@@ -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=UfwwRLS5Ya4_Nh1w5n1dvoYtchQvYE9yj1VANt2IKqI,3925
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.dev144.dist-info/METADATA,sha256=W4dinHk19OLb8OmTDvt77mBpLL_E05WwUn2e0sDnRr0,24627
801
- qontract_reconcile-0.10.2.dev144.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
802
- qontract_reconcile-0.10.2.dev144.dist-info/entry_points.txt,sha256=5i9l54La3vQrDLAdwDKQWC0iG4sV9RRfOb1BpvzOWLc,698
803
- qontract_reconcile-0.10.2.dev144.dist-info/RECORD,,
800
+ qontract_reconcile-0.10.2.dev145.dist-info/METADATA,sha256=Vv7MIziQ6gUpVdVo0qHBWdQeFDG6Eh9er8-hXsbqqsI,24627
801
+ qontract_reconcile-0.10.2.dev145.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
802
+ qontract_reconcile-0.10.2.dev145.dist-info/entry_points.txt,sha256=5i9l54La3vQrDLAdwDKQWC0iG4sV9RRfOb1BpvzOWLc,698
803
+ qontract_reconcile-0.10.2.dev145.dist-info/RECORD,,
reconcile/utils/oc.py CHANGED
@@ -14,7 +14,7 @@ from collections.abc import (
14
14
  from contextlib import suppress
15
15
  from dataclasses import dataclass
16
16
  from datetime import datetime
17
- from functools import wraps
17
+ from functools import cache, wraps
18
18
  from subprocess import Popen
19
19
  from threading import Lock
20
20
  from typing import Any
@@ -37,7 +37,10 @@ from kubernetes.dynamic.exceptions import (
37
37
  ResourceNotUniqueError,
38
38
  ServerTimeoutError,
39
39
  )
40
- from kubernetes.dynamic.resource import ResourceList
40
+ from kubernetes.dynamic.resource import (
41
+ Resource,
42
+ ResourceList,
43
+ )
41
44
  from prometheus_client import Counter
42
45
  from sretoolbox.utils import (
43
46
  retry,
@@ -1241,6 +1244,7 @@ class OCNative(OCCli):
1241
1244
  insecure_skip_tls_verify=insecure_skip_tls_verify,
1242
1245
  connection_parameters=connection_parameters,
1243
1246
  )
1247
+ self._get_obj_client = cache(self.__get_obj_client)
1244
1248
 
1245
1249
  if connection_parameters:
1246
1250
  token = connection_parameters.automation_token
@@ -1256,7 +1260,6 @@ class OCNative(OCCli):
1256
1260
  else:
1257
1261
  raise Exception("A method relies on client/api_kind_version to be set")
1258
1262
 
1259
- self.object_clients: dict[Any, Any] = {}
1260
1263
  self.projects = set()
1261
1264
  self.init_projects = init_projects
1262
1265
  if self.init_projects:
@@ -1308,13 +1311,8 @@ class OCNative(OCCli):
1308
1311
  except urllib3.exceptions.MaxRetryError as e:
1309
1312
  raise StatusCodeError(f"[{self.server}]: {e}") from None
1310
1313
 
1311
- def _get_obj_client(self, kind, group_version):
1312
- key = f"{kind}.{group_version}"
1313
- if key not in self.object_clients:
1314
- self.object_clients[key] = self.client.resources.get(
1315
- api_version=group_version, kind=kind
1316
- )
1317
- return self.object_clients[key]
1314
+ def __get_obj_client(self, kind: str, group_version: str) -> Resource:
1315
+ return self.client.resources.get(api_version=group_version, kind=kind)
1318
1316
 
1319
1317
  @retry(max_attempts=5, exceptions=(ServerTimeoutError))
1320
1318
  def get_items(self, kind, **kwargs):