Repository navigation
NETOBSERV-3036: Rewrite plugin in Golang and reorganize collector packages - #605
jpinsonneau wants to merge 7 commits into
Conversation
d4b194a to
2019279
Compare
|
@jpinsonneau: This pull request references NETOBSERV-3036 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 "5.1.0" version, but no target version was set. DetailsIn response to this:
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. |
b0b652c to
8649969
Compare
|
New image: quay.io/netobserv/network-observability-cli:86499694It will expire in two weeks. To use this build, update your commands using: USER=netobserv VERSION=86499694 make commands |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #605 +/- ##
===========================================
+ Coverage 35.05% 46.78% +11.72%
===========================================
Files 29 93 +64
Lines 4082 5966 +1884
===========================================
+ Hits 1431 2791 +1360
- Misses 2498 2892 +394
- Partials 153 283 +130
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
926a69c to
8649969
Compare
9219616 to
a8e8f46
Compare
|
@jpinsonneau: No Jira issue is referenced in the title of this pull request. DetailsIn response to this:
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. |
|
@jpinsonneau: This pull request references NETOBSERV-3036 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 "5.1.0" version, but no target version was set. DetailsIn response to this:
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. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
86b5f10 to
6d058e7
Compare
|
@jpinsonneau: The following test failed, say
Full PR test history. Your PR dashboard. DetailsInstructions 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 kubernetes-sigs/prow repository. I understand the commands that are listed here. |
ca83448 to
16788e0
Compare
|
New image: quay.io/netobserv/network-observability-cli:b52d4de0It will expire in two weeks. To use this build, update your commands using: USER=netobserv VERSION=b52d4de0 make commands |
b52d4de to
5955236
Compare
Signed-off-by: Julien Pinsonneau <jpinsonn@redhat.com>
Signed-off-by: Julien Pinsonneau <jpinsonn@redhat.com>
Signed-off-by: Julien Pinsonneau <jpinsonn@redhat.com>
Signed-off-by: Julien Pinsonneau <jpinsonn@redhat.com>
Signed-off-by: Julien Pinsonneau <jpinsonn@redhat.com>
7199ed6 to
228bad0
Compare
|
New image: quay.io/netobserv/network-observability-cli:228bad0aIt will expire in two weeks. To use this build, update your commands using: USER=netobserv VERSION=228bad0a make commands |
leandroberetta
left a comment
There was a problem hiding this comment.
Thanks @jpinsonneau ! I did a first review, I left some comments below.
| startFlowCollector() | ||
| return | ||
| } | ||
| go startFlowCollector() |
There was a problem hiding this comment.
When pressing Ctrl+C, the UI stops and this function returns while the flow collector is still running. That leaves the JSON file without its closing ], since the collector doesn’t get to run its deferred cleanup. I tried it locally and could reproduce it consistently.
Could we stop the collector and wait for it to finish writing and close its files before returning here?
There was a problem hiding this comment.
Ctrl+C: Fixed; shutdown now stops the collector and waits for JSON/DB cleanup before returning.
| } | ||
|
|
||
| // EnablePacketDrops replaces the --enable_pkt_drop branch of parse_args (privileged + env var). | ||
| func (b *Builder) EnablePacketDrops() { |
There was a problem hiding this comment.
These feature methods enable the environment variables, but the corresponding host mounts seem to be missing. Packet drops need /sys/kernel/debug, and network events and UDN mapping need the OVN/OVS directories.
The shared builder adds those mounts when it receives the features, but we currently create the DaemonSet without them. Could we pass the enabled features to the shared builder, or add the required mounts here?
There was a problem hiding this comment.
Added idempotent mounts for debugfs, OVN/OVS, and network namespaces.
| }, | ||
| } | ||
| if openShift { | ||
| scc := &securityv1.SecurityContextConstraints{ |
There was a problem hiding this comment.
Does this SCC need to allow hostPID and SYS_PTRACE for OpenSSL captures? --enable_openssl requests both, but they aren't allowed here.
There was a problem hiding this comment.
Added hostPID and SYS_PTRACE. Thanks !
| return err | ||
| } | ||
| if capOpts.outputYAML { | ||
| printYAMLInstructions(r.out, kind) |
There was a problem hiding this comment.
The generated file includes the agents and collector Service, but no collector Pod, I think we need to add the pod creation too.
There was a problem hiding this comment.
YAML output now includes a collector Pod manifest.
| // Flow-filter flags (--protocol, --port, ...) and the bare "or" separator are handled by | ||
| // splitFilterArgs/applyFilterGroups from the explicit argv snapshot, not registered on | ||
| // this FlagSet (see filters.go) — so Cobra must not error on them as "unknown flag". | ||
| FParseErrWhitelist: cobra.FParseErrWhitelist{UnknownFlags: true}, |
There was a problem hiding this comment.
Allowing unknown flags makes sense here for the custom filter parser. Could we validate the remaining arguments afterward, though? For example, flows --protcol=TCP currently succeeds without applying any protocol filter, since Cobra allows it and splitFilterArgs leaves it in the discarded remainder.
There was a problem hiding this comment.
Remaining unrecognized options now fail instead of being silently ignored.
|
|
||
| // prepareBuilder replaces the handful of edit_manifest calls setup() makes itself (as opposed to | ||
| // parse_args' flag-driven ones, already applied by the caller): node selector, TLS, subnets. | ||
| func (r *captureRun) prepareBuilder() error { |
There was a problem hiding this comment.
Should we also call r.builder.SetLogLevel(r.capOpts.logLevel) here? Currently, --log-level=debug is passed to the collector, but the agents keep LOG_LEVEL=info. I noticed this in the generated YAML, and the flag description says it configures both.
There was a problem hiding this comment.
Agent configuration now receives the requested --log-level.
| enableAll bool | ||
| } | ||
|
|
||
| func registerFlowMetricsFlags(cmd *cobra.Command, f *flowMetricsFlags) { |
There was a problem hiding this comment.
Could we preserve --enable_secondary_networks as part of this rewrite? The previous implementation enabled secondary-network capture, mounted /var/run/netns, and added SYS_ADMIN. It was also enabled by --enable_all and --privileged.
I couldn't find the equivalent configuration here. Passing the flag currently succeeds, but it doesn't enable secondary-network capture.
There was a problem hiding this comment.
Restored --enable_secondary_networks, including /var/run/[netns](https://github.com/var/run/netns), SYS_ADMIN, and the legacy --privileged behavior.
Signed-off-by: Julien Pinsonneau <jpinsonn@redhat.com>
6179f2a to
4ec1f25
Compare
|
Thanks for the feedback @leandroberetta ! Good catches ! |
Signed-off-by: Julien Pinsonneau <jpinsonn@redhat.com>
|
PR needs rebase. DetailsInstructions 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 kubernetes-sigs/prow repository. |
Summary
Rewrite the network-observability CLI from Bash to Go and reorganize the collector around focused packages.
output/flow/<timestamp>.jsonand preserve the SQLite.dboutput..pcapng, with optional decoded TLS plaintext inoutput/plaintext/<timestamp>.jsonl..txtconversion path.Related PRs
Dependency
This PR consumes
github.com/netobserv/netobserv-operator/pkg/capturefrom netobserv-operator#2993. The module is pinned to the compatible operator commit until the shared package is released from the canonical repository. The vendored flowlogs-pipeline shutdown behavior is included for safe collector draining.Validation
go test ./...make build, formatting, and golangci-lint.txtfiles