SlideShare a Scribd company logo
Openstack taskflow 
果凍
簡介 
● 任職於迎廣科技 
○ python 
○ openstack 
● c++, java, scala 
● http://about.me/ya790206 
● http://blog.blackwhite. 
tw/ 
● https://github. 
com/ya790206/call_seq
聯絡資料 
● 個人信箱: http://www.blackwhite. 
tw/#/contact 
● 公司信箱:jam.kao at in-win.com.tw
關注 openstack 以下技術 
● cinder 
● glance 
● ceilometer 
● horizon 
● log 
● monitor and alert
What is it? 
● TaskFlow is a Python library for OpenStack 
(and other projects) that helps make task 
execution easy, consistent, scalable and 
reliable.
What it help us to do? 
1. Retry 
2. Revert 
3. Each independent task (or independent 
subgraph) in the graph could be ran in 
parallel when its dependencies have been 
satisfied. 
4. Concurrent / Parallel
前情提要 
A 要找 B 和 C 去餐廳 X 進行祕密會談。只要有人 
無法到場,則取消該次會談 
1. 聯絡 A 和 B 
2. 聯絡 X(餐廳)
def call(name, phone, msg): 
if phone in ['123']: 
print 'name: %s, phone: %s, msg: %s, status: failed' % (name, phone, 
msg) 
return False 
print 'name: %s, phone: %s, msg: %s, status: success' % (name, phone, msg) 
return True
call('B', '123', 'invite B') 
call('C', '124', 'invite C') 
call('X', '124', 'make a reservation in X')
def try_call(name, phone_list, msg): 
ret = False 
for phone in phone_list: 
ret = call(name, phone, msg) 
if ret: 
break 
return ret
try_call('B', ['123'], 'invite B') 
try_call('C', ['124', '126'], 'invite C') 
try_call('X', ['224'], 'make a reservation in X')
try: 
revert_list = [] 
successed = try_call('B', ['123'], 'invite B') 
if not successed: 
raise Exception() 
revert_list.append(lambda: try_call('B', ['123'], 'cancel B')) 
successed = try_call('C', ['124', '126'], 'invite C') 
if not successed: 
raise Exception() 
revert_list.append(lambda: try_call('B', ['123'], 'cancel B')) 
successed = try_call('X', ['224'], 'make a reservation in X') 
if not successed: 
raise Exception() 
revert_list.append(lambda: try_call('B', ['123'], 'cancel B')) 
except: 
for action in revert_list: 
action()
Q: Do we have a better way? 
A: Yes, we have openstack taskflow
Tasks 
A task (derived from an atom) is the smallest 
possible unit of work that can have a execute 
& rollback sequence associated with it.
Flows 
A flow is a structure that links one or more 
tasks together in an ordered sequence 
pattern. When a flow rolls back, it executes 
the rollback code for each of it's child tasks 
using whatever reverting mechanism the task 
has defined as applicable to reverting the 
logic it applied.
Patterns 
1. Linear 
2. Unordered 
3. Graph
Engine 
1. Engines are what really runs your atoms 
(tasks, flows). 
2. Engines decide which atom to run and 
when. 
3. Engine type: 
a. serial(default) 
b. parallel 
c. worker-based
store 
(dict) 
get 
dependence 
provides 
Task 
get 
dependence 
provides 
Task
Openstack taskflow 簡介
provides: Any outputs this task produces.
empty store 
(dict) 
After executing 
Provider task Dmsg 
-> 
XXX 
Dphone_l 
ist -> 
[XXX, 
YYY] 
Dnam 
e -> 
ZZZ
Task 
dependence
rebind: An immutable input resource mapping 
dictionary that can be used to alter the inputs 
given to this task. 
provides: Any outputs this task produces.
Dphone_l 
ist -> 
[XXX, 
Dmsg 
-> 
XXX 
Dnam YYY] 
e -> 
ZZZ 
get 
dependence 
from store for 
CallTask 
(Dname, 
Dphone, 
Dmsg) 
Run 
CallTask 
Provide 
`Ddone` 
Dphone_l 
ist -> 
[XXX, 
YYY] 
Dmsg 
-> 
XXX 
Dnam 
e -> 
ZZZ 
Ddone 
-> 
True 
Provide -> CallStack 
Q: Why it is Dname istead of name 
A: because of rebind 
Q: where is the 
Dphone?
Openstack taskflow 簡介
flow 
provide_flow call_flow
Openstack taskflow 簡介
revert rules: 
● 每次 task 執行失敗,則會 revert 。 
● 只要 flow 中有個 task 執行失敗且無法 
retry,則已經執行過的 task 則會 revert。
Demo 
https://gist.github. 
com/ya790206/14229922355077713 
ad9 
http://goo.gl/gyd3K6
Another example 
x2 = y3+y4 
x1 = y1+y2 
x5 = x1+x3 
x3 = x1+x2 
x4 = x2+y5 
x6 = x5+x4 
x7 = x6+x6 
x7 
x6 
x5 x4 
x4 
x2 y5 
y3 y4 
x1 
y1 y2 
x3 
x1 x2
Graph pattern 
A tasks dependents are guaranteed to be 
satisfied before the task will run. Each 
independent task (or independent subgraph) in 
the graph could be ran in parallel when its 
dependencies have been satisfied.
Code 
https://github. 
com/openstack/taskflow/blob/master/taskflo 
w/examples/graph_flow.py
Why Openstack need taskflow? 
OpenStack code has grown organically, and 
does not have a standard and consistent way 
to perform sequences of code in a way that 
can be safely resumed or rolled back if the 
calling process is unexpectedly terminated 
while the code is busy doing something
Results 
With widespread use of TaskFlow, OpenStack 
can become very predictable and reliable, 
even in situations where it's not deployed in 
high availability configurations.
Summary 
TaskFlow is a Python library for OpenStack 
(and other projects) that helps make task 
execution easy, consistent, scalable and 
reliable.
迎廣雲端研發中心介紹 
● 提供 openstack 相關服務 
○ 教育訓練 
○ 客製化 
○ 佈署
徵才 
● web 前端工程師(angularjs, html5, css) 
● web 後端工程師(python) 
● 熟悉 linux 網路與 SDN 
● 熟悉 linux 分散式儲存與 SDS
Reference 
https://wiki.openstack.org/wiki/TaskFlow
建議學習順序 
1. simple_linear.py 
2. calculate_linear.py 
3. reverting_linear.py 
4. retry_flow.py 
5. graph_flow.py 
6. simple_linear_listening.py 
7. calculate_in_parallel.py 
8. pseudo_scoping.py

More Related Content

PDF
Openstack 簡介
PPTX
All you need to know about the JavaScript event loop
PDF
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
PDF
PyCon KR 2019 sprint - RustPython by example
PDF
How to Write Node.js Module
PPTX
Mysql handle socket
PPTX
Mysql5.1 character set testing
PPTX
Compare mysql5.1.50 mysql5.5.8
Openstack 簡介
All you need to know about the JavaScript event loop
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
PyCon KR 2019 sprint - RustPython by example
How to Write Node.js Module
Mysql handle socket
Mysql5.1 character set testing
Compare mysql5.1.50 mysql5.5.8

What's hot (20)

PPTX
JavaScript Engines and Event Loop
PDF
Доклад Антона Поварова "Go in Badoo" с Golang Meetup
PDF
Nodejs - Should Ruby Developers Care?
PDF
Elasticsearch (R)Evolution — You Know, for Search… by Philipp Krenn at Big Da...
PDF
RestMQ - HTTP/Redis based Message Queue
PPT
Full-Stack JavaScript with Node.js
PDF
Event loop
PDF
[232] TensorRT를 활용한 딥러닝 Inference 최적화
PDF
[232]TensorRT를 활용한 딥러닝 Inference 최적화
PDF
Redis as a message queue
KEY
Node.js - As a networking tool
PDF
Nodejs - A quick tour (v6)
PDF
Wprowadzenie do technologi Big Data i Apache Hadoop
PDF
Будь первым
PDF
Nodejs - A quick tour (v4)
PDF
Nodejs - A-quick-tour-v3
PDF
[214] Ai Serving Platform: 하루 수 억 건의 인퍼런스를 처리하기 위한 고군분투기
PDF
Raymond Kuiper - Working the API like a Unix Pro
PDF
Nodejs - A quick tour (v5)
PDF
Nodejs a-practical-introduction-oredev
JavaScript Engines and Event Loop
Доклад Антона Поварова "Go in Badoo" с Golang Meetup
Nodejs - Should Ruby Developers Care?
Elasticsearch (R)Evolution — You Know, for Search… by Philipp Krenn at Big Da...
RestMQ - HTTP/Redis based Message Queue
Full-Stack JavaScript with Node.js
Event loop
[232] TensorRT를 활용한 딥러닝 Inference 최적화
[232]TensorRT를 활용한 딥러닝 Inference 최적화
Redis as a message queue
Node.js - As a networking tool
Nodejs - A quick tour (v6)
Wprowadzenie do technologi Big Data i Apache Hadoop
Будь первым
Nodejs - A quick tour (v4)
Nodejs - A-quick-tour-v3
[214] Ai Serving Platform: 하루 수 억 건의 인퍼런스를 처리하기 위한 고군분투기
Raymond Kuiper - Working the API like a Unix Pro
Nodejs - A quick tour (v5)
Nodejs a-practical-introduction-oredev
Ad

Viewers also liked (20)

PDF
Task flow
PDF
Introductionof taskflow
PPT
Taskflow
PPTX
ServerlessPresentation
PDF
Combining OpenWhisk (serverless), Open API (swagger) and API Connect to build...
PDF
The Serverless Paradigm, OpenWhisk and FIWARE
PDF
OpenWhisk Under the Hood -- London Oct 16 2016
PDF
Apache kafka big data track
PDF
[AWSKRUG&JAWS-UG Meetup #1] Serverless Real-Time Analysis
PPTX
Architecture of a Kafka camus infrastructure
PDF
Open stack ocata summit enabling aws lambda-like functionality with openstac...
PDF
How to build an event-driven, polyglot serverless microservices framework on ...
PDF
BEEVA | Introducción a Docker
PDF
AWS Lambda from the Trenches
PDF
Building Serverless APIs on AWS
PDF
Build reactive systems on lambda
PDF
JustGiving – Serverless Data Pipelines, API, Messaging and Stream Processing
PDF
Building Serverless APIs (January 2017)
PDF
How to implement chatbots for Alexa and Facebook Messenger
PPTX
IBM Bluemix OpenWhisk: Cloud Foundry Summit 2016, Frankfurt, Germany: The Fut...
Task flow
Introductionof taskflow
Taskflow
ServerlessPresentation
Combining OpenWhisk (serverless), Open API (swagger) and API Connect to build...
The Serverless Paradigm, OpenWhisk and FIWARE
OpenWhisk Under the Hood -- London Oct 16 2016
Apache kafka big data track
[AWSKRUG&JAWS-UG Meetup #1] Serverless Real-Time Analysis
Architecture of a Kafka camus infrastructure
Open stack ocata summit enabling aws lambda-like functionality with openstac...
How to build an event-driven, polyglot serverless microservices framework on ...
BEEVA | Introducción a Docker
AWS Lambda from the Trenches
Building Serverless APIs on AWS
Build reactive systems on lambda
JustGiving – Serverless Data Pipelines, API, Messaging and Stream Processing
Building Serverless APIs (January 2017)
How to implement chatbots for Alexa and Facebook Messenger
IBM Bluemix OpenWhisk: Cloud Foundry Summit 2016, Frankfurt, Germany: The Fut...
Ad

Similar to Openstack taskflow 簡介 (20)

PDF
Node.js flow control
PDF
Easy Cloud Native Transformation using HashiCorp Nomad
PDF
PDF
PostgreSQL 9.6 새 기능 소개
PDF
Douglas Crockford: Serversideness
PDF
Monitoring Kafka w/ Prometheus
PDF
D Trace Support In My Sql Guide To Solving Reallife Performance Problems
PPTX
Clojure And Swing
PDF
Troubleshooting tips from docker support engineers
PDF
TypeScript for Java Developers
PDF
Celery with python
PDF
Deep Learning for Computer Vision: Software Frameworks (UPC 2016)
PDF
Streams Don't Fail Me Now - Robustness Features in Kafka Streams
PPT
Threaded Programming
PDF
Fun Teaching MongoDB New Tricks
PPT
Cpp tutorial
PDF
Groovy.pptx
PDF
Refactoring to Macros with Clojure
PPT
CppTutorial.ppt
PDF
Clojure 1.1 And Beyond
Node.js flow control
Easy Cloud Native Transformation using HashiCorp Nomad
PostgreSQL 9.6 새 기능 소개
Douglas Crockford: Serversideness
Monitoring Kafka w/ Prometheus
D Trace Support In My Sql Guide To Solving Reallife Performance Problems
Clojure And Swing
Troubleshooting tips from docker support engineers
TypeScript for Java Developers
Celery with python
Deep Learning for Computer Vision: Software Frameworks (UPC 2016)
Streams Don't Fail Me Now - Robustness Features in Kafka Streams
Threaded Programming
Fun Teaching MongoDB New Tricks
Cpp tutorial
Groovy.pptx
Refactoring to Macros with Clojure
CppTutorial.ppt
Clojure 1.1 And Beyond

More from kao kuo-tung (15)

PDF
用 Open source 改造鍵盤
PPTX
Immutable infrastructure 介紹與實做:以 kolla 為例
PDF
Python to scala
PDF
Intorduce to Ceph
PDF
Openstack swift, how does it work?
PDF
Why is a[1] fast than a.get(1)
PPTX
減少重複的測試程式碼的一些方法
PDF
Async: ways to store state
PDF
Docker 原理與實作
PDF
那些年,我們一起看的例外
PDF
Python 中 += 與 join比較
PDF
Garbage collection 介紹
PDF
Python 如何執行
PDF
C python 原始碼解析 投影片
PDF
recover_pdb 原理與介紹
用 Open source 改造鍵盤
Immutable infrastructure 介紹與實做:以 kolla 為例
Python to scala
Intorduce to Ceph
Openstack swift, how does it work?
Why is a[1] fast than a.get(1)
減少重複的測試程式碼的一些方法
Async: ways to store state
Docker 原理與實作
那些年,我們一起看的例外
Python 中 += 與 join比較
Garbage collection 介紹
Python 如何執行
C python 原始碼解析 投影片
recover_pdb 原理與介紹

Recently uploaded (20)

PDF
Mushroom cultivation and it's methods.pdf
PDF
Heart disease approach using modified random forest and particle swarm optimi...
PDF
Getting Started with Data Integration: FME Form 101
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Web App vs Mobile App What Should You Build First.pdf
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PDF
Encapsulation theory and applications.pdf
PDF
Approach and Philosophy of On baking technology
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
August Patch Tuesday
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
DP Operators-handbook-extract for the Mautical Institute
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
A novel scalable deep ensemble learning framework for big data classification...
PPTX
Tartificialntelligence_presentation.pptx
PDF
Hindi spoken digit analysis for native and non-native speakers
PPTX
TLE Review Electricity (Electricity).pptx
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PDF
1 - Historical Antecedents, Social Consideration.pdf
Mushroom cultivation and it's methods.pdf
Heart disease approach using modified random forest and particle swarm optimi...
Getting Started with Data Integration: FME Form 101
Encapsulation_ Review paper, used for researhc scholars
Web App vs Mobile App What Should You Build First.pdf
Accuracy of neural networks in brain wave diagnosis of schizophrenia
Encapsulation theory and applications.pdf
Approach and Philosophy of On baking technology
Programs and apps: productivity, graphics, security and other tools
August Patch Tuesday
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
DP Operators-handbook-extract for the Mautical Institute
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
A novel scalable deep ensemble learning framework for big data classification...
Tartificialntelligence_presentation.pptx
Hindi spoken digit analysis for native and non-native speakers
TLE Review Electricity (Electricity).pptx
Digital-Transformation-Roadmap-for-Companies.pptx
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
1 - Historical Antecedents, Social Consideration.pdf

Openstack taskflow 簡介

  • 2. 簡介 ● 任職於迎廣科技 ○ python ○ openstack ● c++, java, scala ● http://about.me/ya790206 ● http://blog.blackwhite. tw/ ● https://github. com/ya790206/call_seq
  • 3. 聯絡資料 ● 個人信箱: http://www.blackwhite. tw/#/contact ● 公司信箱:jam.kao at in-win.com.tw
  • 4. 關注 openstack 以下技術 ● cinder ● glance ● ceilometer ● horizon ● log ● monitor and alert
  • 5. What is it? ● TaskFlow is a Python library for OpenStack (and other projects) that helps make task execution easy, consistent, scalable and reliable.
  • 6. What it help us to do? 1. Retry 2. Revert 3. Each independent task (or independent subgraph) in the graph could be ran in parallel when its dependencies have been satisfied. 4. Concurrent / Parallel
  • 7. 前情提要 A 要找 B 和 C 去餐廳 X 進行祕密會談。只要有人 無法到場,則取消該次會談 1. 聯絡 A 和 B 2. 聯絡 X(餐廳)
  • 8. def call(name, phone, msg): if phone in ['123']: print 'name: %s, phone: %s, msg: %s, status: failed' % (name, phone, msg) return False print 'name: %s, phone: %s, msg: %s, status: success' % (name, phone, msg) return True
  • 9. call('B', '123', 'invite B') call('C', '124', 'invite C') call('X', '124', 'make a reservation in X')
  • 10. def try_call(name, phone_list, msg): ret = False for phone in phone_list: ret = call(name, phone, msg) if ret: break return ret
  • 11. try_call('B', ['123'], 'invite B') try_call('C', ['124', '126'], 'invite C') try_call('X', ['224'], 'make a reservation in X')
  • 12. try: revert_list = [] successed = try_call('B', ['123'], 'invite B') if not successed: raise Exception() revert_list.append(lambda: try_call('B', ['123'], 'cancel B')) successed = try_call('C', ['124', '126'], 'invite C') if not successed: raise Exception() revert_list.append(lambda: try_call('B', ['123'], 'cancel B')) successed = try_call('X', ['224'], 'make a reservation in X') if not successed: raise Exception() revert_list.append(lambda: try_call('B', ['123'], 'cancel B')) except: for action in revert_list: action()
  • 13. Q: Do we have a better way? A: Yes, we have openstack taskflow
  • 14. Tasks A task (derived from an atom) is the smallest possible unit of work that can have a execute & rollback sequence associated with it.
  • 15. Flows A flow is a structure that links one or more tasks together in an ordered sequence pattern. When a flow rolls back, it executes the rollback code for each of it's child tasks using whatever reverting mechanism the task has defined as applicable to reverting the logic it applied.
  • 16. Patterns 1. Linear 2. Unordered 3. Graph
  • 17. Engine 1. Engines are what really runs your atoms (tasks, flows). 2. Engines decide which atom to run and when. 3. Engine type: a. serial(default) b. parallel c. worker-based
  • 18. store (dict) get dependence provides Task get dependence provides Task
  • 20. provides: Any outputs this task produces.
  • 21. empty store (dict) After executing Provider task Dmsg -> XXX Dphone_l ist -> [XXX, YYY] Dnam e -> ZZZ
  • 23. rebind: An immutable input resource mapping dictionary that can be used to alter the inputs given to this task. provides: Any outputs this task produces.
  • 24. Dphone_l ist -> [XXX, Dmsg -> XXX Dnam YYY] e -> ZZZ get dependence from store for CallTask (Dname, Dphone, Dmsg) Run CallTask Provide `Ddone` Dphone_l ist -> [XXX, YYY] Dmsg -> XXX Dnam e -> ZZZ Ddone -> True Provide -> CallStack Q: Why it is Dname istead of name A: because of rebind Q: where is the Dphone?
  • 28. revert rules: ● 每次 task 執行失敗,則會 revert 。 ● 只要 flow 中有個 task 執行失敗且無法 retry,則已經執行過的 task 則會 revert。
  • 30. Another example x2 = y3+y4 x1 = y1+y2 x5 = x1+x3 x3 = x1+x2 x4 = x2+y5 x6 = x5+x4 x7 = x6+x6 x7 x6 x5 x4 x4 x2 y5 y3 y4 x1 y1 y2 x3 x1 x2
  • 31. Graph pattern A tasks dependents are guaranteed to be satisfied before the task will run. Each independent task (or independent subgraph) in the graph could be ran in parallel when its dependencies have been satisfied.
  • 33. Why Openstack need taskflow? OpenStack code has grown organically, and does not have a standard and consistent way to perform sequences of code in a way that can be safely resumed or rolled back if the calling process is unexpectedly terminated while the code is busy doing something
  • 34. Results With widespread use of TaskFlow, OpenStack can become very predictable and reliable, even in situations where it's not deployed in high availability configurations.
  • 35. Summary TaskFlow is a Python library for OpenStack (and other projects) that helps make task execution easy, consistent, scalable and reliable.
  • 36. 迎廣雲端研發中心介紹 ● 提供 openstack 相關服務 ○ 教育訓練 ○ 客製化 ○ 佈署
  • 37. 徵才 ● web 前端工程師(angularjs, html5, css) ● web 後端工程師(python) ● 熟悉 linux 網路與 SDN ● 熟悉 linux 分散式儲存與 SDS
  • 39. 建議學習順序 1. simple_linear.py 2. calculate_linear.py 3. reverting_linear.py 4. retry_flow.py 5. graph_flow.py 6. simple_linear_listening.py 7. calculate_in_parallel.py 8. pseudo_scoping.py