Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions charts/apps/staging-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ argocd:

events:
enabled: true
targetRevision: HEAD
extraValueFiles:
- staging-values.yaml

Expand Down
6 changes: 6 additions & 0 deletions charts/events/crds/ctt-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ spec:
triggerOnMessageType:
type: string
pattern: "^(start|stop)$"
exitStatusWhitelist:
type: array
default: []
items:
type: string
pattern: "^(success|abort|fail)$"
retryBehaviour:
type: object
properties:
Expand Down
6 changes: 6 additions & 0 deletions charts/events/crds/trigger-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ spec:
triggerOnMessageType:
type: string
pattern: "^(start|stop)$"
exitStatusWhitelist:
type: array
default: []
items:
type: string
pattern: "^(success|abort|fail)$"
retryBehaviour:
type: object
properties:
Expand Down
8 changes: 8 additions & 0 deletions charts/events/hooks/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class RetryBehaviour(BaseModel):
class TriggerWorkflow(BaseModel):
template: str
triggerOnMessageType: Literal["start", "stop"] | None = None
exitStatusWhitelist: list[str]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would a better name be "triggerOnExitStatus"?

parameters: list[WorkflowParameter]
retryBehaviour: RetryBehaviour | None = None

Expand Down Expand Up @@ -123,6 +124,13 @@ def sync(self, parent: dict, related: dict) -> SyncResponse:
"value": [workflow.triggerOnMessageType],
})

if workflow.exitStatusWhitelist and source_type == "message-bus":

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that you are following the pre-existing example of the triggerOnMessageType setting. But this design couples the Trigger CR interface strongly to the format of the message being emitted by the beamline.

Did you consider exposing "dataFilters" more directly to give consumers of this API more flexibility?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hadn't really, but you're right, that might be easier at this point than having separate fields for each part of the message that users want to filter on. I'll switch it over and see if it still feels intuitive to use

dataFilters.append({
"path": "body.doc.exit_status",
"type": "string",
"value": workflow.exitStatusWhitelist
})

if namespace != "events":
dataFilters.append({
"path": "body.doc.instrument_session",
Expand Down
Loading