Skip to content

NETOBSERV-1617: use filter with packets capture feature#54

Merged
openshift-merge-bot[bot] merged 1 commit intonetobserv:mainfrom
msherif1234:update-pcap
Jun 28, 2024
Merged

NETOBSERV-1617: use filter with packets capture feature#54
openshift-merge-bot[bot] merged 1 commit intonetobserv:mainfrom
msherif1234:update-pcap

Conversation

@msherif1234
Copy link
Copy Markdown
Contributor

@msherif1234 msherif1234 commented Jun 26, 2024

Description

add filter capability for pca feature
Example from running on Kind cluster

  • build commands locally and use agent custom image
NETOBSERV_AGENT_IMAGE=quay.io/netobserv/netobserv-ebpf-agent:f525832 ./build/oc-netobserv packets --protocol="TCP" --port=443

output pcap

tcpdump -r 2024-06-27T110645Z.pcap 
reading from file 2024-06-27T110645Z.pcap, link-type EN10MB (Ethernet), snapshot length 262144
07:06:57.502363 IP 172.18.0.3.41396 > ec2-52-204-93-25.compute-1.amazonaws.com.https: Flags [P.], seq 2078794407:2078794438, ack 1312010586, win 458, options [nop,nop,TS val 3614985982 ecr 3018431589], length 31
07:06:57.502422 IP 172.18.0.3.41396 > ec2-52-204-93-25.compute-1.amazonaws.com.https: Flags [F.], seq 31, ack 1, win 458, options [nop,nop,TS val 3614985982 ecr 3018431589], length 0
07:06:57.531353 IP ec2-52-204-93-25.compute-1.amazonaws.com.https > 172.18.0.3.41396: Flags [.], ack 31, win 114, options [nop,nop,TS val 3018461620 ecr 3614985982], length 0
07:06:57.531372 IP ec2-52-204-93-25.compute-1.amazonaws.com.https > 172.18.0.3.41396: Flags [F.], seq 1, ack 32, win 114, options [nop,nop,TS val 3018461620 ecr 3614985982], length 0
07:06:57.531381 IP 172.18.0.3.41396 > ec2-52-204-93-25.compute-1.amazonaws.com.https: Flags [.], ack 2, win 458, options [nop,nop,TS val 3614986011 ecr 3018461620], length 0
07:06:58.819363 IP 172.18.0.3.37132 > ec2-44-216-66-253.compute-1.amazonaws.com.https: Flags [P.], seq 1277682538:1277682569, ack 1218593254, win 461, options [nop,nop,TS val 1795579274 ecr 783897356], length 31

Dependencies

netobserv/netobserv-ebpf-agent#359

Checklist

If you are not familiar with our processes or don't know what to answer in the list below, let us know in a comment: the maintainers will take care of that.

  • Is this PR backed with a JIRA ticket? If so, make sure it is written as a title prefix (in general, PRs affecting the NetObserv/Network Observability product should be backed with a JIRA ticket - especially if they bring user facing changes).
  • Does this PR require product documentation?
    • If so, make sure the JIRA epic is labelled with "documentation" and provides a description relevant for doc writers, such as use cases or scenarios. Any required step to activate or configure the feature should be documented there, such as new CRD knobs.
  • Does this PR require a product release notes entry?
    • If so, fill in "Release Note Text" in the JIRA.
  • Is there anything else the QE team should know before testing? E.g: configuration changes, environment setup, etc.
    • If so, make sure it is described in the JIRA ticket.
  • QE requirements (check 1 from the list):
    • Standard QE validation, with pre-merge tests unless stated otherwise.
    • Regression tests only (e.g. refactoring with no user-facing change).
    • No QE (e.g. trivial change with high reviewer's confidence, or per agreement with the QE team).

@openshift-ci-robot
Copy link
Copy Markdown
Collaborator

openshift-ci-robot commented Jun 26, 2024

@msherif1234: This pull request references NETOBSERV-1617 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.17.0" version, but no target version was set.

Details

In response to this:

Description

add filter capability for pca feature

Dependencies

netobserv/netobserv-ebpf-agent#359

Checklist

If you are not familiar with our processes or don't know what to answer in the list below, let us know in a comment: the maintainers will take care of that.

  • Is this PR backed with a JIRA ticket? If so, make sure it is written as a title prefix (in general, PRs affecting the NetObserv/Network Observability product should be backed with a JIRA ticket - especially if they bring user facing changes).
  • Does this PR require product documentation?
  • If so, make sure the JIRA epic is labelled with "documentation" and provides a description relevant for doc writers, such as use cases or scenarios. Any required step to activate or configure the feature should be documented there, such as new CRD knobs.
  • Does this PR require a product release notes entry?
  • If so, fill in "Release Note Text" in the JIRA.
  • Is there anything else the QE team should know before testing? E.g: configuration changes, environment setup, etc.
  • If so, make sure it is described in the JIRA ticket.
  • QE requirements (check 1 from the list):
  • Standard QE validation, with pre-merge tests unless stated otherwise.
  • Regression tests only (e.g. refactoring with no user-facing change).
  • No QE (e.g. trivial change with high reviewer's confidence, or per agreement with the QE team).

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@codecov
Copy link
Copy Markdown

codecov bot commented Jun 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 28.99%. Comparing base (88ad0cb) to head (8a46886).

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #54   +/-   ##
=======================================
  Coverage   28.99%   28.99%           
=======================================
  Files           8        8           
  Lines        1045     1045           
=======================================
  Hits          303      303           
  Misses        720      720           
  Partials       22       22           
Flag Coverage Δ
unittests 28.99% <ø> (ø)

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

Comment on lines +218 to +285
for option in $options; do
key="${option%%=*}"
value="${option#*=}"
case "$key" in
--enable_pca) # Enable packet capture agent
if [[ "$value" == "true" || "$value" == "false" ]]; then
edit_manifest "pca_enable" "$value" "$manifest"
else
echo "invalid value for --pca_enable"
fi
;;
--direction) # Configure filter direction
if [[ "$value" == "Ingress" || "$value" == "Egress" ]]; then
edit_manifest "filter_direction" "$value" "$manifest"
else
echo "invalid value for --direction"
fi
;;
--cidr) # Configure filter CIDR
edit_manifest "filter_cidr" "$value" "$manifest"
;;
--protocol) # Configure filter protocol
if [[ "$value" == "TCP" || "$value" == "UDP" || "$value" == "SCTP" || "$value" == "ICMP" || "$value" == "ICMPv6" ]]; then
edit_manifest "filter_protocol" "$value" "$manifest"
else
echo "invalid value for --protocol"
fi
;;
--sport) # Configure filter source port
edit_manifest "filter_sport" "$value" "$manifest"
;;
--dport) # Configure filter destination port
edit_manifest "filter_dport" "$value" "$manifest"
;;
--port) # Configure filter port
edit_manifest "filter_port" "$value" "$manifest"
;;
--sport_range) # Configure filter source port range
edit_manifest "filter_sport_range" "$value" "$manifest"
;;
--dport_range) # Configure filter destination port range
edit_manifest "filter_dport_range" "$value" "$manifest"
;;
--port_range) # Configure filter port range
edit_manifest "filter_port_range" "$value" "$manifest"
;;
--icmp_type) # ICMP type
edit_manifest "filter_icmp_type" "$value" "$manifest"
;;
--icmp_code) # ICMP code
edit_manifest "filter_icmp_code" "$value" "$manifest"
;;
--peer_ip) # Peer IP
edit_manifest "filter_peer_ip" "$value" "$manifest"
;;
--action) # Filter action
if [[ "$value" == "Accept" || "$value" == "Reject" ]]; then
edit_manifest "filter_action" "$value" "$manifest"
else
echo "invalid value for --action"
fi
;;
*) # Invalid option
echo "Invalid option: $key" >&2
exit 1
;;
esac
done
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can't we merge that loop in a single function to avoid code duplicate ?

We can add check for options not available in both flows / packets commands stopping the script

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ok will gen common function

Comment on lines +222 to +228
--enable_pca) # Enable packet capture agent
if [[ "$value" == "true" || "$value" == "false" ]]; then
edit_manifest "pca_enable" "$value" "$manifest"
else
echo "invalid value for --pca_enable"
fi
;;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not sure to get the point of this option.

To run a packet capture, the user is supposed to type oc netobserv packets right ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes the above default is true the only use of this as way to disable pca which I don’t see a use for it in production see the new doc

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I will drop this option

@openshift-ci-robot
Copy link
Copy Markdown
Collaborator

openshift-ci-robot commented Jun 27, 2024

@msherif1234: This pull request references NETOBSERV-1617 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.17.0" version, but no target version was set.

Details

In response to this:

Description

add filter capability for pca feature
Example from running on Kind cluster

  • build commands locally and use agent custom image
NETOBSERV_AGENT_IMAGE=quay.io/netobserv/netobserv-ebpf-agent:f525832 ./build/oc-netobserv packets --protocol="TCP" --port=443

output pcap

tcpdump -r 2024-06-27T110645Z.pcap 
reading from file 2024-06-27T110645Z.pcap, link-type EN10MB (Ethernet), snapshot length 262144
07:06:57.502363 IP 172.18.0.3.41396 > ec2-52-204-93-25.compute-1.amazonaws.com.https: Flags [P.], seq 2078794407:2078794438, ack 1312010586, win 458, options [nop,nop,TS val 3614985982 ecr 3018431589], length 31
07:06:57.502422 IP 172.18.0.3.41396 > ec2-52-204-93-25.compute-1.amazonaws.com.https: Flags [F.], seq 31, ack 1, win 458, options [nop,nop,TS val 3614985982 ecr 3018431589], length 0
07:06:57.531353 IP ec2-52-204-93-25.compute-1.amazonaws.com.https > 172.18.0.3.41396: Flags [.], ack 31, win 114, options [nop,nop,TS val 3018461620 ecr 3614985982], length 0
07:06:57.531372 IP ec2-52-204-93-25.compute-1.amazonaws.com.https > 172.18.0.3.41396: Flags [F.], seq 1, ack 32, win 114, options [nop,nop,TS val 3018461620 ecr 3614985982], length 0
07:06:57.531381 IP 172.18.0.3.41396 > ec2-52-204-93-25.compute-1.amazonaws.com.https: Flags [.], ack 2, win 458, options [nop,nop,TS val 3614986011 ecr 3018461620], length 0
07:06:58.819363 IP 172.18.0.3.37132 > ec2-44-216-66-253.compute-1.amazonaws.com.https: Flags [P.], seq 1277682538:1277682569, ack 1218593254, win 461, options [nop,nop,TS val 1795579274 ecr 783897356], length 31

Dependencies

netobserv/netobserv-ebpf-agent#359

Checklist

If you are not familiar with our processes or don't know what to answer in the list below, let us know in a comment: the maintainers will take care of that.

  • Is this PR backed with a JIRA ticket? If so, make sure it is written as a title prefix (in general, PRs affecting the NetObserv/Network Observability product should be backed with a JIRA ticket - especially if they bring user facing changes).
  • Does this PR require product documentation?
  • If so, make sure the JIRA epic is labelled with "documentation" and provides a description relevant for doc writers, such as use cases or scenarios. Any required step to activate or configure the feature should be documented there, such as new CRD knobs.
  • Does this PR require a product release notes entry?
  • If so, fill in "Release Note Text" in the JIRA.
  • Is there anything else the QE team should know before testing? E.g: configuration changes, environment setup, etc.
  • If so, make sure it is described in the JIRA ticket.
  • QE requirements (check 1 from the list):
  • Standard QE validation, with pre-merge tests unless stated otherwise.
  • Regression tests only (e.g. refactoring with no user-facing change).
  • No QE (e.g. trivial change with high reviewer's confidence, or per agreement with the QE team).

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

Copy link
Copy Markdown
Member

@jpinsonneau jpinsonneau left a comment

Choose a reason for hiding this comment

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

Code looks good, thanks @msherif1234 !

@Amoghrd
Copy link
Copy Markdown
Member

Amoghrd commented Jun 28, 2024

/ok-to-test

@github-actions
Copy link
Copy Markdown

New image:
quay.io/netobserv/network-observability-cli:2fd8052

It will expire after two weeks.

To use this build, update your commands using:

USER=netobserv VERSION=2fd8052 make commands

@msherif1234
Copy link
Copy Markdown
Contributor Author

/retest

@openshift-ci
Copy link
Copy Markdown

openshift-ci bot commented Jun 28, 2024

New changes are detected. LGTM label has been removed.

@msherif1234
Copy link
Copy Markdown
Contributor Author

fixed the help strings to match with the new pca fmt for e2e to pass

Signed-off-by: Mohamed Mahmoud <mmahmoud@redhat.com>
@openshift-ci openshift-ci bot removed the lgtm label Jun 28, 2024
@openshift-ci
Copy link
Copy Markdown

openshift-ci bot commented Jun 28, 2024

New changes are detected. LGTM label has been removed.

@openshift-ci
Copy link
Copy Markdown

openshift-ci bot commented Jun 28, 2024

[APPROVALNOTIFIER] This PR is APPROVED

Approval requirements bypassed by manually added approval.

This pull-request has been approved by:

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot bot merged commit 488e1d5 into netobserv:main Jun 28, 2024
@Amoghrd
Copy link
Copy Markdown
Member

Amoghrd commented Jun 28, 2024

Was this also meant to be no-qe? If not, why was it merged prior to testing?

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.

4 participants