Пример #1
0
    def __init__(self):
        # NOTE(mdulko): Default shutdown timeout is 60 seconds and K8s won't
        #               wait more by default anyway.
        super(CNIDaemonServiceManager, self).__init__()
        # TODO(dulek): Use cotyledon.oslo_config_glue to support conf reload.

        # TODO(vikasc): Should be done using dynamically loadable OVO types
        #               plugin.
        objects.register_locally_defined_vifs()

        os_vif.initialize()
        clients.setup_kubernetes_client()
        if CONF.sriov.enable_pod_resource_service:
            clients.setup_pod_resources_client()

        self.manager = multiprocessing.Manager()
        registry = self.manager.dict()  # For Watcher->Server communication.
        healthy = multiprocessing.Value(c_bool, True)
        self.add(CNIDaemonWatcherService,
                 workers=1,
                 args=(
                     registry,
                     healthy,
                 ))
        self._server_service = self.add(CNIDaemonServerService,
                                        workers=1,
                                        args=(registry, healthy))
        self.add(CNIDaemonHealthServerService, workers=1, args=(healthy, ))
        self.register_hooks(on_terminate=self.terminate)
Пример #2
0
    def __init__(self):
        # NOTE(mdulko): Default shutdown timeout is 60 seconds and K8s won't
        #               wait more by default anyway.
        super(CNIDaemonServiceManager, self).__init__()
        self._server_service = None
        # TODO(dulek): Use cotyledon.oslo_config_glue to support conf reload.

        # TODO(vikasc): Should be done using dynamically loadable OVO types
        #               plugin.
        objects.register_locally_defined_vifs()

        os_vif.initialize()
        clients.setup_kubernetes_client()
        if CONF.sriov.enable_pod_resource_service:
            clients.setup_pod_resources_client()

        self.manager = multiprocessing.Manager()
        registry = self.manager.dict()  # For Watcher->Server communication.
        healthy = multiprocessing.Value(c_bool, True)
        metrics = self.manager.Queue()
        self.add(watcher_service.KuryrPortWatcherService,
                 workers=1,
                 args=(
                     registry,
                     healthy,
                 ))
        self.add(watcher_service.PodWatcherService,
                 workers=1,
                 args=(
                     registry,
                     healthy,
                 ))
        self._server_service = self.add(CNIDaemonServerService,
                                        workers=1,
                                        args=(
                                            registry,
                                            healthy,
                                            metrics,
                                        ))
        self.add(CNIDaemonHealthServerService, workers=1, args=(healthy, ))
        self.add(CNIDaemonExporterService, workers=1, args=(metrics, ))

        def shutdown_hook(service_id, worker_id, exit_code):
            LOG.critical(f'Child Service {service_id} had exited with code '
                         f'{exit_code}, stopping kuryr-daemon')
            self.shutdown()

        self.register_hooks(on_terminate=self.terminate,
                            on_dead_worker=shutdown_hook)