Comment 4 for bug 1259910

Revision history for this message
Lucas Alvares Gomes (lucasagomes) wrote :

1. "only one "state change task" is allowed to run at the same time per node" Isn't it something that "shared=False" currently does? And what do you think about other tasks, f.e. do_node_deploy discussed recently. Do we need to similar singletone task for this one?

R: It's more about the API perspective, yes internally "shared=False" does it, but it's not clear for the user looking at the API. In this case we have /v1/nodes/<uuid>/states/power working like as a factory, so users might think that by POSTing multiple times will create multiple tasks, but for things like changing the power state it's not possible so we should prevent it and make it clear on the documentation. I see the provision state ( do_node_deploy() ) having the same behaviour.

2. You said that the method that creates the new task resource is synchronous, is it something that already exist, or you're going to implement this in RPC interface?

R: I doesn't, it would be very simple... Throwing one suggestion here:

For the power state, right now we have in our DB two fields related to it: "target_power_state", "power_state". We could add another called "power_state_task", which will save the UUID of the task that is performing the state change, and also will work like a lock/flag to prevent multiple tasks from being created simultaneously.

3. If it's synchronous then I assume it won't do actual job, just register a task, get lock and that's all, am I right? If so, then how we're going to start the job? Will it be some conductor periodic task that picks all tasks registered in db and start them, or will it be another RPC call (async) to start the task?

R: Right the function that handle the POST in our API will call both methods, e.g:

class PowerController:
    def post(...):
        try:
            task_uuid = rpcapi.get_power_lock()
       except Exception:
            raise Exception("Power state in Node A already being running")

        ... check if target is a valid state ...

        rpcapi.change_node_power_state(pecan.request.context, rpc_node, target)

Makes sense?