nova python client is not process safe

Bug #1297796 reported by Boris Pavlovic
18
This bug affects 2 people
Affects Status Importance Assigned to Milestone
python-novaclient
Fix Released
High
Unassigned

Bug Description

Nova python clients shares sockets between process:

this code:
https://github.com/openstack/python-novaclient/blob/master/novaclient/client.py#L42-L52

And sharing socket between process is last thing that you would like to see in your code.

Changed in nova:
assignee: nobody → Boris Pavlovic (boris-42)
importance: Undecided → High
Revision history for this message
Matthias Runge (mrunge) wrote :
Tracy Jones (tjones-i)
no longer affects: nova
Revision history for this message
Boris Pavlovic (boris-42) wrote :

It still affects nova, and we are going to revert that patch

Changed in python-novaclient:
importance: Undecided → High
status: New → Confirmed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-novaclient (master)

Reviewed: https://review.openstack.org/83041
Committed: https://git.openstack.org/cgit/openstack/python-novaclient/commit/?id=98934d7bf1464afe0f7fe98efd2a591d95ac9c41
Submitter: Jenkins
Branch: master

commit 98934d7bf1464afe0f7fe98efd2a591d95ac9c41
Author: Boris Pavlovic <email address hidden>
Date: Wed Mar 26 15:22:03 2014 +0400

    Fix session handling in novaclient

    Prior to this patch, novaclient was handling sessions in an inconsistent
    manner.

    Every time we created a client instance, it would use a global
    connection pool, which made it difficult to use in a process that is
    meant to be forked.

    Obviously sessions like the ones provided by the requests library that
    will automatically cause connections to be kept alive should not be
    implicit. This patch moves the novaclient back to the age of a single
    session-less request call by default, but also adds two more
    resource-reuse friendly options that a user needs to be explicit about.

    The first one is that both v1_1 and v3 clients can now be used as
    context managers,. where the session will be kept open (and thus the
    connection kept-alive) for the duration of the with block. This is far
    more ideal for a web worker use-case as the session can be made
    request-long.

    The second one is the per-instance session. This is very similar to what
    we had up until now, except it is not a global object so forking is
    possible as long as each child instantiates it's own client. The session
    once created will be kept open for the duration of the client object
    lifetime.

    Please note: client instances are not thread safe. As can be seen from
    above forking example - if you wish to use threading/multiprocessing,
    you *must not* share client instances.

    DocImpact

    Related-bug: #1247056
    Closes-Bug: #1297796
    Co-authored-by: Nikola Dipanov <email address hidden>
    Change-Id: Id59e48f61bb3f3c6223302355c849e1e99673410

Changed in python-novaclient:
status: Confirmed → Fix Committed
Michael Still (mikal)
Changed in python-novaclient:
milestone: none → 2.18.0
Michael Still (mikal)
Changed in python-novaclient:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.