Skip to content

feat(fake-workload): Add bool option for generating unclosed endpoints#14904

Merged
vikin91 merged 4 commits intomasterfrom
piotr/add-opiton-for-generating-unclosed-endpoints
Apr 9, 2025
Merged

feat(fake-workload): Add bool option for generating unclosed endpoints#14904
vikin91 merged 4 commits intomasterfrom
piotr/add-opiton-for-generating-unclosed-endpoints

Conversation

@vikin91
Copy link
Contributor

@vikin91 vikin91 commented Apr 7, 2025

Description

Generating unclosed endpoints in the fake-workload is meant to stress-load Central in a situation when many ports are opened for listening in the cluster. They are not closed on purpose to not trigger any cleanups.
The presence of the unclosed endpoints had actually stressed the memory of Sensor that lead to OOMs (ROX-28242). That load on Sensor was caused by "improper" handling of the endpoint data during enrichment of processes: some endpoints were never removed from the input to the enrichment loop on purpose, whereas others were kept there by accident. The fix for that is proposed in #14538.

In this PR, I add an option to disable the generation of unclosed endpoints in the fake workloads. This option is enabled by default (no change to the previous state), but it can be disabled for some workflows.
Disabling this option was helpful in investigating Sensor OOMs, so I think there is a value in persisting it.

User-facing documentation

  • CHANGELOG is updated OR update is not needed
  • documentation PR is created and is linked above OR is not needed

Testing and quality

  • the change is production ready: the change is GA or otherwise the functionality is gated by a feature flag
    • This is not a production code change - when the option is disabled, it affects only the long-running clusters with fake workloads.
  • CI results are inspected

Automated testing

  • added unit tests
  • added e2e tests
  • added regression tests
  • added compatibility tests
  • modified existing tests

How I validated my change

  • Deployed a long running cluster, toggle the newly added option in the config map and observed sensor's metrics regarding the enrichment of endpoints.

Summary by Sourcery

Add a configurable option to control the generation of unclosed network endpoints in fake workloads

New Features:

  • Introduce a new boolean option GenerateUnclosedEndpoints in network workload configuration to control the generation of unclosed network endpoints

Enhancements:

  • Modify fake workload generation to conditionally create unclosed network endpoints based on the new configuration option

Chores:

  • Update multiple workload configuration YAML files to explicitly set the new generateUnclosedEndpoints flag to true

@vikin91
Copy link
Contributor Author

vikin91 commented Apr 7, 2025

This change is part of the following stack:

Change managed by git-spice.

@openshift-ci
Copy link

openshift-ci bot commented Apr 7, 2025

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@rhacs-bot
Copy link
Contributor

rhacs-bot commented Apr 7, 2025

Images are ready for the commit at a63c2b3.

To use with deploy scripts, first export MAIN_IMAGE_TAG=4.8.x-426-ga63c2b3a8d.

@codecov
Copy link

codecov bot commented Apr 7, 2025

Codecov Report

Attention: Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.

Project coverage is 48.96%. Comparing base (b6a727e) to head (09f293e).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
sensor/kubernetes/fake/flows.go 0.00% 4 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master   #14904   +/-   ##
=======================================
  Coverage   48.96%   48.96%           
=======================================
  Files        2550     2550           
  Lines      187222   187225    +3     
=======================================
+ Hits        91674    91683    +9     
+ Misses      88299    88294    -5     
+ Partials     7249     7248    -1     
Flag Coverage Δ
go-unit-tests 48.96% <0.00%> (+<0.01%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@vikin91 vikin91 force-pushed the piotr/ROX-28259-the-sensor-fix branch from 9aba1ec to 2f5c078 Compare April 7, 2025 15:22
@vikin91 vikin91 force-pushed the piotr/add-opiton-for-generating-unclosed-endpoints branch from 407376c to 6e4d36f Compare April 7, 2025 15:23
@vikin91 vikin91 force-pushed the piotr/add-opiton-for-generating-unclosed-endpoints branch from 6e4d36f to 09f293e Compare April 8, 2025 11:51
@vikin91 vikin91 changed the base branch from piotr/ROX-28259-the-sensor-fix to master April 8, 2025 11:51
@vikin91 vikin91 marked this pull request as ready for review April 8, 2025 12:00
@vikin91 vikin91 requested a review from a team as a code owner April 8, 2025 12:00
@vikin91 vikin91 requested a review from JoukoVirtanen April 8, 2025 12:00
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Apr 8, 2025

Reviewer's Guide by Sourcery

This pull request introduces a boolean option to control the generation of unclosed endpoints in fake workloads. This option, generateUnclosedEndpoints, is added to the NetworkWorkload struct and defaults to true to maintain existing behavior. When enabled, the fake workload generates network endpoints without closing them, simulating a scenario where ports are opened but not closed. This change allows for testing and debugging scenarios related to endpoint handling, particularly in the context of Sensor OOM issues.

Sequence diagram for generating network connections with unclosed endpoints

sequenceDiagram
  participant W as WorkloadManager
  participant NW as NetworkWorkload
  participant EP as EndpointPool
  W->>NW: Get NetworkWorkload config
  alt GenerateUnclosedEndpoints is true
    W->>EP: Add networkEndpoint (unclosed)
    EP-->>W: networkEndpoint
    W->>W: Append networkEndpoint to networkEndpoints
  else GenerateUnclosedEndpoints is false
    W->>W: Skip adding unclosed endpoint
  end
  W-->>W: Return networkEndpoints
Loading

Updated class diagram for NetworkWorkload

classDiagram
  class NetworkWorkload {
    FlowInterval time.Duration
    BatchSize int
    GenerateUnclosedEndpoints bool
  }
  note for NetworkWorkload "Added GenerateUnclosedEndpoints field"
Loading

File-Level Changes

Change Details Files
Introduce a new boolean option to control the generation of unclosed endpoints in fake workloads.
  • Added GenerateUnclosedEndpoints field to the NetworkWorkload struct.
  • Modified the fake network connection logic to conditionally generate unclosed endpoints based on the new option.
sensor/kubernetes/fake/flows.go
sensor/kubernetes/fake/workload.go
Enable the generation of unclosed endpoints by default in all workload configurations.
  • Set generateUnclosedEndpoints: true in all yaml workload configuration files.
scale/workloads/sample.yaml
scale/workloads/10-sensors.yaml
scale/workloads/active-vulnmgmt.yaml
scale/workloads/default.yaml
scale/workloads/high-alert.yaml
scale/workloads/long-running.yaml
scale/workloads/np-load.yaml
scale/workloads/okr-single-load.yaml
scale/workloads/rbac.yaml
scale/workloads/scale-test.yaml
scale/workloads/small.yaml
scale/workloads/vulnmgmt.yaml
scale/workloads/xlarge.yaml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @vikin91 - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider adding a comment to the GenerateUnclosedEndpoints field in NetworkWorkload to explain its purpose.
  • Since the default value of GenerateUnclosedEndpoints is true, consider explicitly setting it to true in the workload files where it's currently missing for clarity.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@vikin91 vikin91 changed the title Add bool option for generating unclosed endpoints feat(fake-workload): Add bool option for generating unclosed endpoints Apr 8, 2025
@vikin91
Copy link
Contributor Author

vikin91 commented Apr 8, 2025

  • Consider adding a comment to the GenerateUnclosedEndpoints field in NetworkWorkload to explain its purpose.
  • Since the default value of GenerateUnclosedEndpoints is true, consider explicitly setting it to true in the workload files where it's currently missing for clarity.

@sourcery-ai I actually did that in this PR. The comment is in the sample file and in all profiles the value is being set to true.

@vikin91 vikin91 enabled auto-merge (squash) April 9, 2025 21:03
@vikin91
Copy link
Contributor Author

vikin91 commented Apr 9, 2025

/retest

@openshift-ci
Copy link

openshift-ci bot commented Apr 9, 2025

@vikin91: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/ocp-4-18-nongroovy-e2e-tests 09f293e link false /test ocp-4-18-nongroovy-e2e-tests
ci/prow/ocp-4-12-nongroovy-e2e-tests a63c2b3 link false /test ocp-4-12-nongroovy-e2e-tests

Full PR test history. Your PR dashboard.

Details

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 kubernetes-sigs/prow repository. I understand the commands that are listed here.

@vikin91 vikin91 merged commit aeb7429 into master Apr 9, 2025
78 of 82 checks passed
@vikin91 vikin91 deleted the piotr/add-opiton-for-generating-unclosed-endpoints branch April 9, 2025 22:32
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.

3 participants