Skip to content

Conversation

marqc
Copy link
Contributor

@marqc marqc commented Oct 30, 2023

  • All code is covered by unit and/or runtime tests where feasible.
  • All commits contain a well written commit description including a title,
    description and a Fixes: #XXX line if the commit addresses a particular
    GitHub issue.
  • All commits are signed off. See the section Developer’s Certificate of Origin
  • Provide a title or release-note blurb suitable for the release notes.

Introduce dynamic hubble flowlog exporters configuration guided by config file.
Changes in the config file are reflected without a need to restart cilium-agent, so it allows to dynamically specify flowlog requests. Each request contains the output file path, field mask, include filters (to allow flows), exclude filters (to deny flows) and end time at which flowlog will automatically stop collecting flows. The low-level implementation reuses a current hubble exporter. The config file will be populated from configmap (but allows customization if needed).
The config file is in YAML format, sample config file.

flowlogs:
- name: "test001"
  filePath: "/var/log/network/flow-log/pa/test001.log"
  fieldMask: []
  includeFilters: []
  excludeFilters: []
  end: "2023-10-09T23:59:59-07:00"
- name: "test002"
  filePath: "/var/log/network/flow-log/pa/test002.log"
  fieldMask: ["source.namespace", "source.pod_name", "destination.namespace", "destination.pod_name", "verdict"]
  includeFilters:
  - source_pod: ["default/"]
    event_type:
    - type: 1
  - destination_pod: ["frontend/nginx-975996d4c-7hhgt"]
  excludeFilters: []
  end: "2023-10-09T23:59:59-07:00"

This is a follow up from discussion in #28220 cc: @chancez @AwesomePatrol @nathanperkins

Fixes: #25508

TODO list:

  • replace periodic file reads with inotify As this PR is already quite big I will do it in a separate PR
  • add metrics (gauge with active flowlogs, cumulative counters with number of config changes applied)
  • modify helm charts to cover new dynamic flowlog feature (deploy empty config as CM and mount to cilium-agent)
  • docs
Add dynamic flowlog exporters configured by yaml file (configmap) without a need of agent restart.

@marqc marqc requested a review from a team as a code owner October 30, 2023 15:26
@marqc marqc requested a review from a user October 30, 2023 15:26
@maintainer-s-little-helper maintainer-s-little-helper bot added the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Oct 30, 2023
@marqc marqc marked this pull request as draft October 30, 2023 15:26
@github-actions github-actions bot added the kind/community-contribution This was a contribution made by a community member. label Oct 30, 2023
@marqc marqc force-pushed the dynamic_hubble_flow_logs branch from 890c558 to 43f3aa0 Compare October 31, 2023 14:14
@marqc marqc marked this pull request as ready for review October 31, 2023 14:27
@marqc marqc requested review from a team as code owners October 31, 2023 14:27
@marqc marqc requested review from marseel and derailed October 31, 2023 14:27
@ghost ghost added the sig/hubble label Oct 31, 2023
@chancez
Copy link
Contributor

chancez commented Oct 31, 2023

I'll take a deeper look a bit later this week but so far the general approach looks good.

One thought: can get some metrics? A few useful metrics:

  • a hash of the config and expose that as a gauge. It would help identify when nodes all have the most up to date configuration.
  • a counter for number of configuration reload failures. If the new config is invalid, it would be ideal to have a metric that can be used to detect this case.

@michi-covalent michi-covalent added the release-note/major This PR introduces major new functionality to Cilium. label Oct 31, 2023
@maintainer-s-little-helper maintainer-s-little-helper bot removed the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Oct 31, 2023
Copy link
Contributor

@derailed derailed left a comment

Choose a reason for hiding this comment

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

@marqc Nice work! Cool feature.

@marqc marqc force-pushed the dynamic_hubble_flow_logs branch from 43f3aa0 to 1c1e15f Compare November 2, 2023 10:33
@marqc marqc force-pushed the dynamic_hubble_flow_logs branch from 1c1e15f to 970218b Compare November 2, 2023 12:23
@marqc marqc requested a review from a team as a code owner November 2, 2023 12:23
@marqc marqc requested a review from rolinh November 2, 2023 12:23
@marqc marqc force-pushed the dynamic_hubble_flow_logs branch from 970218b to d0d532e Compare November 2, 2023 12:31
@marqc marqc force-pushed the dynamic_hubble_flow_logs branch 2 times, most recently from 58cbaac to 40ceaec Compare November 2, 2023 14:28
@marqc
Copy link
Contributor Author

marqc commented Nov 2, 2023

One thought: can get some metrics? A few useful metrics:

  • a hash of the config and expose that as a gauge. It would help identify when nodes all have the most up to date configuration.
  • a counter for number of configuration reload failures. If the new config is invalid, it would be ideal to have a metric that can be used to detect this case.

Done. As flowlog already has a "name" identifying it I use it instead of calculating hash in metrics.

@marqc marqc force-pushed the dynamic_hubble_flow_logs branch from 40ceaec to d4f57ff Compare November 2, 2023 14:48
@marqc marqc requested a review from derailed November 2, 2023 14:53
@marqc
Copy link
Contributor Author

marqc commented Nov 27, 2023

/test

Copy link
Member

@rolinh rolinh left a comment

Choose a reason for hiding this comment

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

It looks like I'm late to the review party, sorry about that.

That's a great contribution Marek! The implementation looks pretty solid overall, I only have a few comments (see below).

@marqc marqc force-pushed the dynamic_hubble_flow_logs branch from 6f2b41c to e510e02 Compare November 28, 2023 10:19
@marqc marqc requested a review from rolinh November 28, 2023 10:21
Copy link
Member

@rolinh rolinh left a comment

Choose a reason for hiding this comment

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

Great work 🚀 ! Let's get this in before the v1.15 cut.

@marqc marqc force-pushed the dynamic_hubble_flow_logs branch from e510e02 to d33a197 Compare November 28, 2023 10:53
@rolinh
Copy link
Member

rolinh commented Nov 29, 2023

/test

Copy link

@ql-owo-lp ql-owo-lp left a comment

Choose a reason for hiding this comment

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

Overall good job. Thanks!

@marqc marqc force-pushed the dynamic_hubble_flow_logs branch from d33a197 to 2ff9189 Compare December 1, 2023 13:53
@rolinh
Copy link
Member

rolinh commented Dec 1, 2023

/test

@marqc marqc force-pushed the dynamic_hubble_flow_logs branch from 2ff9189 to e20dea7 Compare December 1, 2023 14:37
Signed-off-by: Marek Chodor <mchodor@google.com>
@marqc marqc force-pushed the dynamic_hubble_flow_logs branch from e20dea7 to 6aa8733 Compare December 1, 2023 14:46
@marqc
Copy link
Contributor Author

marqc commented Dec 1, 2023

/test

@rolinh
Copy link
Member

rolinh commented Dec 1, 2023

/ci-ipsec-upgrade

@rolinh rolinh enabled auto-merge December 1, 2023 16:38
@aanm
Copy link
Member

aanm commented Dec 1, 2023

For some reason, travis didn't run. Travis is only running arm64 unit tests so it's safe to assume that this PR can be merged. Thank you for the contribution.

@aanm aanm merged commit f51bc04 into cilium:main Dec 1, 2023
skmatti pushed a commit to skmatti/cilium that referenced this pull request Jul 24, 2024
Add protoc-gen-gotag plugin to builder image.
Add yaml annotations to flow proto gen files.
Introduce dynamic hubble flow logs exporters based on config file.

Signed-off-by: Marek Chodor <mchodor@google.com>
Carry-Patch-Approval: b/309936968
Upstream-PR: cilium#28873
Upstream-PR: cilium#28943
Upstream-PR: cilium#28944
Change-Id: I7871d8b119822c3228a6e959b86dd1b6b23d275a
Reviewed-on: https://gke-internal-review.googlesource.com/c/third_party/cilium/+/860928
Unit-Verified: Prow_Bot_V2 <425329972751-compute@developer.gserviceaccount.com>
Reviewed-by: Akhil Velagapudi <avelagap@google.com>
Reviewed-by: Prow_Bot_V2 <425329972751-compute@developer.gserviceaccount.com>
Tested-by: Prow_Bot_V2 <425329972751-compute@developer.gserviceaccount.com>
skmatti pushed a commit to skmatti/cilium that referenced this pull request Jul 24, 2024
Carry-Patch-Approval: b/309936968
Upstream-PR: cilium#28873
Change-Id: Ie0028dfba1ad9f6185ddb996582a934eb11b5452
Reviewed-on: https://gke-internal-review.googlesource.com/c/third_party/cilium/+/866204
Reviewed-by: Prow_Bot_V2 <425329972751-compute@developer.gserviceaccount.com>
Tested-by: Prow_Bot_V2 <425329972751-compute@developer.gserviceaccount.com>
Prow-Auto-Submit: Marek Chodor <mchodor@google.com>
Reviewed-by: Alan Kutniewski <kutniewski@google.com>
Unit-Verified: Prow_Bot_V2 <425329972751-compute@developer.gserviceaccount.com>
skmatti pushed a commit to skmatti/cilium that referenced this pull request Jul 24, 2024
The new parser utilizes json tags to keep API consistent.
This also reverts cherry-pick of
cilium#28944 as this is no longer needed.

Carry-Patch-Approval: b/309936968
Upstream-PR: cilium#28873
Change-Id: I8d44e7f937fb56f3c5c6c4ed943586d39a4ea17b
Reviewed-on: https://gke-internal-review.googlesource.com/c/third_party/cilium/+/867331
Tested-by: Prow_Bot_V2 <425329972751-compute@developer.gserviceaccount.com>
Unit-Verified: Prow_Bot_V2 <425329972751-compute@developer.gserviceaccount.com>
Reviewed-by: Akhil Velagapudi <avelagap@google.com>
Reviewed-by: Prow_Bot_V2 <425329972751-compute@developer.gserviceaccount.com>
Prow-Auto-Submit: Marek Chodor <mchodor@google.com>
skmatti pushed a commit to skmatti/cilium that referenced this pull request Jul 24, 2024
Carry-Patch-Approval: b/309936968
Upstream-PR: cilium#28873
Change-Id: Ib38ed5f1581900ab06da92cb2f3931b0cadad152
Reviewed-on: https://gke-internal-review.googlesource.com/c/third_party/cilium/+/867864
Prow-Auto-Submit: Marek Chodor <mchodor@google.com>
Reviewed-by: Prow_Bot_V2 <425329972751-compute@developer.gserviceaccount.com>
Unit-Verified: Prow_Bot_V2 <425329972751-compute@developer.gserviceaccount.com>
Reviewed-by: Akhil Velagapudi <avelagap@google.com>
Tested-by: Prow_Bot_V2 <425329972751-compute@developer.gserviceaccount.com>
skmatti pushed a commit to skmatti/cilium that referenced this pull request Jul 24, 2024
Carry-Patch-Approval: b/309936968
Upstream-PR: cilium#28873
Change-Id: Id7a619b9fb19ae6ee4f1ecc2549ac7dec5c64019
Reviewed-on: https://gke-internal-review.googlesource.com/c/third_party/cilium/+/873423
Reviewed-by: Dorde Lapcevic <dordel@google.com>
Prow-Auto-Submit: Marek Chodor <mchodor@google.com>
Tested-by: Prow_Bot_V2 <425329972751-compute@developer.gserviceaccount.com>
Reviewed-by: Prow_Bot_V2 <425329972751-compute@developer.gserviceaccount.com>
Unit-Verified: Prow_Bot_V2 <425329972751-compute@developer.gserviceaccount.com>
skmatti pushed a commit to skmatti/cilium that referenced this pull request Jul 24, 2024
Upstream-PR: cilium#28873
Signed-off-by: Marek Chodor <mchodor@google.com>
Change-Id: Ib2b6937ba276d7fee127b856c02212053d9bb3ee
Reviewed-on: https://gke-internal-review.googlesource.com/c/third_party/cilium/+/899008
Unit-Verified: Prow_Bot_V2 <425329972751-compute@developer.gserviceaccount.com>
Reviewed-by: Akhil Velagapudi <avelagap@google.com>
Reviewed-by: Aleksander Mistewicz <amistewicz@google.com>
Tested-by: Prow_Bot_V2 <425329972751-compute@developer.gserviceaccount.com>
Reviewed-by: Prow_Bot_V2 <425329972751-compute@developer.gserviceaccount.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/community-contribution This was a contribution made by a community member. release-note/major This PR introduces major new functionality to Cilium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CFP-2023-05-17: Hubble Flow Logs