-
Notifications
You must be signed in to change notification settings - Fork 752
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to add timezone and extra user payload to calendar gateway #164
Ability to add timezone and extra user payload to calendar gateway #164
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
other than one comment, lookds good
|
||
// UserPayload will be sent to sensor as extra data once the event is triggered | ||
// +optional | ||
UserPayload string `json:"userPayload,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason this is a string and not []byte ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most probably user will put JSON string as UserPayload because it is the easiest way to parse it in workflow
i can't find any examples of how to pass this userpayload to the workflow that is triggered by the sensor. |
the example would be -
|
Love it, and is that userPayload set in the gateway? I'm testing a simple POC that involves passing static values to the same workflow for different cron schedules/sensors. Following is what I'm trying to do -
|
That would be in
To pass json as |
That works perfectly thank you. |
If I want to have a 1-1 mapping between cron schedule and sensor, what is the best method? Maybe something like this?
Then in my sensor I have this?
|
Is a completely separate configmap required for each unique interval associated with the calendar gateway? |
Gateway always has a single configmap that contains all the configurations. |
Different workflows, different intervals and schedules. |
ScheduleA - 6pm |
Cool. Check these example out, https://github.com/argoproj/argo-events/blob/master/examples/sensors/webhook-http-boolean.yaml Basically in your case, sensor will have four dependencies Why group dependencies? Because sensor acts as barrier waiting for receive events from one or more gateways. And historically it only supported |
So the sensor would look like ,
|
The sensor spec looks long because all workflows are inlined. You can actually store workflow definitions on git, s3, file, configmap etc and refer them. https://github.com/argoproj/argo-events/blob/master/docs/trigger-guide.md#how-to-define-a-trigger |
Interesting, so this is essentially how you would define multiple sensor triggers in the same sensor reacting on multiple events coming from the gateway, firing different workflows. As an alternative, you could also specify a separate sensor per trigger, each sensor pointing to a separate workflow, correct? I think this approach might make it easier to build out a dynamic workflow generation and deployment wrapper on top of it. |
Also, I recognize there is probably not the right place to ask this question, but is there a way to run specific steps in a workflow, say in a triage situation for a data pipeline where the pipeline is partially processed? |
yes, you can have a separate sensor that handles a single trigger. About the workflow question, I would raise that in |
Hey @VaibhavPage , 👋 What is the recommended way how to parse I would like to pass: apiVersion: v1
kind: ConfigMap
metadata:
name: calendar-gateway-configmap
data:
interval-json: |-
interval: 10s
userPayload: "{\"domian\": \"argo.io\", \"another-param\": \"bar\"}" and then, in workflow insert the apiVersion: argoproj.io/v1alpha1
kind: Sensor
metadata:
name: calendar-sensor
labels:
sensors.argoproj.io/sensor-controller-instanceid: argo-events
spec:
template:
spec:
containers:
- name: "sensor"
image: "argoproj/sensor"
imagePullPolicy: Always
serviceAccountName: argo-events-sa
dependencies:
- name: "calendar-gateway:interval"
eventProtocol:
type: "HTTP"
http:
port: "9300"
triggers:
- template:
name: calendar-workflow-trigger
group: argoproj.io
version: v1alpha1
kind: Workflow
source:
inline: |
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: calendar-workflow-
spec:
entrypoint: whalesay
arguments:
parameters:
- name: message
# this is the value that should be overridden
value: hello world
- name: another-message
value: plz-work
templates:
- name: whalesay
inputs:
parameters:
- name: message
- name: another-message
container:
image: docker/whalesay:latest
command: [cowsay]
args: ["{{inputs.parameters.message}}", "{{inputs.parameters.another-message}}"]
resourceParameters:
- src:
event: "calendar-gateway:interval"
path: userPayload.domian
dest: spec.arguments.parameters.0.value
- src:
event: "calendar-gateway:interval"
path: userPayload.another-param
dest: spec.arguments.parameters.1.value Btw, thanks a lot for your awesome work. I really enjoy learning |
As I would suggest that you pass the The
|
Understood, that's actually what I expected, but still had a small hope that there is some nicer solution for this :-) Thanks for the answer and your amazing work here! |
No description provided.