英文:
Is there a way to make argo events sensor to run triggers sequentially after completion
问题
根据我的测试,传感器触发器是一个接一个地调用的,而不会等待响应。有没有办法让传感器触发器等待一个触发器完成后再调用下一个触发器?
示例传感器:
apiVersion: argoproj.io/v1alpha1
kind: Sensor
metadata:
name: create-resource
spec:
template:
serviceAccountName: argo-events-controller-manager
dependencies:
- name: event
eventSourceName: kafka
eventName: create-resource
triggers:
- template:
name: create-user-if-not-exists
http:
url: "https://reqres.in/api/users?delay=20"
method: POST
retryStrategy:
steps: 3
duration: 3s
policy:
status:
allow:
- 200
- template:
name: delete-resource-if-exists
http:
url: "https://reqres.in/api/users?delay=10"
method: DELETE
retryStrategy:
steps: 3
duration: 3s
policy:
status:
allow:
- 204
- template:
name: create-resource
http:
url: "https://reqres.in/api/users?delay=3"
method: POST
payload:
- src:
dependencyName: event
dataKey: body
useRawData: true
dest: event
retryStrategy:
steps: 3
duration: 3s
policy:
status:
allow:
- 201
- 202
- 以上示例使用一个模拟响应延迟的实时测试REST API。因此,可以轻松复制这种情况。
- 我们触发了3个REST API调用。
- 如果 create-user-if-not-exists 成功,那么 delete-resource-if-exists。
- 如果 delete-resource-if-exists 成功,那么 create-resource。
- 如果第一个调用失败,触发器应该停止,并且不运行其他触发器。
当前行为:
- 所有触发器一个接一个地触发,而不等待响应。
- 如果第一个触发器失败,仍然会触发其他触发器。没有控制以停止其他触发器或使它们等待前一个触发器的完成。
有没有办法强制执行触发器的执行顺序,使触发器等待(依赖于)其他触发器?
从 argo-events 调用 argo-workflow 或其他工作流系统仅用于满足这种需求会感觉很繁重。
英文:
Based on my testing, sensor triggers are invoked one by one without waiting for the response. Is there a way to make sensor triggers to wait for one trigger to complete before invoking the next trigger ?
Example sensor:
apiVersion: argoproj.io/v1alpha1
kind: Sensor
metadata:
name: create-resource
spec:
template:
serviceAccountName: argo-events-controller-manager
dependencies:
- name: event
eventSourceName: kafka
eventName: create-resource
triggers:
- template:
name: create-user-if-not-exists
http:
url: "https://reqres.in/api/users?delay=20"
method: POST
retryStrategy:
steps: 3
duration: 3s
policy:
status:
allow:
- 200
- template:
name: delete-resource-if-exists
http:
url: "https://reqres.in/api/users?delay=10"
method: DELETE
retryStrategy:
steps: 3
duration: 3s
policy:
status:
allow:
- 204
- template:
name: create-resource
http:
url: "https://reqres.in/api/users?delay=3"
method: POST
payload:
- src:
dependencyName: event
dataKey: body
useRawData: true
dest: event
retryStrategy:
steps: 3
duration: 3s
policy:
status:
allow:
- 201
- 202
- The above example uses a live testing REST API which mimics a delay in response. So it should be easy to replicate this scenario.
- We trigger 3 REST API calls.
- create-user-if-not-exists - this takes 20 seconds
- delete-resource-if-exists - this takes 10 seconds
- create-resource - this takes 3 seconds
Expectation :
- after create-user-if-not-exists succeeds, delete-resource-if-exists.
- after delete-resource-if-exists succeeds, create-resource
- If first call fails, the trigger should stop and not run other triggers.
Current behaviour:
- All triggers are fired one after other without waiting for response
- if first trigger fails, still other triggers gets fired. There is no control to stop other triggers or make them wait for the completion of previous trigger.
Is there any way to enforce the order in which triggers gets executed and make the triggers wait (depend on) other trigger ?
Calling argo-workflow or other workflow systems from argo-events just for satisfying this need feels heavy.
答案1
得分: 1
为了这种行为,你应该使用工作流程按顺序触发它。运行传感器,然后运行一个包含你所需步骤的工作流程,并在每个步骤中控制响应。
英文:
for this kind of behaviours you should use a workflow to trigger this in sequence. run the sensor and then run a workflow with the steps that you need. and control the response in each
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论