<div dir="ltr"><div>Hi Shihan,</div><div><br></div><div>I think the problem is slightly different. Does your patch take care of the scenario where a port was deleted  AFTER agent restart (not when agent was down)?</div><div><br></div><div>My problem is that, when the agent restarts, it loses its previous network cache. As soon as the agent starts, as part of "__init__", it rebuilds that cache [1]. But it does not put the ports in there [2].</div><div><br></div><div>In sync_state, Neutron tries to enable/disable networks, by checking the diff between Neutron's state and its own network cache that it just built [3]. It enables any NEW networks and disables any DELETED networks, but it does nothing to PREVIOUSLY KNOWN NETWORKS. So those subnets and ports remain empty lists.</div><div><br></div><div>Now, if such a port is deleted, [4] will return None and the port will never get deleted from the config.</div><div><br></div><div>[1] <a href="https://github.com/openstack/neutron/blob/master/neutron/agent/dhcp/agent.py#L68">https://github.com/openstack/neutron/blob/master/neutron/agent/dhcp/agent.py#L68</a></div><div>[2] <a href="https://github.com/openstack/neutron/blob/master/neutron/agent/dhcp/agent.py#L79-L86">https://github.com/openstack/neutron/blob/master/neutron/agent/dhcp/agent.py#L79-L86</a></div><div>[3] <a href="https://github.com/openstack/neutron/blob/master/neutron/agent/dhcp/agent.py#L154-L171">https://github.com/openstack/neutron/blob/master/neutron/agent/dhcp/agent.py#L154-L171</a></div><div>[4] <a href="https://github.com/openstack/neutron/blob/master/neutron/agent/dhcp/agent.py#L349">https://github.com/openstack/neutron/blob/master/neutron/agent/dhcp/agent.py#L349</a></div><div><br></div><div><br></div></div>