-
Notifications
You must be signed in to change notification settings - Fork 404
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
support filter chain for filtering response data #1189
support filter chain for filtering response data #1189
Conversation
@rambohe-ch: GitHub didn't allow me to assign the following users: your_reviewer. Note that only openyurtio members, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time. In 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: rambohe-ch The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
04bccc8
to
60ca6f7
Compare
Codecov Report
@@ Coverage Diff @@
## master #1189 +/- ##
==========================================
+ Coverage 52.20% 52.33% +0.12%
==========================================
Files 110 106 -4
Lines 13852 13852
==========================================
+ Hits 7232 7250 +18
+ Misses 5973 5953 -20
- Partials 647 649 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
pkg/yurthub/proxy/pool/pool.go
Outdated
@@ -229,7 +229,7 @@ func (pp *PoolCoordinatorProxy) modifyResponse(resp *http.Response) error { | |||
|
|||
// filter response data | |||
if pp.filterMgr != nil { | |||
if ok, runner := pp.filterMgr.FindRunner(req); ok { | |||
if runner, ok := pp.filterMgr.FindResponseFilter(req); ok { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may call it filter instead runner
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@@ -288,7 +288,7 @@ func (lb *loadBalancer) modifyResponse(resp *http.Response) error { | |||
|
|||
// filter response data | |||
if lb.filterManager != nil { | |||
if ok, runner := lb.filterManager.FindRunner(req); ok { | |||
if runner, ok := lb.filterManager.FindResponseFilter(req); ok { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
pkg/yurthub/filter/filter.go
Outdated
return obj | ||
} else if len(chain) == 1 { | ||
return chain[0].Filter(obj, stopCh) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason for such special process for case 0 and case 1?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
return 0, rc, nil | ||
func (stf *serviceTopologyFilter) Filter(obj runtime.Object, stopCh <-chan struct{}) runtime.Object { | ||
if ok := cache.WaitForCacheSync(stopCh, stf.nodeSynced, stf.serviceSynced, stf.nodePoolSynced); !ok { | ||
return obj |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If stopCh is closed, it seems to return the unfiltered object to the client. Is it suitable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if stopCh is closed, Yurthub will be exit and restart lately. so it's no problem to return a unfiltered object.
60ca6f7
to
315e03d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
What type of PR is this?
/kind feature
What this PR does / why we need it:
improve filter framework in Yurthub in order to support filter chain that multiple filters can be selected for response data.
Which issue(s) this PR fixes:
Fixes #1188
Special notes for your reviewer:
Does this PR introduce a user-facing change?
other Note