[Engine-devel] Asynchronous tasks for live merge
Adam Litke
alitke at redhat.com
Mon Mar 3 14:51:15 UTC 2014
On 03/03/14 14:28 +0000, Dan Kenigsberg wrote:
>On Fri, Feb 28, 2014 at 09:30:16AM -0500, Adam Litke wrote:
>> Hi all,
>>
>> As part of our plan to support live merging of VM disk snapshots it
>> seems we will need a new form of asynchronous task in ovirt-engine. I
>> am aware of AsyncTaskManager but it seems to be limited to managing
>> SPM tasks. For live merge, we are going to need something called
>> VmTasks since the async command can be run only on the host that
>> currently runs the VM.
>>
>> The way I see this working from an engine perspective is:
>> 1. RemoveSnapshotCommand in bll is invoked as usual but since the VM is
>> found to be up, we activate an alternative live merge flow.
>> 2. We submit a LiveMerge VDS Command for each impacted disk. This is
>> an asynchronous command which we need to monitor for completion.
>> 3. A VmJob is inserted into the DB so we'll remember to handle it.
>> 4. The VDS Broker monitors the operation via an extension to the
>> already collected VmStatistics data. Vdsm will report active Block
>> Jobs only. Once the job stops (in error or success) it will cease
>> to be reported by vdsm and engine will know to proceed.
>
>You describe a reasonable way for Vdsm to report whether an async
>operation has finished. However, may we instead use the oportunity to
>introduce generic "hsm" tasks?
Sure, I am happy to have that conversation :) If I understand
correctly, HSM tasks, while ideal, might be too complex to get right
and would block the Live Merge feature for longer than we would like.
Has anyone looked into what it would take to implement a HSM Tasks
framework like this in vdsm? Are there any WIP implementations? If
the scope of this is not too big, it can be completed relatively
quickly, and the resulting implementation would cover all known use
cases, then this could be worth it. It's important to support Live
Merge soon.
Regarding deprecation of the current tasks API: Could your suggested
HSM Tasks framework be extended to cover SPM/SDM tasks as well? I
would hope that a it could. In that case, we could look forward to a
unified async task architecture in vdsm.
>I suggest to have something loosely modeled on posix fork/wait.
>
>- Engine asks Vdsm to start an API verb asynchronously and supplies a
> uuid. This is unlike fork(2), where the system chooses the pid, but
> that's required so that Engine could tell if the command has reached
> Vdsm in case of a network error.
>
>- Engine may monitor the task (a-la wait(WNOHANG))
Allon has communicated a desire to limit engine-side polling. Perhaps
the active tasks could be added to the host stats?
>- When the task is finished, Engine may collect its result (a-la wait).
> Until that happens, Vdsm must report the task forever; restart or
> upgrade are no excuses. On reboot, though, all tasks are forgotten, so
> Engine may stop monitoring tasks on a fenced host.
This could be a good comprimise. I hate the idea of requiring engine
to play janitor and clean up stale vdsm data, but there is not much
better of a way to do it. Allowing reboot to auto-clear tasks will at
least provide some backstop to how long tasks could pile up if
forgotten.
>This may be an over kill for your use case, but it would come useful for
>other cases. In particular, setupNetwork returns before it is completely
>done, since dhcp address acquisition may take too much time. Engine may
>poll getVdsCaps to see when it's done (or timeout), but it would be
>nicer to have a generic mechanism that can serve us all.
If we were to consider this, I would want to vet the architecture
against all known use cases for tasks to make sure we don't need to
create a new framework in 3 months.
>Note that I'm suggesting a completely new task framwork, at least on
>Vdsm side, as the current one (with its broken persistence, arcane
>states and never-reliable rollback) is beyond redemption, imho.
Are we okay with abandoning vdsm-side rollback entirely as we move
forward? Won't that be a regression for at least some error flows
(especially in the realm of SPM tasks)?
>> 5. When the job has completed, VDS Broker raises an event up to bll.
>> Maybe this could be done via VmJobDAO on the stored VmJob?
>> 6. Bll receives the event and issues a series of VDS commands to
>> complete the operation:
>> a) Verify the new image chain matches our expectations (the snap is
>> no longer present in the chain).
>> b) Delete the snapshot volume
>> c) Remove the VmJob from the DB
>>
>> Could you guys review this proposed flow for sanity? The main
>> conceptual gaps I am left with concern #5 and #6. What is the
>> appropriate way for VDSBroker to communicate with BLL? Is there an
>> event mechanism I can explore or should I use the database? I am
>> leaning toward the database because it is persistent and will ensure
>> #6 gets completed even if engine is restarted somewhere in the middle.
>> For #6, is there an existing polling / event loop in bll that I can
>> plug into?
>>
>> Thanks in advance for taking the time to think about this flow and for
>> providing your insights!
--
Adam Litke
More information about the Devel
mailing list