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

[Windows] Fix NetNeighbor Powershell error handling #2905

Merged
merged 1 commit into from
Oct 25, 2021

Conversation

lzhecheng
Copy link
Contributor

Signed-off-by: Zhecheng Li [email protected]

@lzhecheng lzhecheng added this to the Antrea v1.4 release milestone Oct 19, 2021
@codecov-commenter
Copy link

codecov-commenter commented Oct 19, 2021

Codecov Report

Merging #2905 (eb5c441) into main (e81f444) will decrease coverage by 7.65%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2905      +/-   ##
==========================================
- Coverage   60.32%   52.67%   -7.66%     
==========================================
  Files         283      283              
  Lines       23603    23644      +41     
==========================================
- Hits        14239    12454    -1785     
- Misses       7845     9803    +1958     
+ Partials     1519     1387     -132     
Flag Coverage Δ
kind-e2e-tests 32.58% <ø> (-14.84%) ⬇️
unit-tests 40.85% <ø> (-0.10%) ⬇️

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

Impacted Files Coverage Δ
pkg/controller/types/networkpolicy.go 0.00% <0.00%> (-100.00%) ⬇️
pkg/agent/controller/networkpolicy/packetin.go 4.50% <0.00%> (-67.50%) ⬇️
pkg/apis/controlplane/v1beta2/helper.go 33.33% <0.00%> (-66.67%) ⬇️
...formers/externalversions/security/v1alpha1/tier.go 0.00% <0.00%> (-64.29%) ⬇️
...ers/externalversions/core/v1alpha2/clustergroup.go 0.00% <0.00%> (-64.29%) ⬇️
...s/externalversions/core/v1alpha2/externalentity.go 0.00% <0.00%> (-64.29%) ⬇️
...xternalversions/security/v1alpha1/networkpolicy.go 0.00% <0.00%> (-64.29%) ⬇️
...versions/security/v1alpha1/clusternetworkpolicy.go 0.00% <0.00%> (-64.29%) ⬇️
pkg/controller/networkpolicy/mutate.go 0.00% <0.00%> (-62.07%) ⬇️
.../agent/apiserver/handlers/networkpolicy/handler.go 0.00% <0.00%> (-58.34%) ⬇️
... and 85 more

}
// If no such neighbor exists, exit code will be 1 and RunCommand() returns error.
// Since Get-NetNeighbor ignores error, it should be ignored.
neighborsStr, _ := ps.RunCommand(cmd)
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand the comment. The first sentence says it will return error, but the second one says the error should be ignored?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If neighbor doesn't exist, it will return error but I don't think no such neighbor means error. So I suggest ignoring error. What do you think? And @wenyingd please share your idea.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Discussed with Wenying, now the code doesn't ignore error and checks if error contains "No matching MSFT_NetNeighbor objects"

@lzhecheng
Copy link
Contributor Author

/test-windows-proxyall-e2e

@lzhecheng
Copy link
Contributor Author

/test-all /test-windows-all

@lzhecheng
Copy link
Contributor Author

/test-conformance

@lzhecheng
Copy link
Contributor Author

@tnqn The tests are successful so please help merge the PR.

return err
}
return nil
return NewNetNeighbor(neighbor)
Copy link
Member

Choose a reason for hiding this comment

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

question: if the neighbor for the IP exists but the MAC or the stat doesn't match, can NewNetNeighbor override 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.

You're right. No, it says Instance MSFT_NetNeighbor already exist. I added a RemoveNetNeighbor before it.

if n.LinkLayerAddress.String() == neighbor.LinkLayerAddress.String() {
found = true
break
if n.LinkLayerAddress.String() == neighbor.LinkLayerAddress.String() && n.State == "Permanent" {
Copy link
Member

Choose a reason for hiding this comment

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

As a generic util, I think this should be:

Suggested change
if n.LinkLayerAddress.String() == neighbor.LinkLayerAddress.String() && n.State == "Permanent" {
if n.LinkLayerAddress.String() == neighbor.LinkLayerAddress.String() && n.State == neighbor.State {

And the callers should set the desired State

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea. Updated.

Stop ignoring Get-NetNeighbor's error and check if the error
message includes "No matching MSFT_NetNeighbor objects"

Signed-off-by: Zhecheng Li <[email protected]>
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 Oct 25, 2021

/test-all
/test-windows-all

@tnqn tnqn merged commit 7f9fb00 into antrea-io:main Oct 25, 2021
@lzhecheng lzhecheng deleted the win-fix-antreaproxy branch October 25, 2021 14:17
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.

3 participants