Open
Description
The current repeatPolicy
has implicit behavior that changes based on configuration:
condition
+expected
: Repeats until condition matches expectedcondition
only: Repeats while condition returns exit code 0exitCode
: Repeats while exit code matches
This implicit behavior is confusing. For example, to monitor while a service is "RUNNING", you have to think backwards and set it to repeat until it's NOT running.
Solution
Add an explicit mode
field to repeatPolicy
:
# Clear intent: repeat WHILE status is RUNNING
steps:
- name: monitor-service
command: check_status.sh
output: STATUS
repeatPolicy:
repeat: while
condition: "${STATUS}"
expected: "RUNNING"
intervalSec: 30
Examples
# Wait UNTIL service is ready
repeatPolicy:
repeat: until
condition: "nc -z localhost 8080"
intervalSec: 5
# Retry WHILE failing
repeatPolicy:
repeat: while
exitCode: [1]
intervalSec: 10
limit: 5
# Monitor WHILE healthy
repeatPolicy:
repeat: while
condition: "curl -f http://localhost/health"
intervalSec: 60
Implementation
- Update
repeat
field type inRepeatPolicy
struct toRepeatMode
- Accept constants values:
whi 4ECD le
oruntil
- Maintain backward compatibility by inferring mode when not specified:
repeat: true
or unspecified (empty) -> defaults towhile
- Add integration test
- Update the json schema
- Update the documentation on repeat policy
Benefits
- Clear Intent: No more mental gymnastics to invert logic
- Better DX:
repeat: while
is self-documenting
I’d appreciate any thoughts or suggestions you might have about this feature.
Metadata
Metadata
Assignees
Labels
No labels