[Openstack] [TaskFlow] Is there any way to retrieve the `flow_uuid` in the `Task`?

Joshua Harlow harlowja at yahoo-inc.com
Fri May 23 20:29:52 UTC 2014


I think this is ok for now, u might have to do some tweaks in the new
release.

There is an active review @ https://review.openstack.org/#/c/95029/ that I
think will also be useful for u :-)

Feel free to check it out (and comment if u want).

-----Original Message-----
From: Timon Wong <timon86.wang at gmail.com>
Date: Thursday, May 22, 2014 at 9:42 PM
To: Joshua Harlow <harlowja at yahoo-inc.com>
Cc: "openstack at lists.openstack.org" <openstack at lists.openstack.org>
Subject: Re: [Openstack] [TaskFlow] Is there any way to retrieve the
`flow_uuid` in the `Task`?

>Thanks Josh, looking forward the v0.3 release :)
>
>So for now I should pass the flow_id to the task constructor instead,
>in case of distributed manner (or maybe resume from database?).
>
>On Fri, May 23, 2014 at 1:09 AM, Joshua Harlow <harlowja at yahoo-inc.com>
>wrote:
>> Hi Timon,
>>
>> A good question :)
>>
>> In general tasks aren't very aware of the flow they are running in,
>>mainly
>> on purpose since flows are really just a 'container' of tasks that
>>impose
>> constraints on how the tasks inside it run (for example a linear_flow
>>as u
>> are using imposes a linearity constraint on the tasks contained inside
>>it).
>>
>> If its still needed there are a few ways to do this. U have found one of
>> them, passing it in via the task constructor method. This I think is
>>fine
>> if u are ok with not running those tasks later in a remote/distributed
>> manner (since the logger resource object can't be sent across remote
>> channels).
>>
>> Another way to do this is to use the transient feature of the engines
>> storage that should be released in 0.3 (this will come out soon)[1].
>>This
>> would allow your task to have the following function definition and have
>> it not have to be passed in via the task constructor (instead the logger
>> argument will become a execution time dependency that will be grabbed
>>from
>> the storage interface).
>>
>> def execute(self, a, b, c, logger):
>>   logger.log(...)
>>
>> A third method is to use the listener interface and use that instead
>> (although this will be a less granular logging approach). There are some
>> examples and usage details @
>> 
>>http://docs.openstack.org/developer/taskflow/notifications.html#printing-
>>an
>> d-logging-listeners that might be useful for u. Combining this listener
>> approach with a tasks ability to update its own status/progress[2] might
>> just do the trick for u.
>>
>> If none of these work for u, feel free to jump on
>> #openstack-state-management and we can think of other ways to do this :)
>>
>> -Josh
>>
>> [1]
>> 
>>https://github.com/openstack/taskflow/blob/master/taskflow/storage.py#L41
>>3
>> [2] 
>>https://github.com/openstack/taskflow/blob/master/taskflow/task.py#L78
>>
>> -----Original Message-----
>> From: Timon Wong <timon86.wang at gmail.com>
>> Date: Wednesday, May 21, 2014 at 11:17 PM
>> To: "openstack at lists.openstack.org" <openstack at lists.openstack.org>
>> Subject: [Openstack] [TaskFlow] Is there any way to retrieve the
>> `flow_uuid` in the `Task`?
>>
>>>For logging purpose, I wanna log the `flow_uuid` as a context to
>>>indicate which flow the logging message related to.
>>>
>>>Currently, I just created a logging adapter, grab the `uuid` from the
>>>`flow_details`, the pass them as a constructor param like this:
>>>
>>>flow = linear_flow.Flow(flow_name)
>>>flow_detail = p_utils.create_flow_detail(flow)
>>>logger = create_logger_adpater(flow_detail.uuid)
>>>flow.add(XXXTask(logger), YYYTask(logger),ZZZTask(logger))
>>>
>>>
>>>Is there any better way to do that?
>>>
>>>Thanks in advance!
>>>
>>>Regards,
>>>Timon Wong
>>>
>>>_______________________________________________
>>>Mailing list:
>>>http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack
>>>Post to     : openstack at lists.openstack.org
>>>Unsubscribe :
>>>http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack
>>





More information about the Openstack mailing list