<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif;">
<div>
<div>
<div>Any comments/input on this?</div>
<div>Ajay</div>
<div><br>
</div>
<div>
<div id="MAC_OUTLOOK_SIGNATURE"></div>
</div>
</div>
</div>
<div><br>
</div>
<span id="OLK_SRC_BODY_SECTION">
<div style="font-family:Calibri; font-size:12pt; text-align:left; color:black; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt">
<span style="font-weight:bold">From: </span>Ajay Kalambur <<a href="mailto:akalambu@cisco.com">akalambu@cisco.com</a>><br>
<span style="font-weight:bold">Date: </span>Monday, October 10, 2016 at 6:31 PM<br>
<span style="font-weight:bold">To: </span>"OpenStack Development Mailing List (not for usage questions)" <<a href="mailto:openstack-dev@lists.openstack.org">openstack-dev@lists.openstack.org</a>><br>
<span style="font-weight:bold">Subject: </span>[openstack][nova] Port unbound from active VM<br>
</div>
<div><br>
</div>
<span style="mso-bookmark:_MailOriginalBody">
<div>
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
<div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px;">
Hi</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px;">
There seems to be a corner case bug in nova code. Steps to reproduce it are</div>
<ol style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px;">
<li>Create a neutron port  </li><li>Create a VM and launch instance with this port</li><li>Shutdown nova compute and network agent on compute node</li><li>Unbind port from VM and delete the VM (offline delete) </li><li>Now create a VM with same port but on a different compute node</li><li>Bring up nova compute on old node</li></ol>
<div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px;">
It basically runs the reap for deleted instances and cleanes up VM from libvirt. In the process it unbinds the pre-existing ports and ends up unbinding the port from an active VM on a different compute node</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px;">
Reason nova simply sends a blind port-update with binding_host: “” even if that port is bound to a different instance</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px;">
<br>
</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px;">
<br>
</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px;">
So following fix seemed to help any suggestions on a better fix</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px;">
<br>
</div>
<div><font face="Calibri,sans-serif">In </font><font face="Menlo"><span style="font-size: 12px;">nova/network/neutronv2/api.py. So basically when neutron sees no ports for this instance don’t attempt an unbind</span></font></div>
<div><font face="Menlo"><span style="font-size: 12px;">In this case </span></font><span style="font-family: Menlo; font-size: 12px;">        </span></div>
<div><span style="font-family: Menlo; font-size: 12px;">data = neutron.list_ports(**search_opts)</span></div>
<div><font face="Menlo"><span style="font-size: 12px;">C</span></font><span style="font-family: Menlo; font-size: 12px;">all in </span><span style="font-family: Menlo; font-size: 12px;">deallocate_for_instance returns empty ports</span></div>
<div><span style="font-family: Menlo; font-size: 12px;"><br>
</span></div>
<div><font face="Menlo"><span style="font-size: 12px;"><br>
</span></font></div>
<div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px;">
<span style="font-family: Menlo; font-size: 12px;"><br>
</span></div>
<div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px;">
<p style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo;">
<span style="font-variant-ligatures: no-common-ligatures">      # Reset device_id and device_owner for the ports that are skipped</span></p>
<p style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo;">
<span style="font-variant-ligatures: no-common-ligatures">        if data.get('ports', []):</span></p>
<p style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo;">
<span style="font-variant-ligatures: no-common-ligatures">            self._unbind_ports(context, ports_to_skip, neutron)</span></p>
<p style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo;">
<span style="font-variant-ligatures: no-common-ligatures">        else:</span></p>
<p style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo;">
<span style="font-variant-ligatures: no-common-ligatures">            LOG.debug("Neutron sees a different view of this port hence skipping unbind”)</span></p>
<p style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo;">
<span style="font-variant-ligatures: no-common-ligatures"><br>
</span></p>
<p style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo;">
<span style="font-variant-ligatures: no-common-ligatures"><br>
</span></p>
<p style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo;">
<span style="font-variant-ligatures: no-common-ligatures">Ajay</span></p>
<p style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo;">
<span style="font-variant-ligatures: no-common-ligatures"><br>
</span></p>
</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px;">
<div id=""></div>
</div>
</div>
</div>
</span></span>
</body>
</html>