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

Remove the pod reference in v1beta1 AddressGroup #1586

Merged
merged 1 commit into from
Nov 20, 2020

Conversation

tnqn
Copy link
Member

@tnqn tnqn commented Nov 20, 2020

To be backwards compatible, AddressGroup v1beta1 must not include
PodReferences in its members, otherwise the agents that use v1beta1 will
think the members have changed and will add new IPs to the openflow
entries of relevant NetworkPolicies and delete old IPs from them, while
the old IPs and new IPs are actually the same. In current
implementation, deleting old IPs is executed after adding new IPs, so it
leads to some IPs missing in the openflow entries.

Fixes #1587

@antrea-bot
Copy link
Collaborator

Thanks for your PR.
Unit tests and code linters are run automatically every time the PR is updated.
E2e, conformance and network policy tests can only be triggered by a member of the vmware-tanzu organization. Regular contributors to the project should join the org.

The following commands are available:

  • /test-e2e: to trigger e2e tests.
  • /skip-e2e: to skip e2e tests.
  • /test-conformance: to trigger conformance tests.
  • /skip-conformance: to skip conformance tests.
  • /test-all-features-conformance: to trigger conformance tests with all alpha features enabled.
  • /skip-all-features-conformance: to skip conformance tests with all alpha features enabled.
  • /test-whole-conformance: to trigger all conformance tests on linux.
  • /skip-whole-conformance: to skip all conformance tests on linux.
  • /test-networkpolicy: to trigger networkpolicy tests.
  • /skip-networkpolicy: to skip networkpolicy tests.
  • /test-windows-conformance: to trigger windows conformance tests.
  • /skip-windows-conformance: to skip windows conformance tests.
  • /test-windows-networkpolicy: to trigger windows networkpolicy tests.
  • /skip-windows-networkpolicy: to skip windows networkpolicy tests.
  • /test-hw-offload: to trigger ovs hardware offload test.
  • /skip-hw-offload: to skip ovs hardware offload test.
  • /test-all: to trigger all tests (except whole conformance).
  • /skip-all: to skip all tests (except whole conformance).

@codecov-io
Copy link

codecov-io commented Nov 20, 2020

Codecov Report

Merging #1586 (66c523a) into master (9d3d10b) will increase coverage by 0.69%.
The diff coverage is 52.94%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1586      +/-   ##
==========================================
+ Coverage   63.31%   64.01%   +0.69%     
==========================================
  Files         170      181      +11     
  Lines       14250    15556    +1306     
==========================================
+ Hits         9023     9958     +935     
- Misses       4292     4547     +255     
- Partials      935     1051     +116     
Flag Coverage Δ
e2e-tests 45.81% <35.79%> (?)
kind-e2e-tests 52.70% <45.37%> (-2.68%) ⬇️
unit-tests 40.44% <16.48%> (-0.84%) ⬇️

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

Impacted Files Coverage Δ
cmd/antrea-agent/agent.go 0.00% <0.00%> (ø)
cmd/antrea-agent/options.go 21.69% <0.00%> (+0.97%) ⬆️
pkg/agent/config/node_config.go 100.00% <ø> (ø)
pkg/agent/stats/collector.go 97.72% <ø> (ø)
pkg/controller/networkpolicy/tier.go 90.00% <ø> (ø)
pkg/features/antrea_features.go 16.66% <ø> (ø)
pkg/ovs/openflow/ofctrl_builder.go 60.58% <0.00%> (-1.59%) ⬇️
pkg/ovs/openflow/ofctrl_group.go 48.57% <0.00%> (-4.56%) ⬇️
pkg/ovs/openflow/ofctrl_action.go 68.90% <17.14%> (+7.55%) ⬆️
pkg/agent/proxy/proxier_linux.go 33.33% <33.33%> (+8.33%) ⬆️
... and 70 more

@tnqn
Copy link
Member Author

tnqn commented Nov 20, 2020

/test-all

@tnqn
Copy link
Member Author

tnqn commented Nov 20, 2020

/test-all

@tnqn
Copy link
Member Author

tnqn commented Nov 20, 2020

/test-windows-conformance

@tnqn tnqn force-pushed the v1beta1-revert branch 2 times, most recently from 39fd4b8 to 83891c4 Compare November 20, 2020 15:49
@tnqn
Copy link
Member Author

tnqn commented Nov 20, 2020

/test-all

To be backwards compatible, AddressGroup v1beta1 must not include
PodReferences in its members, otherwise the agents that use v1beta1 will
think the members have changed and will add new IPs to the openflow
entries of relevant NetworkPolicies and delete old IPs from them, while
the old IPs and new IPs are actually the same. In current
implementation, deleting old IPs is executed after adding new IPs, so it
leads to some IPs missing in the openflow entries.
if err = data.deleteNetworkpolicy(np); err != nil {
t.Fatalf("Error when deleting network policy: %v", err)
}
}()
})
time.Sleep(networkPolicyDelay)
Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure if it's changing the podSelector to "MatchExpressions" caused the networkpolicy takes a little more time to realize. The test now has a chance to fail without the sleep, I can confirm it's not because of the conversion function change as it also failed when I just changed the test code in this PR: https://github.com/vmware-tanzu/antrea/runs/1431829031?check_suite_focus=true

@tnqn
Copy link
Member Author

tnqn commented Nov 20, 2020

/test-all

@antoninbas
Copy link
Contributor

/test-e2e

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 - I will merge if it passes the test and kick off the v0.11.1 release process

// conversion is called for an AddressGroup as agents don't expect it in v1beta1 version.
// This function doesn't match the pattern of conversion function which requires the last parameter to be
// conversion.Scope so won't be registered to schema.
func Convert_controlplane_GroupMember_To_v1beta1_GroupMemberPod(in *controlplane.GroupMember, out *GroupMemberPod, includePodRef bool) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

could have been a private function?

Copy link
Member Author

Choose a reason for hiding this comment

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

Definitely can be private, I kept its name as it was as code in this file doesn't follow normal go style anyway.
Do you prefer it to be private?

Comment on lines +132 to +133
// This function doesn't match the pattern of conversion function which requires the last parameter to be
// conversion.Scope so won't be registered to schema.
Copy link
Contributor

Choose a reason for hiding this comment

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

BTW, is there any advantage to having conversion functions for non resources registered to the schema? I understand why Convert_controlplane_AddressGroup_To_v1beta1_AddressGroup needs to be registered, but it seems conversion functions for non resources will only be called indirectly by other conversion functions. Is it for auto-generated conversion functions?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good question, I wondered this as well, haven't found answer so blindly followed what K8s code does.
I can take a look what it would affect later and see if we could remove them. Created #1616 to track it.

@antoninbas antoninbas merged commit 87039c0 into antrea-io:master Nov 20, 2020
antoninbas pushed a commit to antoninbas/antrea that referenced this pull request Nov 20, 2020
To be backwards compatible, AddressGroup v1beta1 must not include
PodReferences in its members, otherwise the agents that use v1beta1 will
think the members have changed and will add new IPs to the openflow
entries of relevant NetworkPolicies and delete old IPs from them, while
the old IPs and new IPs are actually the same. In current
implementation, deleting old IPs is executed after adding new IPs, so it
leads to some IPs missing in the openflow entries.

Fixes antrea-io#1587
antoninbas pushed a commit that referenced this pull request Nov 21, 2020
To be backwards compatible, AddressGroup v1beta1 must not include
PodReferences in its members, otherwise the agents that use v1beta1 will
think the members have changed and will add new IPs to the openflow
entries of relevant NetworkPolicies and delete old IPs from them, while
the old IPs and new IPs are actually the same. In current
implementation, deleting old IPs is executed after adding new IPs, so it
leads to some IPs missing in the openflow entries.

Fixes #1587
antoninbas pushed a commit that referenced this pull request Dec 23, 2020
To be backwards compatible, AddressGroup v1beta1 must not include
PodReferences in its members, otherwise the agents that use v1beta1 will
think the members have changed and will add new IPs to the openflow
entries of relevant NetworkPolicies and delete old IPs from them, while
the old IPs and new IPs are actually the same. In current
implementation, deleting old IPs is executed after adding new IPs, so it
leads to some IPs missing in the openflow entries.

Fixes #1587
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NetworkPolicy are not enforced correctly during upgrade
5 participants