diff --git a/neutron/Chart.yaml b/neutron/Chart.yaml index 37c277547a..158110be2a 100644 --- a/neutron/Chart.yaml +++ b/neutron/Chart.yaml @@ -14,7 +14,7 @@ apiVersion: v1 appVersion: v1.0.0 description: OpenStack-Helm Neutron name: neutron -version: 0.2.20 +version: 0.2.21 home: https://docs.openstack.org/neutron/latest/ icon: https://www.openstack.org/themes/openstack/images/project-mascots/Neutron/OpenStack_Project_Neutron_vertical.png sources: diff --git a/neutron/templates/bin/_neutron-netns-cleanup-cron.py.tpl b/neutron/templates/bin/_neutron-netns-cleanup-cron.py.tpl old mode 100644 new mode 100755 index 273041ac0a..f4913edc88 --- a/neutron/templates/bin/_neutron-netns-cleanup-cron.py.tpl +++ b/neutron/templates/bin/_neutron-netns-cleanup-cron.py.tpl @@ -6,12 +6,13 @@ import time import socket from neutron.common import config from oslo_config import cfg +from oslo_concurrency import processutils from neutron.agent.linux import dhcp from neutron.agent.l3 import namespaces from neutron.agent.l3 import dvr_snat_ns from neutron.agent.l3 import dvr_fip_ns from neutron.cmd.netns_cleanup import setup_conf -from neutron.cmd.netns_cleanup import destroy_namespace +from neutron.cmd.netns_cleanup import unplug_device from neutron.cmd.netns_cleanup import eligible_for_deletion from neutron.conf.agent import common as agent_config from neutron.agent.linux import ip_lib @@ -31,10 +32,24 @@ def get_neutron_creds(): 'username': os.getenv('OS_USERNAME', 'admin'), 'cafile' : os.getenv('OS_CACERT','/var/lib/neutron/openstack-helm/openstack-helm.crt'), 'insecure' : os.getenv('NEUTRON_CLEANUP_INSECURE', 'true'), - 'debug': os.getenv('NEUTRON_CLEANUP_DEBUG', 'false'), - 'wait': os.getenv('NEUTRON_CLEANUP_TIMEOUT', '1800')} + 'debug': os.getenv('NEUTRON_CLEANUP_DEBUG', 'true'), + 'wait': os.getenv('NEUTRON_CLEANUP_TIMEOUT', '600')} return opts +def ldestroy_namespace(conf, namespace): + try: + ip = ip_lib.IPWrapper(namespace=namespace) + if ip.netns.exists(namespace): + cmd = ['ip', 'netns', 'pids', namespace] + output = processutils.execute(*cmd, run_as_root=True, root_helper=conf.AGENT.root_helper) + for pid in output[0].splitlines(): + utils.kill_process(pid, signal.SIGTERM, run_as_root=True, root_helper=conf.AGENT.root_helper) + for device in ip.get_devices(): + unplug_device(device) + ip.garbage_collect_namespace() + except Exception as e: + sys.stderr.write("Error - unable to destroy namespace: {} : {}\n".format(namespace, e)) + def net_list(neutron_get): hosts = dict() net_list = neutron_get.list_networks() @@ -64,26 +79,26 @@ def del_bad_dhcp(dhcp_ns, dhcp_hosts, conf, dhcp_prefix, debug): cut_ns_name = ns[len(dhcp_prefix):] if cut_ns_name in dhcp_hosts: if hostname not in dhcp_hosts[cut_ns_name]: - destroy_namespace(conf, ns, conf.force) + ldestroy_namespace(conf, ns) if debug: - sys.stdout.write("DEBUG: {} host {} deleted {} because host wrong\n" + sys.stderr.write("DEBUG: {} host {} deleted {} because host wrong\n" .format(sys.argv[0], hostname, ns)) else: if debug: - sys.stdout.write("DEBUG: {} host {} {} looks ok\n" + sys.stderr.write("DEBUG: {} host {} {} looks ok\n" .format(sys.argv[0], hostname, ns)) else: - destroy_namespace(conf, ns, conf.force) + ldestroy_namespace(conf, ns) if debug: - sys.stdout.write("DEBUG: {} host {} deleted {} because no related network found\n" + sys.stderr.write("DEBUG: {} host {} deleted {} because no related network found\n" .format(sys.argv[0], hostname, ns)) def del_bad_not_dhcp(not_dhcp_ns, conf, debug): for ns in not_dhcp_ns: if eligible_for_deletion(conf, ns, conf.force): - destroy_namespace(conf, ns, conf.force) + ldestroy_namespace(conf, ns) if debug: - sys.stdout.write("DEBUG: {} host {} deleted {} because no IP addr\n" + sys.stderr.write("DEBUG: {} host {} deleted {} because no IP addr\n" .format(sys.argv[0], hostname, ns)) if __name__ == "__main__": @@ -118,17 +133,17 @@ if __name__ == "__main__": del_bad_dhcp(dhcp_ns, dhcp_hosts, conf, DHCP_NS_PREFIX, debug) else: if debug: - sys.stdout.write("DEBUG: {} host {} no dhcp ns found\n" + sys.stderr.write("DEBUG: {} host {} no dhcp ns found\n" .format(sys.argv[0], hostname)) if not_dhcp_ns: del_bad_not_dhcp(not_dhcp_ns, conf, debug) else: if debug: - sys.stdout.write("DEBUG: {} host {} no not_dhcp ns found\n" + sys.stderr.write("DEBUG: {} host {} no not_dhcp ns found\n" .format(sys.argv[0], hostname)) else: if debug: - sys.stdout.write("DEBUG: {} host {} no ns found at all\n" + sys.stderr.write("DEBUG: {} host {} no ns found at all\n" .format(sys.argv[0], hostname)) except Exception as ex: sys.stderr.write( @@ -139,6 +154,4 @@ if __name__ == "__main__": sys.stderr.write( "Cleaning network namespaces caught an exception") time.sleep(30) - finally: - cfg.CONF.clear() - time.sleep(timeout) + time.sleep(timeout) \ No newline at end of file diff --git a/releasenotes/notes/neutron.yaml b/releasenotes/notes/neutron.yaml index d373776103..452dd4f829 100644 --- a/releasenotes/notes/neutron.yaml +++ b/releasenotes/notes/neutron.yaml @@ -34,4 +34,5 @@ neutron: - 0.2.18 Updated naming for subchart compatibility - 0.2.19 Added qdhcp NS host validation for deleting wrong namespaces. - 0.2.20 Add Xena and Yoga values overrides + - 0.2.21 Fix for qdhcp NS host validation for deleting wrong namespaces. ...