Ejemplo n.º 1
0
    def _check_ha_router_process_status(self):
        """Check HA router VRRP process status in network node.

        Check if the HA router HA routers VRRP (keepalived) process count
        and state change python monitor process count meet the expected
        quantity. If so, l3-agent will not call neutron to set all related
        HA port to down state, this can prevent some unexpected VRRP
        re-election. If not, a physical host may have down and just
        restarted, set HA network port status to DOWN.
        """
        if (self.conf.agent_mode not in [
                lib_const.L3_AGENT_MODE_DVR_SNAT,
                lib_const.L3_AGENT_MODE_LEGACY
        ]):
            return

        if self.ha_router_count <= 0:
            return

        # HA routers VRRP (keepalived) process count
        vrrp_pcount = linux_utils.get_process_count_by_name("keepalived")
        LOG.debug("VRRP process count %s.", vrrp_pcount)
        # HA routers state change python monitor process count
        vrrp_st_pcount = linux_utils.get_process_count_by_name(
            "neutron-keepalived-state-change")
        LOG.debug("neutron-keepalived-state-change process count %s.",
                  vrrp_st_pcount)

        # Due to the process structure design of keepalived and the current
        # config of l3-ha router, it will run one main 'keepalived' process
        # and a child  'VRRP' process. So in the following check, we divided
        # number of processes by 2 to match the ha router count.
        if (not (vrrp_pcount / 2 >= self.ha_router_count
                 and vrrp_st_pcount >= self.ha_router_count)):
            LOG.debug("Call neutron server to set HA port to DOWN state.")
            try:
                # We set HA network port status to DOWN to let l2 agent
                # update it to ACTIVE after wiring. This allows us to spawn
                # keepalived only when l2 agent finished wiring the port.
                self.plugin_rpc.update_all_ha_network_port_statuses(
                    self.context)
            except Exception:
                LOG.exception('update_all_ha_network_port_statuses failed')
Ejemplo n.º 2
0
    def _check_ha_router_process_status(self):
        """Check HA router VRRP process status in network node.

        Check if the HA router HA routers VRRP (keepalived) process count
        and state change python monitor process count meet the expected
        quantity. If so, l3-agent will not call neutron to set all related
        HA port to down state, this can prevent some unexpected VRRP
        re-election. If not, a physical host may have down and just
        restarted, set HA network port status to DOWN.
        """
        if (self.conf.agent_mode not in [lib_const.L3_AGENT_MODE_DVR_SNAT,
                                         lib_const.L3_AGENT_MODE_LEGACY]):
            return

        if self.ha_router_count <= 0:
            return

        # HA routers VRRP (keepalived) process count
        vrrp_pcount = linux_utils.get_process_count_by_name("keepalived")
        LOG.debug("VRRP process count %s.", vrrp_pcount)
        # HA routers state change python monitor process count
        vrrp_st_pcount = linux_utils.get_process_count_by_name(
            "neutron-keepalived-state-change")
        LOG.debug("neutron-keepalived-state-change process count %s.",
                  vrrp_st_pcount)

        # Due to the process structure design of keepalived and the current
        # config of l3-ha router, it will run one main 'keepalived' process
        # and a child  'VRRP' process. So in the following check, we divided
        # number of processes by 2 to match the ha router count.
        if (not (vrrp_pcount / 2 >= self.ha_router_count and
                 vrrp_st_pcount >= self.ha_router_count)):
            LOG.debug("Call neutron server to set HA port to DOWN state.")
            try:
                # We set HA network port status to DOWN to let l2 agent
                # update it to ACTIVE after wiring. This allows us to spawn
                # keepalived only when l2 agent finished wiring the port.
                self.plugin_rpc.update_all_ha_network_port_statuses(
                    self.context)
            except Exception:
                LOG.exception('update_all_ha_network_port_statuses failed')
Ejemplo n.º 3
0
 def test_root_process(self):
     cmd = ['sleep', '100']
     processes = []
     for _ in range(20):
         process = async_process.AsyncProcess(cmd)
         process.start()
         processes.append(process)
     for process in processes:
         common_utils.wait_until_true(lambda: process._process.pid,
                                      sleep=0.5,
                                      timeout=5)
     self.addCleanup(self._stop_processes, processes)
     number_of_sleep = utils.get_process_count_by_name('sleep')
     # NOTE(ralonsoh): other tests can spawn sleep processes too, but at
     # this point we know there are, at least, 20 "sleep" processes running.
     self.assertLessEqual(20, number_of_sleep)