<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jan 12, 2015 at 3:33 PM, Angus Salkeld <span dir="ltr"><<a href="mailto:asalkeld@mirantis.com" target="_blank">asalkeld@mirantis.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Mon, Jan 12, 2015 at 10:17 PM, Konstantin Danilov <span dir="ltr"><<a href="mailto:kdanilov@mirantis.com" target="_blank">kdanilov@mirantis.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Boris, <br><br></div><div>Move from sync http to something like websocket requires a lot of work and not directly connected <br>with API issue. When openstack api servers begin to support<br></div><div>websockets - it would be easy to change implementation of monitoring thread without breaking compatibility.<br></div><div>At the moment periodical pooling from additional thread looks reasonable for me<br></div><div>and it creates same amount of http requests as all current implementation. <br><br>BP is not about improving performance,<br></div><div>but about providing convenient and common API to handle background tasks.<br></div><span><div><br>> So we won't need to retrieve 100500 times information about object.<br></div></span><div>As I sad before - this API creates same amount of load as any code which we use to check background task currently.<br></div><div>It even can decrease load due to requests aggregation in some cases (but there a points to discuss).<span><br><br><div>> As well this pattern doesn't look great.<br></div><div>> I would prefer to see something like: </div></span><div>> vm = novaclient.servers.create(...., sync=True)<br><br>This is completely different pattern. It is blocking call, which don't allows you to start two(or more) background tasks<br>and from same thread and make some calculations while they running in background. <br></div></div></div></blockquote><div><br></div></span><div>Except if you use threads (eventlet or other) - I am still struggling to enjoy Futures/yield based flowcontrol, lost battle i guess:(. <br></div></div></div></div></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div></div><br></div><div><br><br><br></div></div><div class="gmail_extra"><div><div><br><div class="gmail_quote">On Mon, Jan 12, 2015 at 1:42 PM, Boris Pavlovic <span dir="ltr"><<a href="mailto:bpavlovic@mirantis.com" target="_blank">bpavlovic@mirantis.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Konstantin,<div><br></div><div><br></div><div>I believe it's better to work on server side, and use some modern approach like web sockets for async operations. So we won't need to retrieve 100500 times information about object. And then use this feature in clients. </div><span><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span style="font-size:13px"> create_future = novaclient.servers.create_</span><span style="font-size:13px">async(....)<br></span><span style="font-size:13px">    .....<br></span><span style="font-size:13px">    vm = create_future.result()</span></blockquote><div><br></div></span><div>As well this pattern doesn't look great. </div><div><br></div><div>I would prefer to see something like: </div><div><br></div><div>  vm = novaclient.servers.create(...., sync=True)</div><div><br></div><div><br></div><div>Best regards,</div><div>Boris Pavlovic </div><div><br></div><div><br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div>On Mon, Jan 12, 2015 at 2:30 PM, Konstantin Danilov <span dir="ltr"><<a href="mailto:kdanilov@mirantis.com" target="_blank">kdanilov@mirantis.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div><div dir="ltr"><div>Hi all.<br></div><div><br>There a set of openstack api functions which starts background actions<br>and return preliminary results - like 'novaclient.create'. Those functions<br>requires periodically check results and handle timeouts/errors<br>(and often cleanup + restart help to fix an error).<br><br>Check/retry/cleanup code duplicated over a lot of core projects.<br>As examples - heat, tempest, rally, etc and definitely in many third-party scripts.<br></div></div></div></div></blockquote></div></div></blockquote></div></div></div></div></blockquote><div><br></div></span><div>We have some very similar code at the moment, but we are keen to move away from it to<br></div><div>something like making use of rpc ".{start,end}" notifications to reduce the load we put on keystone and<br>friends.<br></div></div></div></div></blockquote><div><br></div><div>This is nice approach for core projects, yet novaclient users are typically can't use such approach.<br><br></div><div>But the nice things about futures is that we can have different engines (websockets, sync http, rpc with callbacks, etc)<br>behind same API, and hide all implementation details behind it.  It's even possible to use them in simultaneously - <br>different engine would used to handle different calls.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div></div><span class=""><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail_extra"><div><div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div><div dir="ltr"><div><br>I propose to provide common higth-level API for such functions, which uses<br>'futures' (<a href="http://en.wikipedia.org/wiki/Futures_and_promises" target="_blank">http://en.wikipedia.org/wiki/Futures_and_promises</a>) as a way to<br>present background task.<br><br>Idea is to add to each background-task-starter function a complimentary call,<br>that returns 'future' object. E.g.<br><br>    create_future = novaclient.servers.create_async(....)<br>    .....<br>    vm = create_future.result()<br></div></div></div></div></blockquote></div></div></blockquote></div></div></div></div></blockquote><div><br></div></span>Is that going to return on any state change or do you pass in a list of acceptable states?<span class=""><font color="#888888"><br></font></span></div></div></div></blockquote><div><br></div><div>In general it should returns result if background task is completed successfully or raise exception <br></div><div>if it fails. For server I currently use 'active' as success marker and 'error' or timeout for exception<br>( <a href="https://github.com/koder-ua/os_api/blob/master/os_api/nova.py#L74">https://github.com/koder-ua/os_api/blob/master/os_api/nova.py#L74</a> ), and hope that expected states <br>can be calculated from api call/parameters automatically, but not 100% sure. So - yes, additional <br></div><div>parameter might be required.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class=""><font color="#888888"><br></font></span></div><span class=""><font color="#888888"><div class="gmail_quote">-Angus<br> <br></div></font></span><div><div class="h5"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail_extra"><div><div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div><div dir="ltr"><div><br>This allows to unify(and optimize) monitoring cycles, retries, etc.<br>Please found complete BP at<br><a href="https://github.com/koder-ua/os_api/blob/master/README.md" target="_blank">https://github.com/koder-ua/os_api/blob/master/README.md</a><br><br clear="all"></div>Thanks<span><font color="#888888"><br><div>-- <br><div>Kostiantyn Danilov aka <a href="http://koder.ua" target="_blank">koder</a><br>Principal software engineer, Mirantis<br><br>skype:<a href="http://koder.ua" target="_blank">koder.ua</a><br><a href="http://koder-ua.blogspot.com/" target="_blank">http://koder-ua.blogspot.com/</a><br><a href="http://mirantis.com" target="_blank">http://mirantis.com</a></div>
</div></font></span></div>
<br></div></div>__________________________________________________________________________<br>
OpenStack Development Mailing List (not for usage questions)<br>
Unsubscribe: <a href="http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe" target="_blank">OpenStack-dev-request@lists.openstack.org?subject:unsubscribe</a><br>
<a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br>
<br></blockquote></div><br></div>
<br>__________________________________________________________________________<br>
OpenStack Development Mailing List (not for usage questions)<br>
Unsubscribe: <a href="http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe" target="_blank">OpenStack-dev-request@lists.openstack.org?subject:unsubscribe</a><br>
<a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br>
<br></blockquote></div><br><br clear="all"><br></div></div><span><font color="#888888">-- <br></font></span><div><span><font color="#888888">Kostiantyn Danilov aka <a href="http://koder.ua" target="_blank">koder.ua</a></font></span><span><br>Principal software engineer, Mirantis<br><br>skype:<a href="http://koder.ua" target="_blank">koder.ua</a><br><a href="http://koder-ua.blogspot.com/" target="_blank">http://koder-ua.blogspot.com/</a><br><a href="http://mirantis.com" target="_blank">http://mirantis.com</a></span></div>
</div>
<br>__________________________________________________________________________<br>
OpenStack Development Mailing List (not for usage questions)<br>
Unsubscribe: <a href="http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe" target="_blank">OpenStack-dev-request@lists.openstack.org?subject:unsubscribe</a><br>
<a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br>
<br></blockquote></div><br></div></div></div></div>
<br>__________________________________________________________________________<br>
OpenStack Development Mailing List (not for usage questions)<br>
Unsubscribe: <a href="http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe" target="_blank">OpenStack-dev-request@lists.openstack.org?subject:unsubscribe</a><br>
<a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature">Kostiantyn Danilov aka <a href="http://koder.ua" target="_blank">koder.ua</a><br>Principal software engineer, Mirantis<br><br>skype:<a href="http://koder.ua" target="_blank">koder.ua</a><br><a href="http://koder-ua.blogspot.com/" target="_blank">http://koder-ua.blogspot.com/</a><br><a href="http://mirantis.com" target="_blank">http://mirantis.com</a></div>
</div></div>