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 not dedup Priorities in batch register #1841

Merged
merged 1 commit into from
Feb 9, 2021

Conversation

Dyanngg
Copy link
Contributor

@Dyanngg Dyanngg commented Feb 8, 2021

When Antrea agent is restarted, all Antrea-native policy priorities will be registered in batch. On a specific Node, there can be a large number of Antrea-native policies of the same Tier and policy priority. Hence, the list of types.Priority to be registered can contain duplicates, but it is not correctly handled by the priorityAssigner. Hence, the resulting ofPriority for a specific policy Priority can be inconsistent between batch registration and individual registration. This PR fixes this issue.

@Dyanngg Dyanngg added this to the Antrea v0.13.0 release milestone Feb 8, 2021
@Dyanngg Dyanngg self-assigned this Feb 8, 2021
antoninbas
antoninbas previously approved these changes Feb 9, 2021
Copy link
Contributor

@antoninbas antoninbas left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines 307 to 315
assert.Equalf(t, nil, err, "Error occurred in priority registration")
_, _, err2 := pa2.RegisterPriorities(prioritiesToRegisterDuplicate)
assert.Equalf(t, nil, err2, "Error occurred in priority registration")
ofPriority1130, _ := pa1.GetOFPriority(p1130)
ofPriority1130Dup, _ := pa2.GetOFPriority(p1130)
assert.Equal(t, ofPriority1130, ofPriority1130Dup)
ofPriority1131, _ := pa1.GetOFPriority(p1131)
ofPriority1131Dup, _ := pa2.GetOFPriority(p1131)
assert.Equal(t, ofPriority1131, ofPriority1131Dup)
Copy link
Contributor

Choose a reason for hiding this comment

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

please use assert.NoError(t, err, ...) for errors

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed for the entire test file.

pkg/agent/controller/networkpolicy/priority.go Outdated Show resolved Hide resolved
Copy link
Contributor

@antoninbas antoninbas left a comment

Choose a reason for hiding this comment

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

LGTM

@Dyanngg
Copy link
Contributor Author

Dyanngg commented Feb 9, 2021

/test-all

@codecov-io
Copy link

Codecov Report

❗ No coverage uploaded for pull request base (main@abb6c33). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1841   +/-   ##
=======================================
  Coverage        ?   42.88%           
=======================================
  Files           ?      196           
  Lines           ?    16658           
  Branches        ?        0           
=======================================
  Hits            ?     7143           
  Misses          ?     8510           
  Partials        ?     1005           
Flag Coverage Δ
e2e-tests 42.88% <0.00%> (?)

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

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, thanks for fixing it.

@Dyanngg Dyanngg merged commit 9319930 into antrea-io:main Feb 9, 2021
@Dyanngg Dyanngg deleted the fix-dup-priority-batch-register branch February 9, 2021 04:10
antoninbas pushed a commit to antoninbas/antrea that referenced this pull request Feb 10, 2021
antoninbas pushed a commit to antoninbas/antrea that referenced this pull request Feb 10, 2021
antoninbas pushed a commit to antoninbas/antrea that referenced this pull request Feb 11, 2021
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.

5 participants