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 Traceflow of live traffic #2005

Merged
merged 1 commit into from
Apr 4, 2021
Merged

Conversation

jianjuns
Copy link
Contributor

@jianjuns jianjuns commented Mar 29, 2021

Add support of tracing live traffic. Rather than injecting a Traceflow
packet, a live traffic Traceflow will trace the real traffic between
Pods - the first packet of the first connection that matches the
Traceflow spec will be traced.
antctl traceflow command is extended to support live traffic Traceflow.
This commit also makes a few others changes to Traceflow: change
Destination (live traffic Traceflow does not require Traceflow
Destination to be provided), Packet, and Packet IPHeader in Traceflow
Spec to optional fields; add a Timeout parameter to Traceflow Spec and
antctl traceflow command to specify the timeout time of a Traceflow;
delete OVS flows added for the Traceflow after agent receives the first
captured packet of the Traceflow; support all IP protocols.

Issue: #2030

@jianjuns
Copy link
Contributor Author

I still need to add e2e test, and fix the OVS packet_out error for regular Traceflow (at least in my env).

@antoninbas : I plan to add reporting the captured packet headers after this PR.

pkg/ovs/openflow/ofctrl_builder.go Show resolved Hide resolved
pkg/antctl/raw/traceflow/command.go Show resolved Hide resolved
pkg/antctl/raw/traceflow/command.go Outdated Show resolved Hide resolved
pkg/antctl/raw/traceflow/command.go Show resolved Hide resolved
@jianjuns jianjuns force-pushed the tf-live branch 4 times, most recently from c1e780d to d74ca64 Compare March 29, 2021 16:59
@codecov-io
Copy link

codecov-io commented Mar 29, 2021

Codecov Report

Merging #2005 (5dfa3c8) into main (81041c2) will increase coverage by 1.07%.
The diff coverage is 58.91%.

❗ Current head 5dfa3c8 differs from pull request most recent head 847aad3. Consider uploading reports for the commit 847aad3 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2005      +/-   ##
==========================================
+ Coverage   61.83%   62.91%   +1.07%     
==========================================
  Files         262      262              
  Lines       19473    19560      +87     
==========================================
+ Hits        12042    12307     +265     
+ Misses       6176     5983     -193     
- Partials     1255     1270      +15     
Flag Coverage Δ
e2e-tests 25.29% <0.63%> (?)
kind-e2e-tests 53.35% <66.24%> (+0.01%) ⬆️
unit-tests 41.47% <21.35%> (-0.38%) ⬇️

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

Impacted Files Coverage Δ
pkg/ovs/openflow/ofctrl_builder.go 56.46% <0.00%> (-0.12%) ⬇️
pkg/ovs/openflow/ofctrl_packetout.go 86.09% <0.00%> (-2.69%) ⬇️
pkg/antctl/raw/traceflow/command.go 26.33% <12.50%> (-0.72%) ⬇️
...agent/controller/traceflow/traceflow_controller.go 72.97% <64.74%> (-2.13%) ⬇️
pkg/agent/openflow/pipeline.go 73.22% <75.00%> (+2.58%) ⬆️
pkg/agent/controller/traceflow/packetin.go 60.48% <80.00%> (+1.00%) ⬆️
pkg/agent/openflow/client.go 60.37% <87.87%> (-3.29%) ⬇️
pkg/controller/traceflow/controller.go 70.06% <100.00%> (+0.58%) ⬆️
pkg/ovs/openflow/ofctrl_action.go 68.37% <100.00%> (+20.73%) ⬆️
pkg/ipfix/ipfix_process.go 81.81% <0.00%> (-18.19%) ⬇️
... and 19 more

pkg/agent/controller/traceflow/packetin.go Show resolved Hide resolved
pkg/agent/controller/traceflow/packetin.go Outdated Show resolved Hide resolved
pkg/agent/controller/traceflow/packetin.go Show resolved Hide resolved
Comment on lines -50 to -51
type icmpType uint8
type icmpCode uint8
Copy link
Contributor

Choose a reason for hiding this comment

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

why the change?

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 do not define a type for all other fields (IPFlags, TCPFlags, ICMPEchoSequence, IPProtocol, TPPort, etc.), I do not see why we define a type just for these three (and convert to uint8 later).

pkg/agent/controller/traceflow/traceflow_controller.go Outdated Show resolved Hide resolved
pkg/agent/controller/traceflow/traceflow_controller.go Outdated Show resolved Hide resolved
pkg/agent/openflow/client.go Outdated Show resolved Hide resolved
pkg/apis/ops/v1alpha1/types.go Outdated Show resolved Hide resolved
Source Source `json:"source,omitempty"`
Destination *Destination `json:"destination,omitempty"`
Packet *Packet `json:"packet,omitempty"`
// LiveTraffic indicates the Traceflow is to trace the live traffic
Copy link
Contributor

Choose a reason for hiding this comment

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

I am curious about what your plan is to report header values in the captured packet in the future. Do you have an idea already of how TraceflowStatus will change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I plan to add a struct called CapturedPacket to TraceflowStatus.

pkg/apis/ops/v1alpha1/types.go Outdated Show resolved Hide resolved
@jianjuns jianjuns force-pushed the tf-live branch 6 times, most recently from 215bc7f to b1371d5 Compare March 30, 2021 18:53
@jianjuns
Copy link
Contributor Author

I reverted the Traceflow API change of making Destination and Packet optional. Also added e2e tests for live-traffic Traceflow. But still need to fix inter-node e2e test failures.

@jianjuns
Copy link
Contributor Author

/test-e2e

@antoninbas antoninbas added this to the Antrea v1.0 release milestone Mar 30, 2021
@jianjuns jianjuns force-pushed the tf-live branch 4 times, most recently from cb9e005 to f40d2d8 Compare March 31, 2021 05:07
@jianjuns jianjuns changed the title Support Traceflow of live traffic WIP: Support Traceflow of live traffic Mar 31, 2021
@jianjuns
Copy link
Contributor Author

Debugging Kind e2e test failure..

@jianjuns jianjuns force-pushed the tf-live branch 2 times, most recently from 64bb112 to 14f1389 Compare March 31, 2021 05:57
@jianjuns jianjuns force-pushed the tf-live branch 4 times, most recently from f5f7d38 to be06e04 Compare April 1, 2021 16:07
@jianjuns jianjuns changed the title WIP: Support Traceflow of live traffic Support Traceflow of live traffic Apr 1, 2021
@jianjuns jianjuns force-pushed the tf-live branch 4 times, most recently from 9d38ad8 to 929c9eb Compare April 2, 2021 15:39
tnqn
tnqn previously approved these changes Apr 2, 2021
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, just two format issues.

pkg/agent/openflow/client.go Outdated Show resolved Hide resolved
pkg/agent/openflow/pipeline.go Outdated Show resolved Hide resolved
tnqn
tnqn previously approved these changes Apr 2, 2021
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

@jianjuns
Copy link
Contributor Author

jianjuns commented Apr 3, 2021

/test-all

@jianjuns jianjuns closed this Apr 3, 2021
@jianjuns jianjuns reopened this Apr 3, 2021
@jianjuns
Copy link
Contributor Author

jianjuns commented Apr 3, 2021

/test-all

tnqn
tnqn previously approved these changes Apr 3, 2021
Add support of tracing live traffic. Rather than injecting a Traceflow
packet, a live traffic Traceflow will trace the real traffic between
Pods - the first packet of the first connection that matches the
Traceflow spec will be traced.
antctl traceflow command is extended to support live traffic Traceflow.
This commit also makes a few others changes to Traceflow: add a
Timeout parameter to Traceflow Spec and antctl traceflow command to
specify the timeout time of a Traceflow; delete OVS flows added for the
Traceflow after agent receives the first captured packet of the
Traceflow; support all IP protocol.
@jianjuns
Copy link
Contributor Author

jianjuns commented Apr 3, 2021

/test-all

@jianjuns
Copy link
Contributor Author

jianjuns commented Apr 4, 2021

/test-networkpolicy

@jianjuns jianjuns merged commit 780cae0 into antrea-io:main Apr 4, 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.

7 participants