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

chore(example): Add watch timeout and print out workflow status message #4740

Merged
merged 2 commits into from Dec 18, 2020
Merged

chore(example): Add watch timeout and print out workflow status message #4740

merged 2 commits into from Dec 18, 2020

Conversation

terrytangyuan
Copy link
Member

The workflow in the current example would only exit the loop when it reaches completion. It's better to exit loop immediately when the workflow has failed.

Signed-off-by: terrytangyuan terrytangyuan@gmail.com

Checklist:

@@ -68,6 +68,10 @@ func main() {
if !ok {
continue
}
if wf.Status.Phase == wfv1.NodeFailed || wf.Status.Phase == wfv1.NodeError {
Copy link
Contributor

Choose a reason for hiding this comment

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

won't the block on line 75 also catch this?

Copy link
Member Author

Choose a reason for hiding this comment

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

That's true. I was debugging why the example has been running forever and turns out that the problem is something else. I have updated this PR to print out the detailed error message from the status and added the timeout to the watch to improve the usability of this example. Let me know what you think.

@terrytangyuan terrytangyuan changed the title fix(example): Exit loop immediately when workflow has failed enh(example): Add watch timeout and print out workflow error message Dec 15, 2020
@terrytangyuan terrytangyuan changed the title enh(example): Add watch timeout and print out workflow error message chore(example): Add watch timeout and print out workflow error message Dec 15, 2020
Signed-off-by: terrytangyuan <terrytangyuan@gmail.com>
@@ -70,6 +71,9 @@ func main() {
}
if !wf.Status.FinishedAt.IsZero() {
fmt.Printf("Workflow %s %s at %v\n", wf.Name, wf.Status.Phase, wf.Status.FinishedAt)
if wf.Status.Phase == wfv1.NodeFailed || wf.Status.Phase == wfv1.NodeError {
fmt.Printf("Workflow %s failed due to: %s", wf.Name, wf.Status.Message)
Copy link
Contributor

Choose a reason for hiding this comment

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

could you just add the wf.Status.Message to line 74?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure updated.

Signed-off-by: terrytangyuan <terrytangyuan@gmail.com>
@terrytangyuan terrytangyuan changed the title chore(example): Add watch timeout and print out workflow error message chore(example): Add watch timeout and print out workflow status message Dec 15, 2020
@alexec alexec merged commit 15ec9f5 into argoproj:master Dec 18, 2020
@terrytangyuan terrytangyuan deleted the go-example-enh branch December 19, 2020 00:01
@simster7 simster7 mentioned this pull request Jan 4, 2021
21 tasks
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.

None yet

2 participants