Skip to content
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

addition of signadot job submit -f ... --wait #152

Merged
merged 2 commits into from
Jan 7, 2025
Merged

Conversation

scott-cotton
Copy link
Member

@scott-cotton scott-cotton commented Dec 30, 2024

24-12-30 scott@air cli % cat ~/tmp/job.yaml
spec:
  namePrefix: jwait
  runnerGroup: scott-jrg
  script: |
    #!/bin/sh
    echo not exiting-28
24-12-30 scott@air cli % ./signadot job submit -f ~/tmp/job.yaml --wait
Job jwait-lfl0zyi succeeded on Job Runner Group: scott-jrg

Dashboard page: https://app.signadot.com/testing/jobs/jwait-lfl0zyi

24-12-30 scott@air cli % echo $?
0
24-12-30 scott@air cli % cat ~/tmp/job.yaml
spec:
  namePrefix: jwait
  runnerGroup: scott-jrg
  script: |
    #!/bin/sh
    echo exiting-28
    exit 28
24-12-30 scott@air cli % ./signadot job submit -f ~/tmp/job.yaml --wait
Job jwait-k3mbgby failed on Job Runner Group: scott-jrg

Dashboard page: https://app.signadot.com/testing/jobs/jwait-k3mbgby

Error: job "jwait-k3mbgby" failed
24-12-30 scott@air cli % echo $?
1
24-12-30 scott@air cli % ./signadot job submit -f ~/tmp/job.yaml --wait --attach
Error: cannot specify both --attach and --wait

checkpoint
@davixcky
Copy link
Contributor

Just to get a little bit of context, the main difference is that wait don't print the logs? Or there is other difference?

@scott-cotton scott-cotton requested a review from foxish December 31, 2024 14:12
@scott-cotton
Copy link
Member Author

Just to get a little bit of context, the main difference is that wait don't print the logs? Or there is other difference?

The main objective of this is to make it simple to run a job and determine in CI (automatically) whether it succeeded. --attach has the disadvantage that, due to retries, the output isn't parseable or really usable and makes it awkward at best to retrieve the job name. Here, one can also use -o json | jq -r .name to get the name of the job for subsequent artifact downloads.

Copy link
Member

@foxish foxish left a comment

Choose a reason for hiding this comment

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

Overall seems like a good idea and the fact that it's orthogonal to --attach makes sense.

@@ -26,6 +27,7 @@ func (c *JobSubmit) AddFlags(cmd *cobra.Command) {
cmd.Flags().Var(&c.TemplateVals, "set", "--set var=val")
cmd.Flags().BoolVar(&c.Attach, "attach", false, "waits until the job is completed, displaying the stdout and stderr streams")
cmd.Flags().DurationVar(&c.Timeout, "timeout", 0, "timeout when waiting for the job to be started, if 0 is specified, no timeout will be applied and the command will wait until completion or cancellation of the job (default 0)")
Copy link
Member

@foxish foxish Jan 6, 2025

Choose a reason for hiding this comment

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

In sb apply, we have --wait and --wait-timeout. Here, we have this timeout property that looks sort of related to wait. I'm curious whether this timeout is the equivalent of --wait-timeout when using with --wait?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, it is. I guess we could add an alias or something to make it more uniform

Copy link
Member Author

Choose a reason for hiding this comment

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

I double checked this and

  1. I corrected the description, which was improperly worded before this PR, now it applies to both --attach and --wait
  2. I fixed how --timeout applies to --wait; I had tested that but I guess I got the test wrong or it was on a dev version. Now it actually checks the timeout when non-zero during the --wait poll.

Copy link
Contributor

@daniel-de-vera daniel-de-vera left a comment

Choose a reason for hiding this comment

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

LGTM, just left a minor comment.

- reduce poll frequency
- make sure timeout applies to `--wait` properly

also correct the doc for `--timeout`
@scott-cotton scott-cotton merged commit ff987db into main Jan 7, 2025
@scott-cotton scott-cotton deleted the job-wait branch January 7, 2025 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants