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 <rdiaz@opennebula.io>
This commit is contained in:
Ricardo Diaz authored and GitHub committed 2021-05-20 12:21:34 +02:00
1 parent 7078b8d298
commit cc2ae9ef7b
2 files changed
+5 -2

No files matched your search

+2 -2
View File
@@ -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
+3
View File
@@ -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)