nova-api should shutdown gracefully

Bug #1382390 reported by Tiantian Gao
22
This bug affects 3 people
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Wishlist
Marian Horban
oslo-incubator
Won't Fix
Wishlist
Unassigned
oslo.service
Fix Released
Undecided
Unassigned

Bug Description

In IceHouse, An awesome feature got implemented: graceful shutdown nova service, which can make sure in-process RPC request got done before kill the process.

But nova-api not support graceful shutdown now, which can cause problem when do upgrading. For example, when a request to create an instance was in-progress, kill the nova-api may lead to quota not sync or odd database records. Especially in large-scale development, there are hundreds of request in a second, kill the nova-api will interrupt lots in-process greenlet.

In nova/wsgi.py, when stoping WSGI service, we first shrink the greenlet pool size to 0, then kill the eventlet wsgi server. The work around is quick and easy: wait for all greenlets in the pool to finish, then kill wsgi server. The code looks like below:

diff --git a/nova/wsgi.py b/nova/wsgi.py
index ba52872..3c89297 100644
--- a/nova/wsgi.py
+++ b/nova/wsgi.py
@@ -212,6 +212,9 @@ class Server(object):
         if self._server is not None:
             # Resize pool to stop new requests from being processed
             self._pool.resize(0)
+ num = self._pool.running()
+ LOG.info(_("Waiting WSGI server to finish %d requests." % num))
+ self._pool.waitall()
             self._server.kill()

     def wait(self):

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

Fix proposed to branch: master
Review: https://review.openstack.org/129167

Changed in nova:
assignee: nobody → Tiantian Gao (gtt116)
status: New → In Progress
Yaguang Tang (heut2008)
tags: added: icehouse-backport-potential juno-backport-potential
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on nova (master)

Change abandoned by Sean Dague (<email address hidden>) on branch: master
Review: https://review.openstack.org/129167
Reason: This review is > 4 weeks without comment, and failed Jenkins the last time it was checked. We are abandoning this for now. Feel free to reactivate the review by pressing the restore button and leaving a 'recheck' comment to get fresh test results.

Revision history for this message
Davanum Srinivas (DIMS) (dims-v) wrote :

Removing "In Progress" status and assignee as change is abandoned.

Changed in nova:
assignee: Tiantian Gao (gtt116) → nobody
status: In Progress → Confirmed
Joe Gordon (jogo)
tags: added: quotas
Changed in nova:
importance: Undecided → Wishlist
Revision history for this message
Davanum Srinivas (DIMS) (dims-v) wrote :

We should be adding support for this in oslo.service

Changed in oslo-incubator:
status: New → Confirmed
importance: Undecided → Wishlist
Changed in nova:
assignee: nobody → Davanum Srinivas (DIMS) (dims-v)
status: Confirmed → In Progress
Revision history for this message
Joe Gordon (jogo) wrote :

nova-compute already does something like this, I just don't think nova-api does yet.

Changed in nova:
assignee: Davanum Srinivas (DIMS) (dims-v) → Marian Horban (mhorban)
Revision history for this message
Marian Horban (mhorban) wrote :
Revision history for this message
Marian Horban (mhorban) wrote :

One more test for graceful shutdown. Can be used with any of openstack services.
Usage:
python graceful_shutdown.py openstack-service api-port

For example
python graceful_shutdown.py 'neutron-server' 9696

Must be run on the same host with service's proces.

Revision history for this message
Mitsuhiro Tanino (mitsuhiro-tanino) wrote :

Fix proposed to oslo.service : master
https://review.openstack.org/#/c/190175/

Changed in oslo.service:
status: New → Confirmed
Revision history for this message
Mitsuhiro Tanino (mitsuhiro-tanino) wrote :

I made my bug report for duplicate of this bug.

https://bugs.launchpad.net/oslo.service/+bug/1463132

Revision history for this message
Elena Ezhova (eezhova) wrote :

Related fix for oslo.service: https://review.openstack.org/#/c/190175/

Changed in oslo.service:
status: Confirmed → Fix Released
Changed in nova:
status: In Progress → Fix Committed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Change abandoned by Michael Still (<email address hidden>) on branch: master
Review: https://review.openstack.org/129167
Reason: This patch as been stalled for a very long time, so I am going to abandon it to keep the review queue sane. Please restore the change when its ready for review.

Thierry Carrez (ttx)
Changed in nova:
milestone: none → liberty-3
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: liberty-3 → 12.0.0
Changed in oslo-incubator:
status: Confirmed → Won't Fix
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.