def __init__(self, config: Dict[str, Any]): self.config = config self.name = self.config["cluster_name"] self.namespace = self.config["provider"]["namespace"] # Make directory for configs of clusters in the namespace, # if the directory doesn't exist already. namespace_dir = operator_utils.namespace_dir(self.namespace) if not os.path.isdir(namespace_dir): os.mkdir(namespace_dir) self.config_path = operator_utils.config_path( cluster_namespace=self.namespace, cluster_name=self.name) # Tracks metadata.generation field of associated custom resource. # K8s increments this field whenever the spec of the custom resource is # updated. self._generation = 0 # Tracks metadata.labels.autoscalerRetries field of the CR. # The operator increments this field whenever we attempt recovery from # autoscaler failure. self._num_retries = 0 # Monitor subprocess self.subprocess = None # type: Optional[mp.Process] # Monitor logs for this cluster will be prefixed by the monitor # subprocess name: self.subprocess_name = ",".join([self.name, self.namespace]) self.monitor_stop_event = mp.Event() self.setup_logging()
def __init__(self, config: Dict[str, Any]): self.config = config self.name = self.config["cluster_name"] self.namespace = self.config["provider"]["namespace"] # Make directory for configs of clusters in the namespace, # if the directory doesn't exist already. namespace_dir = operator_utils.namespace_dir(self.namespace) os.makedirs(namespace_dir, exist_ok=True) self.config_path = operator_utils.config_path( cluster_namespace=self.namespace, cluster_name=self.name) # Monitor subprocess # self.subprocess is non-null iff there's an active monitor subprocess # or a finished monitor subprocess in need of cleanup. self.subprocess = None # type: Optional[mp.Process] # Monitor logs for this cluster will be prefixed by the monitor # subprocess name: self.subprocess_name = ",".join([self.name, self.namespace]) self.monitor_stop_event = mp.Event() self.setup_logging()
def __init__(self, config: Dict[str, Any]): self.set_config(config) self.name = self.config["cluster_name"] self.namespace = self.config["provider"]["namespace"] # Make directory for configs of clusters in the namespace, # if the director doesn't exist already. namespace_dir = operator_utils.namespace_dir(self.namespace) if not os.path.isdir(namespace_dir): os.mkdir(namespace_dir) self.config_path = operator_utils.config_path( cluster_namespace=self.namespace, cluster_name=self.name) # Tracks metadata.generation field of associated custom resource. # K8s increments this field whenever the spec of the custom resource is # updated. self._generation = 0 self.subprocess = None # type: Optional[mp.Process] # Monitor logs for this cluster will be prefixed by the monitor # subprocess name: self.subprocess_name = ",".join([self.name, self.namespace]) self.setup_logging()