-
Notifications
You must be signed in to change notification settings - Fork 42
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
Implement schedule
commands
#459
Conversation
schedule
commands [incomplete]schedule
commands
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.
Looks good. Didn't pour over every output detail or anything.
temporalcli/commands.schedule.go
Outdated
// For json: this doesn't come out as proper protojson, the field names are | ||
// day_of_month instead of dayOfMonth. |
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.
This is the cost of mixing proto and non-proto JSON but there's not an east solution. What we do in some other commands is separate the JSON representation structs from the text ones, and for JSON, make this be something like []json.Message
instead where we pre-JSON it. It became too confusing for complicated models to try to satisfy JSON and non-JSON needs with the same model (but if you must reuse models, consider more explicit JSON models then that meet the JSON field name needs).
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.
I ended up adding a special case for slices in the printer.. I hope that's acceptable. With that, and a couple specialized structs in here, I think the text output for specs is much nicer.
For json, I realized I was making the problem much harder than it had to be: I just made -o json
do what --raw
did, for both describe and list. There's no reason at all to have two different json outputs.
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.
I ended up adding a special case for slices in the printer.. I hope that's acceptable.
Works for me, not sure we've had a stance on nested slice printing so I don't mind making it friendlier. Looks like it breaks a test, so may have to update that.
For json, I realized I was making the problem much harder than it had to be: I just made -o json do what --raw did, for both describe and list. There's no reason at all to have two different json outputs.
Also works for me, because I find proto to be more stable and documented than CLI-specific structs anyways (but have to resort to specific structs when needing to combine of course)
temporalcli/commands.schedule.go
Outdated
// TODO: should we include any other fields here, e.g. jitter, time zone, start/end time | ||
out := &printableSchedule{ |
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.
I think so. I'd expect describing to return everything available.
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.
Added most of the data that's in the schedule description. Also rearranged a bunch of stuff and changed some formatting. I'm not sure it's great but it's closer.
Also appears this will close #433 - if that's true can you update the description to close that when this is merged? |
Not really, it just prints memo/search attrs in list, but not update them. |
595e771
to
f888d67
Compare
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.
Looks good, just want to bring that test time down
res := s.createSchedule("--interval", "2s") | ||
s.NoError(res.Err) | ||
|
||
time.Sleep(4 * time.Second) // run at least once |
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.
Can we avoid sleeps in tests? Can we do some kind of manual trigger/backfill here?
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.
we can do a manual trigger, yeah. I wanted to keep the tests more orthogonal and use a normal scheduled run here, but I guess it doesn't matter.
res := s.createSchedule("--interval", "2s") | ||
s.NoError(res.Err) | ||
|
||
time.Sleep(4 * time.Second) // run at least once |
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.
we can do a manual trigger, yeah. I wanted to keep the tests more orthogonal and use a normal scheduled run here, but I guess it doesn't matter.
temporalcli/commands.schedule.go
Outdated
WorkflowTaskTimeout: opts.WorkflowTaskTimeout, | ||
// RetryPolicy not supported yet | ||
// TODO: buildStartOptions doesn't fill in TypedSearchAttributes, this doesn't work yet: | ||
TypedSearchAttributes: opts.TypedSearchAttributes, |
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.
@cretz @Quinn-With-Two-Ns What do you think is the best way to handle this right now?
The situation appears to be: buildStartOptions
builds search attributes in the form map[string]any
(very easy to do from json) and puts them in StartWorkflowOptions.SearchAttributes
. This is deprecated, but it still works for starting workflows.
For ScheduleWorkflowAction
though, apparently untyped support is gone completely? The comment on UntypedSearchAttributes
says This should never be used for create.
Even if I could use it, it's a map[string]*commonpb.Payload
which means I'd have to convert to Payload
s (a little more work but not a huge deal).
To set TypedSearchAttributes
, though, it looks like I'd have to do a lot of work. Basically it would have to look a lot like convertToTypedSearchAttributes
from internal/internal_search_attributes.go
, except with reflection?
I understand the goal of typed search attributes is to make them hard to use in a generic way, but the cli kinda needs to use them in a generic way 🫤 (So does "modify schedule search attributes" btw, except that's from workflow context so the code has to be different again.)
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.
Ug, yeah, we've hit this a few times now with generic tools. If the UntypedSearchAttributes
does work for now I think it's ok to use here and just assume that warning is for users only. The problem is technically a search attribute key for setting is supposed to be defined by its name and type, but we have no reasonable interface for that in CLI.
Note the starting of workflows sets untyped search attributes too, we were just forced to remove the either-or option on schedules because this same type is used for update and we couldn't tell which was the intended field on update (it was a long discussion internally before we made this backwards compatibility break and we documented it in release notes).
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.
I confirmed UntypedSearchAttributes
in the start workflow action works for create schedule so I used that for now (sorry Quinn) and added a test.
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.
If there are obvious flag incompatibilities with today's CLI schedule command, can you mention those in the PR description? We're going to go across the PRs and collect them when we make our first release.
I'm not aware of any big incompatibilities, though there may be some small ones. The non-raw describe json output is different, but that's why |
👍 No concerns about output compatibility |
What was changed
Implement schedule commands for new CLI.
Why?
Feature parity.
Checklist
Closes
How was this tested:
new tests
temporal schedule describe -o json
changed to the--raw
format of the previous cli.