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 incorrect results by antctl get networkpolicy on Pods #3499

Merged
merged 2 commits into from
Mar 26, 2022

Conversation

Dyanngg
Copy link
Contributor

@Dyanngg Dyanngg commented Mar 21, 2022

When the -p <PodName> -n <PodNamespace> options are used in antctl get networkpolicy command, the -n option should only be used to identify the Pod being queried, but not filter any internal policies based on the Namespace. Otherwise, all ACNPs applied to the Pod will be filtered out.

This PR also fixes an issue where duplicate policy names are displayed.

Signed-off-by: Yang Ding [email protected]

@Dyanngg Dyanngg added kind/bug Categorizes issue or PR as related to a bug. area/component/antctl Issues or PRs releated to the command line interface component labels Mar 21, 2022
@codecov-commenter
Copy link

codecov-commenter commented Mar 21, 2022

Codecov Report

Merging #3499 (e6a3079) into main (a539b78) will decrease coverage by 2.08%.
The diff coverage is 20.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3499      +/-   ##
==========================================
- Coverage   65.46%   63.37%   -2.09%     
==========================================
  Files         278      278              
  Lines       27771    27774       +3     
==========================================
- Hits        18179    17603     -576     
- Misses       7666     8332     +666     
+ Partials     1926     1839      -87     
Flag Coverage Δ
kind-e2e-tests 51.66% <20.00%> (-3.53%) ⬇️
unit-tests 43.36% <0.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/agent/controller/networkpolicy/cache.go 86.06% <0.00%> (-2.70%) ⬇️
pkg/antctl/antctl.go 66.66% <ø> (ø)
pkg/querier/querier.go 57.14% <ø> (ø)
.../agent/apiserver/handlers/networkpolicy/handler.go 50.00% <21.42%> (-8.34%) ⬇️
...g/agent/apiserver/handlers/featuregates/handler.go 0.00% <0.00%> (-82.36%) ⬇️
pkg/controller/egress/store/egressgroup.go 1.38% <0.00%> (-58.34%) ⬇️
...kg/apiserver/registry/system/supportbundle/rest.go 20.45% <0.00%> (-54.55%) ⬇️
pkg/support/dump.go 8.19% <0.00%> (-49.19%) ⬇️
...egator/apiserver/handlers/recordmetrics/handler.go 0.00% <0.00%> (-44.45%) ⬇️
pkg/support/dump_others.go 0.00% <0.00%> (-44.00%) ⬇️
... and 36 more

@Dyanngg Dyanngg requested a review from jianjuns March 22, 2022 03:45
@tnqn tnqn added this to the Antrea v1.6 release milestone Mar 22, 2022
@tnqn tnqn added the action/release-note Indicates a PR that should be included in release notes. label Mar 22, 2022
return nil, fmt.Errorf("with a name, none of the other fields can be set")
return nil, "", fmt.Errorf("with a name, none of the other fields can be set")
}
// In case of getting policies applied to a specific Pod, the -n option is used to specify the
Copy link
Member

Choose a reason for hiding this comment

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

I feel it's confusing that "-n" stands for the namespace of the Pod in one case and stands for the namespace filter of networkpolicies in another case.
Could we ask for "-p ns/pod" for the former case to be clear?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@GraysonWu and I thought about this when we discussed how to fix this issue. The problem by going with "-p ns/pod" is that it doesn't make much sense for -p and -n to be used in conjunction anymore. Do you think we should disable this usage?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to "-p ns/pod" in the latest commit

@Dyanngg Dyanngg requested a review from tnqn March 22, 2022 17:59
@vicky-liu
Copy link

This PR came late for Antrea 1.6.0, we can set it as stretched goal.

tnqn
tnqn previously approved these changes Mar 25, 2022
Copy link
Member

@tnqn tnqn left a comment

Choose a reason for hiding this comment

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

LGTM

@tnqn
Copy link
Member

tnqn commented Mar 25, 2022

/test-all

@tnqn
Copy link
Member

tnqn commented Mar 25, 2022

/test-integration

@tnqn
Copy link
Member

tnqn commented Mar 25, 2022

/test-all
/test-integration

@Dyanngg
Copy link
Contributor Author

Dyanngg commented Mar 25, 2022

Fixed lint issue /test-all /test-integration

@tnqn
Copy link
Member

tnqn commented Mar 26, 2022

/test-integration

@tnqn tnqn merged commit b9e37a8 into antrea-io:main Mar 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action/release-note Indicates a PR that should be included in release notes. area/component/antctl Issues or PRs releated to the command line interface component kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants