Merge "Exit rpc_loop when SIGTERM is recieved in ovs-agent"

This commit is contained in:
Jenkins 2014-06-27 03:22:47 +00:00 committed by Gerrit Code Review
commit e2d5f19221

View File

@ -216,6 +216,7 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
root_helper)
# Initialize iteration counter
self.iter_num = 0
self.run_daemon_loop = True
def _check_arp_responder_support(self):
'''Check if OVS supports to modify ARP headers.
@ -1340,7 +1341,7 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
ancillary_ports = set()
tunnel_sync = True
ovs_restarted = False
while True:
while self.run_daemon_loop:
start = time.time()
port_stats = {'regular': {'added': 0,
'updated': 0,
@ -1467,9 +1468,9 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
self.rpc_loop(polling_manager=pm)
def handle_sigterm(signum, frame):
sys.exit(1)
def _handle_sigterm(self, signum, frame):
LOG.debug("Agent caught SIGTERM, quitting daemon loop.")
self.run_daemon_loop = False
def create_agent_config_map(config):
@ -1533,12 +1534,11 @@ def main():
cfg.CONF.set_default('ip_lib_force_root', True)
agent = OVSNeutronAgent(**agent_config)
signal.signal(signal.SIGTERM, handle_sigterm)
signal.signal(signal.SIGTERM, agent._handle_sigterm)
# Start everything.
LOG.info(_("Agent initialized successfully, now running... "))
agent.daemon_loop()
sys.exit(0)
if __name__ == "__main__":