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

Unify http/non-http result handling #729

Merged
merged 1 commit into from
Jun 4, 2019
Merged

Unify http/non-http result handling #729

merged 1 commit into from
Jun 4, 2019

Conversation

johnSchnake
Copy link
Contributor

What this PR does / why we need it:
We have two flows for this logic: one for the
HTTP server and one for the channel monitoring
results.

This change places all the logic into a central
method so that it can be modified/tested more
confidently/succinctly.

Which issue(s) this PR fixes
Related to #728

Special notes for your reviewer:
No logical changes in this PR; only doing this in prep of my next change to simplify the diffs. This way we can more easily test the logic used throughout.

Release note:

NONE

@codecov-io
Copy link

codecov-io commented May 24, 2019

Codecov Report

Merging #729 into master will increase coverage by 0.07%.
The diff coverage is 59.52%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #729      +/-   ##
==========================================
+ Coverage    40.1%   40.18%   +0.07%     
==========================================
  Files          69       69              
  Lines        3922     3932      +10     
==========================================
+ Hits         1573     1580       +7     
- Misses       2247     2251       +4     
+ Partials      102      101       -1
Impacted Files Coverage Δ
pkg/plugin/aggregation/aggregator.go 67.28% <59.52%> (+0.27%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a07aed2...b2f0d07. Read the comment docs.

@johnSchnake
Copy link
Contributor Author

@stevesloka Sanity check on this?

The diff looks bigger than it logically is.

I did the following:

  • created the error type to pass http-ish errors
  • moved the logic out of both IngestResults and HandleResults and put it into the processResults method
  • the 2 original methods call process results and just log/respond to the user as necessary in that context

No tests changed and no logical change in behavior intended. Follow up PR will modify things and add new tests.

@johnSchnake johnSchnake requested a review from stevesloka May 24, 2019 19:17
@johnSchnake johnSchnake mentioned this pull request May 25, 2019
We have two flows for this logic: one for the
HTTP server and one for the channel monitoring
results.

This change places all the logic into a central
method so that it can be modified/tested more
confidently/succinctly.

Signed-off-by: John Schnake <[email protected]>
@johnSchnake johnSchnake changed the title Unity http/non-http result handling Unify http/non-http result handling May 25, 2019
Copy link
Contributor

@stevesloka stevesloka left a comment

Choose a reason for hiding this comment

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

/lgtm with maybe a small nit

return
return &httpError{
err: fmt.Errorf("result %v unexpected", resultID),
code: http.StatusForbidden,
Copy link
Contributor

Choose a reason for hiding this comment

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

A 403 seems out of place here for this type of error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree, looking at docs that seems like it is supposed to be auth related, not content like this. Not 100% sure of the right response though but that is for another PR; this just moved the code and didnt chose it here. Maybe https://httpstatuses.com/422 would be most appropriate.

@johnSchnake johnSchnake merged commit 98d7d32 into vmware-tanzu:master Jun 4, 2019
@johnSchnake johnSchnake deleted the unifyResultsHandling branch June 4, 2019 21:15
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.

3 participants