mirror of
https://github.com/bunkerity/bunkerweb
synced 2026-05-24 09:28:37 +00:00
autoconf - fix deadlock with k8s
This commit is contained in:
parent
38ab5ea21a
commit
03ba91e968
3 changed files with 4 additions and 14 deletions
|
|
@ -1,7 +1,6 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
from os import getenv
|
||||
from threading import Lock
|
||||
from time import sleep
|
||||
from typing import Optional
|
||||
|
||||
|
|
@ -11,9 +10,8 @@ from logger import setup_logger # type: ignore
|
|||
|
||||
|
||||
class Config(ConfigCaller):
|
||||
def __init__(self, lock: Optional[Lock] = None):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.__lock = lock
|
||||
self.__logger = setup_logger("Config", getenv("LOG_LEVEL", "INFO"))
|
||||
self.__instances = []
|
||||
self.__services = []
|
||||
|
|
@ -80,9 +78,6 @@ class Config(ConfigCaller):
|
|||
)
|
||||
sleep(5)
|
||||
|
||||
if self.__lock:
|
||||
self.__lock.acquire()
|
||||
|
||||
# update instances in database
|
||||
err = self._db.update_instances(self.__instances)
|
||||
if err:
|
||||
|
|
@ -104,7 +99,4 @@ class Config(ConfigCaller):
|
|||
f"Can't save autoconf custom configs in database: {err}, custom configs may not work as expected",
|
||||
)
|
||||
|
||||
if self.__lock:
|
||||
self.__lock.release()
|
||||
|
||||
return success
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
from abc import ABC, abstractmethod
|
||||
from os import getenv
|
||||
from threading import Lock
|
||||
from time import sleep
|
||||
from typing import Literal, Optional, Union
|
||||
|
||||
|
|
@ -15,9 +14,8 @@ class Controller(Config):
|
|||
def __init__(
|
||||
self,
|
||||
ctrl_type: Union[Literal["docker"], Literal["swarm"], Literal["kubernetes"]],
|
||||
lock: Optional[Lock] = None,
|
||||
):
|
||||
super().__init__(lock)
|
||||
super().__init__()
|
||||
self._type = ctrl_type
|
||||
self._instances = []
|
||||
self._services = []
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ from Controller import Controller
|
|||
class IngressController(Controller):
|
||||
def __init__(self):
|
||||
self.__internal_lock = Lock()
|
||||
super().__init__("kubernetes", self.__internal_lock)
|
||||
super().__init__("kubernetes")
|
||||
config.load_incluster_config()
|
||||
self.__corev1 = client.CoreV1Api()
|
||||
self.__networkingv1 = client.NetworkingV1Api()
|
||||
|
|
@ -31,7 +31,7 @@ class IngressController(Controller):
|
|||
def _to_instances(self, controller_instance) -> List[dict]:
|
||||
instance = {}
|
||||
instance["name"] = controller_instance.metadata.name
|
||||
instance["hostname"] = controller_instance.status.pod_ip
|
||||
instance["hostname"] = controller_instance.status.pod_ip or controller_instance.metadata.name
|
||||
health = False
|
||||
if controller_instance.status.conditions:
|
||||
for condition in controller_instance.status.conditions:
|
||||
|
|
|
|||
Loading…
Reference in a new issue