-
Notifications
You must be signed in to change notification settings - Fork 367
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
Add sort-by effectivePriority for antctl get networkpolicy #1530
Conversation
Thanks for your PR. The following commands are available:
|
3079f01
to
3708ab2
Compare
Codecov Report
@@ Coverage Diff @@
## master #1530 +/- ##
==========================================
- Coverage 63.31% 62.11% -1.21%
==========================================
Files 170 182 +12
Lines 14250 15420 +1170
==========================================
+ Hits 9023 9578 +555
- Misses 4292 4826 +534
- Partials 935 1016 +81
Flags with carried forward coverage won't be shown. Click here to find out more.
|
d63205a
to
1a02873
Compare
1a02873
to
8830b8d
Compare
8830b8d
to
9849143
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.
maybe you can mention this command in the documentation as part of this PR, since it is a pretty small change in terms of LOCs? In antctl.md (and maybe in antrea-network-policy.md as well?).
9849143
to
9357f8a
Compare
I think sorting functionality is typically done on the client-side instead of making the server do this work. This is the case for kubectl for example: kubernetes/kubernetes#80602 (comment) One advantage of sorting client-side would be that we could support "sort by effective priority" when using antctl in controller-mode without having to introduce a new API. @tnqn what do you think? |
I agree with @antoninbas, and the apiserver lib doesn't support |
So if we move this to the client side, does it mean we sort the NetworkPolicies by effective priority by default? since it does not take |
9357f8a
to
01a0978
Compare
I believe the fact that we do not support flags for controller commands ( In theory all commands could support |
543f1d5
to
b809d06
Compare
b809d06
to
0c15f32
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.
some minor comments, otherwise LGTM
thanks for making the change and implementing this client-side, we get "controller-mode" support for free :)
@@ -127,6 +127,13 @@ func (e *resourceEndpoint) flags() []flagInfo { | |||
usage: "Filter the resource by namespace", | |||
}) | |||
} | |||
if e.groupVersionResource == &v1beta2.NetworkPolicyVersionResource { |
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.
in a future PR, we can consider extending this flag to other resources & other fields. Would you mind opening a Github issue for that, I think it would make a "good first issue" as well
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.
Opened #1605
0c15f32
to
c02b813
Compare
sortBy := query.Get("sort-by") | ||
if sortBy != "" && sortBy != sortByEffectivePriority { | ||
return nil, fmt.Errorf("unsupported value for sort-by option. Current supported value is %s", sortByEffectivePriority) | ||
} |
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.
@Dyanngg I am confused as to why the check is done on the server-side, and only for the agent?
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 are totally right. Reverted that and added the check on the client-side
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
/test-all |
* Add sort-by effectivePriority for antctl get networkpolicy * Address comments and move sort logic to the client side * Add value check for sort-by flag
This PR aims to solve #1388
antctl get networkpolicy
, which sorts the Antrea internal controlplane NetworkPolicy objects by the order in which they are evaluated.antctl get networkpolicy
displays tier priority and policy priority by default