Pull host spoofing logic into an http client#1458
Pull host spoofing logic into an http client#1458google-prow-robot merged 1 commit intoknative:masterfrom
Conversation
d03ddde to
222f728
Compare
|
/assign @tcnghia @bobcatfish |
|
Nice! /approve Holding so @bobcatfish can take a look. |
DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
|
/lgtm |
|
/hold Going to pull this into a separate file per #1460 (comment) |
bobcatfish
left a comment
There was a problem hiding this comment.
Can you also update the docs in adding_tests.md? some description of this interface there might make this all crystal clear (helps for a review too! cuz then i can start with the docs before diving into the nitty gritty
There was a problem hiding this comment.
I like the idea of exposing a polling interface that is specifically oriented around polling response objects safely.
It took me a while (and talking with you) to understand why bodyMatcher is replacing the body of the response after reading it, but now that I understand (it's so you can poll it without changing it, and also so you can return the response object untarnished), what do you think about this idea: what if the interface to inState (i.e. the ResponseChecker) took a different object, not the actual response, but a response object you have constructed that contains the body of the response, the error code, etc.? then ppl can do whatever they want to it in inState without causing side effects (in the currently implementation, there's nothing to stop someone from avoiding bodyMatcher and doing all kinds of terrible things to the response in their inState - maybe by accident!
There was a problem hiding this comment.
Oh. I like this!
There was a problem hiding this comment.
I think the comment describing this function could have more detail about the assumed interface, e.g. details such as the response body should not be consumed (or maybe that wont be a problem, see above), and what is returned (or you could include more of this in adding_tests.md)
There was a problem hiding this comment.
I'll add a longer comment to the ResponseChecker type, let me know if that does not address your concern here.
There was a problem hiding this comment.
two things i am not so fond of here:
- I find it very hard to tell the difference between bodyMatcher, matchesBody and eventuallyMatchesBody based on name and docs (esp. eventuallyMatchesBody b/c from the name and description i thought that function itself was doing polling)
- I don't like it that these have been made with a specific usage in mind: being invoked in a polling method, but also are intended to be used in a non-polling context. i'd prefer if the part that is going to be used in a non-polling context was factored out and the poll-ready interface was only used when polling is involved
There was a problem hiding this comment.
bodyMatcher
This should mostly go away with your other suggestion.
used in a non-polling context
Yeah this was a bit of a shortcut, I'll break these down.
2fee235 to
8fcdc8e
Compare
|
/assign @mattmoor |
|
I welcome any and all bikeshedding for names :) |
|
/lgtm |
bobcatfish
left a comment
There was a problem hiding this comment.
Looking good! Still would love to see some docs in adding_tests.md :D
/lgtm
/approve
/meow space
/hold
There was a problem hiding this comment.
how do you feel about these timeouts being the SAME values in multiple files but also duplicated everywhere? i dont have any good ideas what else to do.
There was a problem hiding this comment.
I don't understand, can you elaborate?
There was a problem hiding this comment.
part of why you dont understand is that i derped - i thought you were adding a new set of timeouts.
as it stands these will only exist here but then also in crd_checks - i guess 2 spots isnt so bad
There was a problem hiding this comment.
is this a pattern people use? ive never seen this before so it seems strange to me but im probably not used to it!
There was a problem hiding this comment.
courtesy of @imjasonh
I'll add a comment.
There was a problem hiding this comment.
im interested in why this is called Interface instead of something like SpoofingClientInterface
There was a problem hiding this comment.
To avoid the stutter. If another package wants to implement this, I prefer spoof.Interface to spoof.SpoofingClientInterface. If this ends up with more than one interface, I'd readily change it.
There was a problem hiding this comment.
okee dokee, thanks for explaining
There was a problem hiding this comment.
we should probably have some docs/comments somewhere that explain the scope for this, e.g. this is cant be reused for multiple Ingresses (tied to an ingress)
There was a problem hiding this comment.
Good idea, thanks.
There was a problem hiding this comment.
how about something like:
"EventuallyMatchesBody is the same as MatchesBody, but will return false, nil if the response does not match, which will prompt polling methods such as SpoofingClient.Poll to retry the request"
There was a problem hiding this comment.
I've incorporated your comment and changed the structure of EventuallyMatchesBody to mirror MatchesBody so that it's easier to compare them. I also added a comment describing the behavior of each failure condition to make it explicit why the false case does what it does.
WDYT?
DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: adrcunha, bobcatfish, jonjohnsonjr, mattmoor The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
This little abstraction hoists the hostname spoofing into its own http client so that it is reusable outside of the context of waiting for an endpoint to return a specific response.
297d095 to
790b57b
Compare
jonjohnsonjr
left a comment
There was a problem hiding this comment.
I think that's everything, please LMK if I missed anything. Thanks for the review 🤸♂️
There was a problem hiding this comment.
To avoid the stutter. If another package wants to implement this, I prefer spoof.Interface to spoof.SpoofingClientInterface. If this ends up with more than one interface, I'd readily change it.
There was a problem hiding this comment.
courtesy of @imjasonh
I'll add a comment.
There was a problem hiding this comment.
Good idea, thanks.
There was a problem hiding this comment.
I don't understand, can you elaborate?
There was a problem hiding this comment.
I've incorporated your comment and changed the structure of EventuallyMatchesBody to mirror MatchesBody so that it's easier to compare them. I also added a comment describing the behavior of each failure condition to make it explicit why the false case does what it does.
WDYT?
|
/hold cancel This should be ready for a final look @bobcatfish 👍 |
There was a problem hiding this comment.
part of why you dont understand is that i derped - i thought you were adding a new set of timeouts.
as it stands these will only exist here but then also in crd_checks - i guess 2 spots isnt so bad
There was a problem hiding this comment.
okee dokee, thanks for explaining
…e-v1.16 [release-v1.16] Update OWNERS file


This little abstraction hoists the hostname spoofing into its own http
client so that it is reusable outside of the context of waiting for an
endpoint to return a specific response.