[openstack-dev] [nova] Looking at _sync_instance_power_state makes me want to gouge my eyes out

Matt Riedemann mriedem at linux.vnet.ibm.com
Mon Jul 27 17:27:47 UTC 2015

garyk has a change up [1] which proposes to add a config option to log a 
warning rather than call the stop API when nova thinks that an instance 
is in an inconsistent state between the database and hypervisor and 
decides to stop it.

Regardless of that proposal, it brings up the fact that this code is a 
big pile of spaghetti and I kind of hate it. :)

It's called from the periodic task and the virt driver lifecycle event 
callback (implemented by libvirt and hyperv).

I was thinking it'd be nice to abstract some of that state -> action 
logic into objects.  Like you create a factory which given some state 
value(s) yields an action, which could be logging/calling stop API, etc, 
but the point is that logic is abstracted away from 
_sync_instance_power_state so we don't have that giant mess of conditionals.

I don't really have a clear picture in my head for this, but wanted to 
dump it in the mailing list for something to think about if people want 
something to work on.

[1] https://review.openstack.org/#/c/190047/



Matt Riedemann

More information about the OpenStack-dev mailing list