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

Support Antrea NetworkPolicy in Traceflow #1361

Merged
merged 1 commit into from
Nov 11, 2020
Merged

Conversation

gran-vmv
Copy link
Contributor

This PR added 3 major changes:

  1. Mirror existing Antrea NetworkPolicy drop flows with action=controller when running TF
  2. Collect drop table and rule when PacketIn
  3. Add dropFlag into ofFlow struct to identify if the flow contains drop action

This PR closes #1225

@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-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 Oct 12, 2020

Codecov Report

Merging #1361 (d3ec61b) into master (d1e0624) will decrease coverage by 13.01%.
The diff coverage is 71.42%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master    #1361       +/-   ##
===========================================
- Coverage   67.58%   54.56%   -13.02%     
===========================================
  Files         169      135       -34     
  Lines       13465    12508      -957     
===========================================
- Hits         9100     6825     -2275     
- Misses       3420     5046     +1626     
+ Partials      945      637      -308     
Flag Coverage Δ
integration-tests 45.64% <31.25%> (-0.09%) ⬇️
kind-e2e-tests ?
unit-tests 41.38% <63.26%> (-0.37%) ⬇️

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

Impacted Files Coverage Δ
pkg/agent/controller/traceflow/packetin.go 12.33% <57.57%> (-51.85%) ⬇️
pkg/agent/openflow/client.go 52.09% <100.00%> (-16.01%) ⬇️
pkg/ovs/openflow/ofctrl_action.go 91.30% <100.00%> (+0.08%) ⬆️
pkg/ovs/openflow/ofctrl_flow.go 75.00% <100.00%> (+5.18%) ⬆️
pkg/agent/agent_linux.go 0.00% <0.00%> (-100.00%) ⬇️
pkg/apis/controlplane/helper.go 0.00% <0.00%> (-100.00%) ⬇️
pkg/apis/controlplane/v1beta2/helper.go 0.00% <0.00%> (-100.00%) ⬇️
pkg/agent/proxy/types/groupcounter.go 0.00% <0.00%> (-95.00%) ⬇️
pkg/controller/networkpolicy/tier.go 0.00% <0.00%> (-90.00%) ⬇️
pkg/apis/controlplane/register.go 0.00% <0.00%> (-85.72%) ⬇️
... and 108 more

@gran-vmv gran-vmv added the status/WIP Work in progress label Oct 12, 2020
@gran-vmv gran-vmv force-pushed the tf-anp branch 5 times, most recently from 6df090b to 31f5a8a Compare October 14, 2020 09:54
Copy link
Contributor

@jianjuns jianjuns left a comment

Choose a reason for hiding this comment

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

LGTM

pkg/agent/openflow/client.go Show resolved Hide resolved
jianjuns
jianjuns previously approved these changes Oct 29, 2020
Copy link
Contributor

@jianjuns jianjuns left a comment

Choose a reason for hiding this comment

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

The change LGTM. But hope @wenyingd can review too.

pkg/agent/openflow/pipeline.go Outdated Show resolved Hide resolved
pkg/agent/openflow/pipeline.go Outdated Show resolved Hide resolved
@@ -738,6 +738,7 @@ func (c *client) InstallTraceflowFlows(dataplaneTag uint8) error {
flows := []binding.Flow{}
c.conjMatchFlowLock.Lock()
defer c.conjMatchFlowLock.Unlock()
// Copy default drop rules
for _, ctx := range c.globalConjMatchFlowCache {
if ctx.dropFlow != nil {
flows = append(
Copy link
Contributor

Choose a reason for hiding this comment

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

Having discussion with @weiqiangt , after metric flow is introduced, the actual "drop" action should happen in the XgressMetricTable, so I think we could add traceflow only in XgressMetricTable with the flow having "dropFlag". Otherwise, the flow in the default drop table is useless.

Copy link
Contributor

Choose a reason for hiding this comment

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

Think over, as metricflow doesn't record from which policy table the packet is resubmitted in, does it affect the result of Traceflow? I mean we actually want to report that the packet is dropped by K8s Policy Rule or Antrea Policy Rule, but it seems the current implementation would report the packet is dropped by MetricTable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will the K8s NetworkPolicy use default drop table?
I think Traceflow need to mock all NetworkPolicy flows with "drop" action, including default drop flow for K8s NetworkPolicy and XgressMetricTable for Antrea NetworkPolicy.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can identify this by the prefix in networkPolicy property. This function is added by @tnqn
Here is my test result:

  status:
    phase: Succeeded
    results:
    - node: gran-k8s0-2
      observations:
      - action: Forwarded
        component: SpoofGuard
      - action: Forwarded
        component: NetworkPolicy
        componentInfo: EgressRule
        networkPolicy: AntreaNetworkPolicy:default/test-anp
      - action: Dropped
        component: NetworkPolicy
        componentInfo: IngressMetric
        networkPolicy: AntreaNetworkPolicy:default/test-anp
      timestamp: 1603965404

@gran-vmv gran-vmv force-pushed the tf-anp branch 2 times, most recently from 9ee4873 to 0bdc543 Compare November 3, 2020 01:44
@abhiraut
Copy link
Contributor

abhiraut commented Nov 4, 2020

can we target this for 0.11 release?

@gran-vmv gran-vmv added this to the Antrea v0.11.0 release milestone Nov 5, 2020
@gran-vmv
Copy link
Contributor Author

gran-vmv commented Nov 6, 2020

can we target this for 0.11 release?

Yes, this is for 0.11 release.

@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).

@gran-vmv gran-vmv force-pushed the tf-anp branch 3 times, most recently from d8065ef to a653390 Compare November 11, 2020 01:33
@gran-vmv
Copy link
Contributor Author

/test-all

@gran-vmv gran-vmv merged commit 6c1a913 into antrea-io:master Nov 11, 2020
@gran-vmv gran-vmv deleted the tf-anp branch January 21, 2021 09:09
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.

Support CNP in Traceflow
8 participants