From 0c170ea135fff97a7fe5b315be6bbfed261259d9 Mon Sep 17 00:00:00 2001 From: Ricardo Diaz Date: Thu, 20 May 2021 12:21:34 +0200 Subject: [PATCH] M #-: nodeport post needs deactivate (#1237) When resuming a VM powered-off from guest OS (and it is monitored as powered-off by the OpenNebula monitor), it fails because 'ip route add' fails when an already existing route is configured. If 'ip route add' is changed by 'ip route replace' (idempotent) the problem is solved; however, duplicated iptables rules are added. Therefore, to have this working for all scenarios a deactivate is called on driver to clean the VM route and the all the iptables rules previos to the call to activate. Signed-off-by: Ricardo Diaz (cherry picked from commit cc2ae9ef7bb54b30a9480dd4f56cd7d59286af03) --- src/vnm_mad/remotes/nodeport/nodeport.rb | 4 ++-- src/vnm_mad/remotes/nodeport/post | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/vnm_mad/remotes/nodeport/nodeport.rb b/src/vnm_mad/remotes/nodeport/nodeport.rb index b4509c85b2..979c9854c4 100644 --- a/src/vnm_mad/remotes/nodeport/nodeport.rb +++ b/src/vnm_mad/remotes/nodeport/nodeport.rb @@ -100,9 +100,9 @@ class NodePortDriver < VNMMAD::VNMDriver "#{nic[:bridge]} | true" cmds.add :iptables, '-t nat -D PREROUTING -p tcp --dport ' \ "#{nic[:external_port_range]} -j DNAT --to " \ - "#{nic[:ip]}:#{nic[:internal_port_range]}" + "#{nic[:ip]}:#{nic[:internal_port_range]} | true" cmds.add :iptables, '-t nat -D POSTROUTING -j MASQUERADE ' \ - "-s #{nic[:ip]}" + "-s #{nic[:ip]} | true" end if rc != false diff --git a/src/vnm_mad/remotes/nodeport/post b/src/vnm_mad/remotes/nodeport/post index dfc3129633..fb122ffbd8 100755 --- a/src/vnm_mad/remotes/nodeport/post +++ b/src/vnm_mad/remotes/nodeport/post @@ -31,6 +31,9 @@ begin xpath_filter, deploy_id, false) + + drv.deactivate + filter_driver.activate(true) if drv.activate == 0 rescue Exception => e OpenNebula.log_error(e.message)