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

feat: add egctl ratelimit config support #2674

Merged
merged 3 commits into from
Feb 26, 2024
Merged

Conversation

ShyunnY
Copy link
Contributor

@ShyunnY ShyunnY commented Feb 22, 2024

What type of PR is this?

feat(egctl): add egctl ratelimit config support

What this PR does / why we need it:

Add the egctl ratelimit subcommand to egctl. This subcommand can help developers or users quickly view the ratelimit configuration or debug the ratelimit.

Which issue(s) this PR fixes:

Fixes #2584

@ShyunnY ShyunnY requested a review from a team as a code owner February 22, 2024 15:20
Copy link

codecov bot commented Feb 22, 2024

Codecov Report

Attention: Patch coverage is 45.00000% with 88 lines in your changes are missing coverage. Please review.

Project coverage is 62.98%. Comparing base (4c79ef9) to head (756c017).
Report is 18 commits behind head on main.

Files Patch % Lines
internal/cmd/egctl/config_ratelimit.go 43.05% 72 Missing and 10 partials ⚠️
internal/cmd/egctl/config_cmd.go 0.00% 3 Missing ⚠️
internal/cmd/egctl/envoy_stats.go 0.00% 2 Missing ⚠️
internal/cmd/egctl/config.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2674      +/-   ##
==========================================
- Coverage   63.38%   62.98%   -0.41%     
==========================================
  Files         119      122       +3     
  Lines       19098    19756     +658     
==========================================
+ Hits        12106    12443     +337     
- Misses       6193     6506     +313     
- Partials      799      807       +8     

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

@ShyunnY ShyunnY force-pushed the egctl branch 2 times, most recently from faed6ce to 5da05ef Compare February 22, 2024 15:51
@@ -35,6 +36,10 @@ func newConfigCommand() *cobra.Command {
return cfgCommand
}

func ratelimitCommand() *cobra.Command {
Copy link
Contributor

Choose a reason for hiding this comment

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

why not use ratelimitConfigCommand directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have thought about this problem, but I hope to write it like the func proxyCommand() function for backward compatibility.

zirain
zirain previously approved these changes Feb 25, 2024
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.

Great works @ShyunnY, add some minor comments. Also, CI need to fix.

I've test this command on my local env, and it works as expected, thanks!

internal/cmd/egctl/config_ratelimit.go Outdated Show resolved Hide resolved
internal/cmd/egctl/config_test.go Outdated Show resolved Hide resolved
internal/infrastructure/kubernetes/ratelimit/resource.go Outdated Show resolved Hide resolved
internal/infrastructure/kubernetes/ratelimit/resource.go Outdated Show resolved Hide resolved
internal/cmd/egctl/config_ratelimit.go Outdated Show resolved Hide resolved
internal/cmd/egctl/config_ratelimit.go Outdated Show resolved Hide resolved
@ShyunnY
Copy link
Contributor Author

ShyunnY commented Feb 26, 2024

@shawnh2 Thank you for your suggestions on this PR ❤️ , I have modified it. But I don’t quite understand why CI test will produce errors. Is this my problem?

expectErr error
}{
{
caseName: "normally obtain the rate limit pod of Running phase",
Copy link
Contributor

Choose a reason for hiding this comment

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

the log shows there's something wrong with this test case: https://github.com/envoyproxy/gateway/actions/runs/8047676612/job/21977431309?pr=2674#step:4:144.

seems the conditions in this status also needs to be updated according to checkRateLimitPodStatusReady

tc := tc
t.Run(tc.name, func(t *testing.T) {
got := LabelSelector()
require.Equal(t, tc.expected, got)
Copy link
Contributor

Choose a reason for hiding this comment

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

better go with require.ElementsMatch, since we only can promise the values of got as expected not the orders.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, do I only need to change these two things?

Copy link
Contributor

Choose a reason for hiding this comment

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

let's give it a try now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems to be okay this time 😃

@shawnh2
Copy link
Contributor

shawnh2 commented Feb 26, 2024

/retest

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!

Copy link
Contributor

@arkodg arkodg 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 !

@arkodg arkodg merged commit 72fadb7 into envoyproxy:main Feb 26, 2024
21 of 22 checks passed
@ShyunnY ShyunnY deleted the egctl branch March 8, 2024 05:36
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.

Add egctl config ratelimit support
4 participants