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

fix: fix checkObjectNamespaceLabels func param type #2477

Merged
merged 1 commit into from
Jan 23, 2024
Merged

fix: fix checkObjectNamespaceLabels func param type #2477

merged 1 commit into from
Jan 23, 2024

Conversation

ShyunnY
Copy link
Contributor

@ShyunnY ShyunnY commented Jan 22, 2024

What type of PR is this?

What this PR does / why we need it:

Which issue(s) this PR fixes:
Fix the checkObjectNamespaceLabels function param type so that it can support passing in common interface types. Avoid obtaining namespace in advance outside the function.

Fixes #

@ShyunnY ShyunnY requested a review from a team as a code owner January 22, 2024 08:05
zirain
zirain previously approved these changes Jan 22, 2024
Copy link

codecov bot commented Jan 22, 2024

Codecov Report

Attention: 12 lines in your changes are missing coverage. Please review.

Comparison is base (20b8497) 64.71% compared to head (235c992) 64.66%.
Report is 12 commits behind head on main.

Files Patch % Lines
internal/provider/kubernetes/routes.go 66.66% 5 Missing ⚠️
internal/provider/kubernetes/controller.go 33.33% 4 Missing ⚠️
internal/provider/kubernetes/filters.go 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2477      +/-   ##
==========================================
- Coverage   64.71%   64.66%   -0.06%     
==========================================
  Files         115      115              
  Lines       17431    17470      +39     
==========================================
+ Hits        11281    11297      +16     
- Misses       5433     5451      +18     
- Partials      717      722       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ShyunnY
Copy link
Contributor Author

ShyunnY commented Jan 22, 2024

@zirain The rest of the files cannot be covered by the test, do I need to deal with it?

Copy link
Contributor

@shawnh2 shawnh2 left a comment

Choose a reason for hiding this comment

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

hi @ShyunnY please fix linter, thanks

@ShyunnY
Copy link
Contributor Author

ShyunnY commented Jan 22, 2024

hi @ShyunnY please fix linter, thanks

Yes, I have fix it

@zirain
Copy link
Member

zirain commented Jan 22, 2024

/retest

@@ -580,8 +580,10 @@ func (r *gatewayAPIReconciler) findReferenceGrant(ctx context.Context, from, to
if len(r.namespaceLabels) != 0 {
var rgs []gwapiv1b1.ReferenceGrant
for _, refGrant := range refGrants {
refGrant := refGrant

ns := refGrant.GetNamespace()
Copy link
Contributor

Choose a reason for hiding this comment

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

are these ns needed ?

Copy link
Contributor

Choose a reason for hiding this comment

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

same for other types

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In principle, we don’t need ns here, but I considered the future scalability and may still use this ns, so I kept it.

Copy link
Contributor

@arkodg arkodg Jan 22, 2024

Choose a reason for hiding this comment

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

if thats the case, do we need to change the signature of checkObjectNamespaceLabels, how are we benefitting from it ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

First of all, I think that the step of obtaining the namespace in advance before calling the function may be redundant externally. We should move this step inside the function and let the function do this step for us.
Secondly, we may expand the judgment conditions in the future, using the interface form of metav1.object as a parameter, which will allow us to obtain more information.
Finally, subsequent modifications to this function will not affect external calls.

Copy link
Contributor

Choose a reason for hiding this comment

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

vote for removing these ns, since there's no other particular usage. if we encounter this in the future, we can simply change it back.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, of course we can do that. One reason why I didn't remove ns is because the subsequent error message used the ns variable. I didn't want to modify the original code too much. I thought that this ns variable might be used in the future, so I made it a retained variable. rather than removing it.
@shawnh2

Copy link
Contributor

Choose a reason for hiding this comment

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

imo, removing these ns is kinda point of this PR. as for those used in error msg, directly using xxx.GetNamespace() works for me.

func (r *gatewayAPIReconciler) checkObjectNamespaceLabels(obj matav1.Object) (bool, error) {

var nsString string
// it requires extra condition?
Copy link
Contributor

@shawnh2 shawnh2 Jan 23, 2024

Choose a reason for hiding this comment

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

is this comment a TODO?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Strictly speaking, this may be a TODO. Because we need to judge cluster resources and some resources that do not have namespace.

Copy link
Contributor

Choose a reason for hiding this comment

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

got it! can you make this comment more clear? it will help those who come across it later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, i have do that

Signed-off-by: ShyunnY <1147212064@qq.com>
@ShyunnY ShyunnY requested a review from shawnh2 January 23, 2024 11:24
Copy link
Contributor

@shawnh2 shawnh2 left a comment

Choose a reason for hiding this comment

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

lgtm, thanks

@shawnh2 shawnh2 requested review from zirain and arkodg January 23, 2024 11:38
@arkodg arkodg merged commit 45c03a2 into envoyproxy:main Jan 23, 2024
17 checks passed
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.

4 participants