-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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
Fix OpenAPI aggregation cleanup #120108
Fix OpenAPI aggregation cleanup #120108
Conversation
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.
Thanks for reporting and fixing this! A couple small nits
@@ -236,7 +236,7 @@ func (s *specAggregator) RemoveAPIService(apiServiceName string) error { | |||
defer s.mutex.Unlock() | |||
|
|||
if _, exists := s.specsByAPIServiceName[apiServiceName]; !exists { | |||
return ErrAPIServiceNotFound | |||
return nil |
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.
This function cannot return an error anymore right? Would it make sense to to change the function signature so it's more clear?
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.
Sure, changed the signature.
/triage accepted |
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.
@Jefftree thanks for your review and comments.
@@ -236,7 +236,7 @@ func (s *specAggregator) RemoveAPIService(apiServiceName string) error { | |||
defer s.mutex.Unlock() | |||
|
|||
if _, exists := s.specsByAPIServiceName[apiServiceName]; !exists { | |||
return ErrAPIServiceNotFound | |||
return nil |
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.
Sure, changed the signature.
LGTM label has been added. Git tree hash: a3860487bb874ef97b06556bedf588beefd8ed23
|
@@ -45,7 +45,7 @@ var ErrAPIServiceNotFound = errors.New("resource not found") | |||
type SpecAggregator interface { | |||
AddUpdateAPIService(apiService *v1.APIService, handler http.Handler) error | |||
UpdateAPIServiceSpec(apiServiceName string) error | |||
RemoveAPIService(apiServiceName string) error |
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.
you introduced a special error. This is becoming part of the interface and needs documentation. Or better: get rid of the error and use found bool, err error
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.
updated
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.
just a note that adding a return parameter will probably make backporting slightly more involved
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.
made a compromise here: documented the specific error ErrAPIServiceNotFound to avoid affecting v2 code and facilitate backporting.
Thanks @sttts for your review. The code was mainly to be consistent with OpenAPI v2, please let me know if we should change them together or focus on bugfix in the PR. |
RemoveAPIService(apiServiceName string) error | ||
// UpdateAPIServiceSpec updates the APIService. It returns a bool which indicates whether the APIService exists and | ||
// the actual error. | ||
UpdateAPIServiceSpec(apiServiceName string) (bool, error) |
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.
this is not what I meant. If you make "not found" explicit, it is not an error anymore. So we would return false, nil
.
f0862ed
to
1a753b9
Compare
There were four issues in OpenAPI aggregation cleanup: 1. When removing an APIService, openAPIAggregationController was called twice while openAPIV3AggregationController was never called, leading to OpenAPI v3 for the APIService not cleaned up. 2. When removing a local APIService, v2 specAggregator should not return ErrAPIServiceNotFound when it doesn't find the APIService because local APIServices were never added to its cache, otherwise confusing error logs would be generated. Besides, the method's comment indicates that the desired behavior is that no error is returned if the APIService does not exist. 3. When removing an APIService, v3 specProxier should update openapiv2converter's cache, like when updating an APIService, otherwise the API would not be removed from "/openapi/v3". 4. When v3 AggregationController reconciles an APIService, it should stop requeueing it if it fails with ErrAPIServiceNotFound as the APIService has been removed, like what v2 AggregationController does, otherwise it would keep reconciling the APIService forever. Signed-off-by: Quan Tian <[email protected]>
/approve Leaving final lgtm to @Jefftree |
/approve |
LGTM label has been added. Git tree hash: a371c959f6684053431a451213d161f6b11213f2
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Jefftree, sttts, tnqn 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 |
/retest |
@Jefftree I found there are some conflicts when backporting it to 1.27 due to the change: #118212, just want to check with you if it's still worth to backport in this situation. If yes, I would need to add ErrAPIServiceNotFound to 1.27. There is no conflict with 1.28. |
@tnqn: OpenAPIV3 went GA in 1.27 so I think it'd be worth it. Let me know if you need help with it. |
…-upstream-release-1.27 Automated cherry pick of #120108: Fix OpenAPI aggregation cleanup
…-upstream-release-1.28 Automated cherry pick of #120108: Fix OpenAPI aggregation cleanup
What type of PR is this?
/kind bug
What this PR does / why we need it:
There were four issues in OpenAPI aggregation cleanup:
Which issue(s) this PR fixes:
Fixes #120107
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: