<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
        {mso-style-priority:99;
        mso-style-link:"Plain Text Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.PlainTextChar
        {mso-style-name:"Plain Text Char";
        mso-style-priority:99;
        mso-style-link:"Plain Text";
        font-family:"Calibri",sans-serif;}
span.pl-en
        {mso-style-name:pl-en;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:55014236;
        mso-list-type:hybrid;
        mso-list-template-ids:2017120114 67698689 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;}
@list l0:level1
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Symbol;}
@list l0:level2
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:"Courier New";}
@list l0:level3
        {mso-level-number-format:bullet;
        mso-level-text:\F0A7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Wingdings;}
@list l0:level4
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Symbol;}
@list l0:level5
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:"Courier New";}
@list l0:level6
        {mso-level-number-format:bullet;
        mso-level-text:\F0A7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Wingdings;}
@list l0:level7
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Symbol;}
@list l0:level8
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:"Courier New";}
@list l0:level9
        {mso-level-number-format:bullet;
        mso-level-text:\F0A7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Wingdings;}
@list l1
        {mso-list-id:1894269010;
        mso-list-type:hybrid;
        mso-list-template-ids:-422935498 67698703 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l1:level1
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:.75in;
        text-indent:-.25in;}
@list l1:level2
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:1.25in;
        text-indent:-.25in;}
@list l1:level3
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        margin-left:1.75in;
        text-indent:-9.0pt;}
@list l1:level4
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:2.25in;
        text-indent:-.25in;}
@list l1:level5
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:2.75in;
        text-indent:-.25in;}
@list l1:level6
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        margin-left:3.25in;
        text-indent:-9.0pt;}
@list l1:level7
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:3.75in;
        text-indent:-.25in;}
@list l1:level8
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:4.25in;
        text-indent:-.25in;}
@list l1:level9
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        margin-left:4.75in;
        text-indent:-9.0pt;}
ol
        {margin-bottom:0in;}
ul
        {margin-bottom:0in;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoPlainText">Hi all,<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">While I was working on fixing the resize for pci passthrough [1] I have notice the following issue in resize.<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">If you are using small image and you resize-confirm it very fast the old resources are not getting freed.<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">After debug this issue I found out the root cause of it. <o:p>
</o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">A Good run of resize is as detailed below: <o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">When doing resize the _update_usage_from_migration in the resource trucker called twice.<o:p></o:p></p>
<p class="MsoPlainText" style="margin-left:.75in;text-indent:-.25in;mso-list:l1 level1 lfo2">
<![if !supportLists]><span style="mso-list:Ignore">1.<span style="font:7.0pt "Times New Roman"">      
</span></span><![endif]><span dir="LTR"></span>The first call we return  the instance type of the new flavor and will enter this case
<o:p></o:p></p>
<p class="MsoPlainText">                     <a href="https://github.com/openstack/nova/blob/master/nova/compute/resource_tracker.py#L718">https://github.com/openstack/nova/blob/master/nova/compute/resource_tracker.py#L718</a><o:p></o:p></p>
<p class="MsoPlainText" style="margin-left:.75in;text-indent:-.25in;mso-list:l1 level1 lfo2">
<![if !supportLists]><span style="mso-list:Ignore">2.<span style="font:7.0pt "Times New Roman"">      
</span></span><![endif]><span dir="LTR"></span>Then it will put in the tracked_migrations the migration and the new instance_type
<o:p></o:p></p>
<p class="MsoPlainText">                    <a href="https://github.com/openstack/nova/blob/master/nova/compute/resource_tracker.py#L763">https://github.com/openstack/nova/blob/master/nova/compute/resource_tracker.py#L763</a><o:p></o:p></p>
<p class="MsoPlainText" style="margin-left:.75in;text-indent:-.25in;mso-list:l1 level1 lfo2">
<![if !supportLists]><span style="mso-list:Ignore">3.<span style="font:7.0pt "Times New Roman"">      
</span></span><![endif]><span dir="LTR"></span>The second call we return the old  instance_type and will enter this case<o:p></o:p></p>
<p class="MsoPlainText">                     <a href="https://github.com/openstack/nova/blob/master/nova/compute/resource_tracker.py#L725">https://github.com/openstack/nova/blob/master/nova/compute/resource_tracker.py#L725</a><o:p></o:p></p>
<p class="MsoPlainText" style="margin-left:.75in;text-indent:-.25in;mso-list:l1 level1 lfo2">
<![if !supportLists]><span style="mso-list:Ignore">4.<span style="font:7.0pt "Times New Roman"">      
</span></span><![endif]><span dir="LTR"></span>Then in the tracked_migrations it will overwrite  the old value with migration and the old instance type<o:p></o:p></p>
<p class="MsoPlainText" style="margin-left:.75in;text-indent:-.25in;mso-list:l1 level1 lfo2">
<![if !supportLists]><span style="mso-list:Ignore">5.<span style="font:7.0pt "Times New Roman"">      
</span></span><![endif]><span dir="LTR"></span><a href="https://github.com/openstack/nova/blob/master/nova/compute/resource_tracker.py#L763">https://github.com/openstack/nova/blob/master/nova/compute/resource_tracker.py#L763</a><o:p></o:p></p>
<p class="MsoPlainText" style="margin-left:.75in;text-indent:-.25in;mso-list:l1 level1 lfo2">
<![if !supportLists]><span style="mso-list:Ignore">6.<span style="font:7.0pt "Times New Roman"">      
</span></span><![endif]><span dir="LTR"></span>When doing resize-confirm the drop_move_claim called with the old instance type
<o:p></o:p></p>
<p class="MsoPlainText" style="margin-left:.75in"><a href="https://github.com/openstack/nova/blob/9a05d38f48ef0f630c5e49e332075b273cee38b9/nova/compute/manager.py#L3369">https://github.com/openstack/nova/blob/9a05d38f48ef0f630c5e49e332075b273cee38b9/nova/compute/manager.py#L3369</a><o:p></o:p></p>
<p class="MsoPlainText" style="margin-left:.75in;text-indent:-.25in;mso-list:l1 level1 lfo2">
<![if !supportLists]><span style="mso-list:Ignore">7.<span style="font:7.0pt "Times New Roman"">      
</span></span><![endif]><span dir="LTR"></span>The <span class="pl-en">drop_move_claim will compare the instance_type[id] from the
</span>tracked_migrations to the instance_type.id <span class="pl-en">(which is the old one)</span><o:p></o:p></p>
<p class="MsoPlainText" style="margin-left:.75in;text-indent:-.25in;mso-list:l1 level1 lfo2">
<![if !supportLists]><span style="mso-list:Ignore">8.<span style="font:7.0pt "Times New Roman"">      
</span></span><![endif]><span dir="LTR"></span>And because they are equals it will
<span class="pl-en"> remove the old resource usage</span><o:p></o:p></p>
<p class="MsoPlainText">                    <a href="https://github.com/openstack/nova/blob/master/nova/compute/resource_tracker.py#L315-L328">https://github.com/openstack/nova/blob/master/nova/compute/resource_tracker.py#L315-L328</a>   
<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">But with small image like CirrOS   and doing the revert-confirm fast the second call of _update_usage_from_migration will not get executing.<o:p></o:p></p>
<p class="MsoPlainText">The result is that when we enter the <span class="pl-en">
drop_move_claim it compares it with the new instance_type and this  expression is false
<a href="https://github.com/openstack/nova/blob/master/nova/compute/resource_tracker.py#L314">
https://github.com/openstack/nova/blob/master/nova/compute/resource_tracker.py#L314</a><o:p></o:p></span></p>
<p class="MsoPlainText"><span class="pl-en">This mean that this code block is not executed  <a href="https://github.com/openstack/nova/blob/master/nova/compute/resource_tracker.py#L315-L326">https://github.com/openstack/nova/blob/master/nova/compute/resource_tracker.py#L315-L326</a>
 and therefore </span>old resources are not getting freed.<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">Any thought on the matter?<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">[1] - <a href="https://review.openstack.org/#/c/307124/">
https://review.openstack.org/#/c/307124/</a> <o:p></o:p></p>
</div>
</body>
</html>