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

Apply as many changes as possible with error summary at end #532

Merged
merged 1 commit into from
Sep 19, 2022

Conversation

praveenrewar
Copy link
Member

@praveenrewar praveenrewar commented Jun 18, 2022

What this PR does / why we need it:

Currently kapp errors out as soon as it detects an error while apply a resource or waiting for a resource, but we would want to apply as many changes as possible and return all the errors at end. If a change doesn't depend on a failed change then it should get applied.

  • Changes that depend on failing changes shouldn't be applied
  • exit-early-on-apply-error flag can be used to exit as soon as an error is encountered while applying changes (default true)
  • exit-early-on-wait-error flag can be used to exit as soon as an error is encountered while waiting for changes (default true)

Sample gist for testing: https://gist.github.com/praveenrewar/2746318c5a273d13ed26497f34755638

TODO:

  • Add e2e test
  • Do more manual testing

Which issue(s) this PR fixes:

Fixes #426

Does this PR introduce a user-facing change?


Additional Notes for your reviewer:

Review Checklist:
  • Follows the developer guidelines
  • Relevant tests are added or updated
  • Relevant docs in this repo added or updated
  • Relevant carvel.dev docs added or updated in a separate PR and there's
    a link to that PR
  • Code is at least as readable and maintainable as it was before this
    change

Additional documentation e.g., Proposal, usage docs, etc.:


@praveenrewar praveenrewar marked this pull request as draft June 18, 2022 10:41
Comment on lines 107 to 112
if err != nil {
return err
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Should the timeout errors also include the unsuccessfulChanges?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think they should!

Copy link
Member Author

@praveenrewar praveenrewar Jul 4, 2022

Choose a reason for hiding this comment

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

I am still thinking if we should do this and what would be the best way to present the errors.

Copy link
Contributor

@100mik 100mik left a comment

Choose a reason for hiding this comment

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

Some thoughts:

  • Should there be a flag which enables disables this behaviour? What should be it's default value?
  • How does this look with multiple failures? I think we might need better formatting than [error1, error2, error3] maybe more like:
- error1
- error2
- error3

@praveenrewar
Copy link
Member Author

praveenrewar commented Jun 21, 2022

Should there be a flag which enables disables this behaviour? What should be it's default value?

Hmm, maybe, but I am not sure why someone would want to turn it off.

How does this look with multiple failures?

It's just like you have mentioned 😁 please do take a look at the gist that I have shared, it contains an example manifest and the output that we would get while deploying it.

@100mik
Copy link
Contributor

100mik commented Jun 22, 2022

Hmm, maybe, but I am not sure why someone would want to turn it off.

One case I can think of is pipelines. They would probably want to error out the moment something goes south rather than wait for other resources to be created.
Some packages might be interested in this I guess, but I do not see a super strong case for it. (Not sure if kapp-controller will choose to error out by default because the installation fails none the less)

It's just like you have mentioned 😁 please do take a look at the gist that I have shared, it contains an example manifest and the output that we would get while deploying it.

Oooh noice! Missed that. I noticed there was a ']' added to a test and misunderstood 🤔

@praveenrewar
Copy link
Member Author

They would probably want to error out the moment something goes south rather than wait for other resources to be created.

I don't know how that would be useful, but maybe it would be useful in some scenarios that I am not able to think at the moment, so I am keeping this discussion open for now, we can discuss more later.

I noticed there was a ']' added to a test and misunderstood

Yeah, I am still trying to figure out how to best use NewSemiStructuredError. Right now it formats properly when there are more errors (>1), but if there is just one error then it keeps the brackets. I will look more into it.

@praveenrewar praveenrewar force-pushed the error-at-end branch 2 times, most recently from 3f6c521 to 7cfe3b9 Compare July 3, 2022 19:17
@praveenrewar praveenrewar marked this pull request as ready for review July 4, 2022 04:57
@cppforlife
Copy link
Contributor

cppforlife commented Jul 5, 2022

  • we should probably have a flag that fails on first failure (current behaviour) so that folks can still "quickly" exit if that's what they want.
  • how does this feature play with timeout errors? should we be erroring on timeout errors immediately?

@praveenrewar
Copy link
Member Author

we should probably have a flag that fails on first failure (current behaviour) so that folks can still "quickly" exit if that's what they want.

Yeah, that's something @100mik had suggested as well. I had kept this discussion open till now, I will add a flag to disable the behaviour.

how does this feature play with timeout errors?

Right now, we error out for --wait-timeout but not for --wait-resource-timeout.

should we be erroring on timeout errors immediately?

I was thinking that individual resource timeouts can be treated as resource errors in this case, as one resource getting timed out doesn’t mean that others (which don't depend on it) will also get timed out.

@praveenrewar praveenrewar force-pushed the error-at-end branch 2 times, most recently from 05a67c8 to ee45a27 Compare July 6, 2022 13:43
@praveenrewar praveenrewar force-pushed the error-at-end branch 2 times, most recently from 47192dc to c5b2777 Compare July 21, 2022 14:31
waitingChanges.Track(appliedChanges)

if waitingChanges.IsEmpty() {
if len(unsuccessfulChanges) == 1 {
Copy link
Member Author

@praveenrewar praveenrewar Jul 25, 2022

Choose a reason for hiding this comment

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

NewSemiStructuredError doesn't work really well when there is only one error inside [] because there might be errors containing something like map[string]string and there is no good way to differentiate between an error and such field.
I should probably add this as a comment.

@100mik
Copy link
Contributor

100mik commented Jul 25, 2022

The changes themselves LGTM 🤔

Re: Error structuring
I think we are:

  • Retaining how we used to show errors for one error by using the len(unsuccessfulChanges) == 1 check
  • However multiple errors won't have the formatting due to capitalisation?

@kumaritanushree
Copy link
Contributor

Suggestion: I think it would be good if you can add little more description like: how the new output will look like? You can add some example output.

@praveenrewar
Copy link
Member Author

Retaining how we used to show errors for one error by using the len(unsuccessfulChanges) == 1 check

That's correct.

However multiple errors won't have the formatting due to capitalisation?

That doesn't happen in NewSemistructuredError.

@praveenrewar
Copy link
Member Author

Suggestion: I think it would be good if you can add little more description like: how the new output will look like? You can add some example output.

I think the test cases and the gist that I have provided should be a good indication of the output, but do let me know if I should add more examples.

@100mik
Copy link
Contributor

100mik commented Jul 26, 2022

So I am guessing multiple errors will be unformatted 🤔
Also, I m not entirely sure if the way we format a single message will help in case of multiple messages.
But I think we should explore if we have any options better than having it in one line.

That said I do not think it is a major blocker but more of a nice to have thing imo 🚀

Copy link
Contributor

@sethiyash sethiyash 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 thinking about the output. For the example given in the gist wouldn't it be better to show 2 Resource Succeded before showing errors or final summary at the end on number of resources succeeded and failed.

@praveenrewar
Copy link
Member Author

wouldn't it be better to show 2 Resource Succeded before showing errors or final summary at the end on number of resources succeeded and failed.

Hmm, definitely a good thought. The reason I didn't include more details around successful changes at the end is because we already include enough information in the logs (ok: reconcile...). I also was trying to keep the ui changes to the minimum, but I am open to creating a separate PR if we want to enhance the experience a bit further later on.

@100mik
Copy link
Contributor

100mik commented Aug 1, 2022

I think I am satisfied with how the UI changes look as well, I cannot think of how we can make a list of errors look better right away. But these cosmetic improvements can always go as a separate PR if we have better ideas.

@100mik
Copy link
Contributor

100mik commented Aug 1, 2022

Also, @praveenrewar looks like this branch needs a rebase. I will take one final look at this once it is done!

Copy link
Contributor

@100mik 100mik left a comment

Choose a reason for hiding this comment

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

A few nitty thoughts!
Over all the implementation looks good 🚀

@praveenrewar praveenrewar force-pushed the error-at-end branch 2 times, most recently from a4389a9 to 937b6fa Compare September 8, 2022 06:13
- Changes that depend on failing changes shouldn't be applied
- exit-on-apply-error flag can be used to exit as soon as an error is encountered while applying changes
- exit-on-wait-error flag can be used to exit as soon as an error is encountered while waiting for changes (default true)
Copy link
Contributor

@100mik 100mik left a comment

Choose a reason for hiding this comment

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

LGTM!

@praveenrewar praveenrewar merged commit 094843d into develop Sep 19, 2022
@praveenrewar praveenrewar deleted the error-at-end branch September 21, 2022 05:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Don't exit at first error but continues and summarizes all the found ones at the end of execution
7 participants