Skip to content

Add support for multiple datasources in createExperiment and generate Recommendations.#1946

Draft
khansaad wants to merge 16 commits into
kruize:runtimes-iirjfrom
khansaad:add-cryostat-support
Draft

Add support for multiple datasources in createExperiment and generate Recommendations.#1946
khansaad wants to merge 16 commits into
kruize:runtimes-iirjfrom
khansaad:add-cryostat-support

Conversation

@khansaad

@khansaad khansaad commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Description

This PR adds support for multiple datasources in createExperiment and generate Recommendations.
Fixes # (issue)

Type of change

  • Bug fix
  • New feature
  • Docs update
  • Breaking change (What changes might users need to make in their application due to this PR?)
  • Requires DB changes

How has this been tested?

Please describe the tests that were run to verify your changes and steps to reproduce. Please specify any test configuration required.

  • New Test X
  • Functional testsuite

Test Configuration

  • Kubernetes clusters tested on:

Checklist 🎯

  • Followed coding guidelines
  • Comments added
  • Dependent changes merged
  • Documentation updated
  • Tests added or updated

Additional information

Include any additional information such as links, test results, screenshots here

Summary by Sourcery

Add multi-datasource support to experiments and layer detection while maintaining backward compatibility with the existing single datasource field.

New Features:

  • Support configuring multiple datasources for experiments via the API and internal KruizeObject model.
  • Aggregate detected layers across all configured datasources during experiment setup.

Enhancements:

  • Improve logging and error handling in layer detection to better trace datasource-specific issues.

Tests:

  • Add unit tests covering multi-datasource configuration, backward compatibility, and layer aggregation behavior.

Signed-off-by: bharathappali <abharath@redhat.com>
Signed-off-by: bharathappali <abharath@redhat.com>
Signed-off-by: bharathappali <abharath@redhat.com>
Signed-off-by: bharathappali <abharath@redhat.com>
@khansaad khansaad requested a review from bharathappali June 9, 2026 08:17
@khansaad khansaad self-assigned this Jun 9, 2026
@khansaad khansaad added the enhancement New feature or request label Jun 9, 2026
@khansaad khansaad moved this to In Progress in Monitoring Jun 9, 2026
@sourcery-ai

sourcery-ai Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Adds multi-datasource support for experiments and layer detection by introducing datasources lists on API/domain objects, updating layer detection to iterate and aggregate across all configured datasources, and adding focused unit tests for backward compatibility and aggregation behavior.

Sequence diagram for multi-datasource layer detection

sequenceDiagram
    participant CreateExperimentAPIObject as CreateExperimentAPIObject
    participant ServiceHelpers as ServiceHelpers
    participant KubernetesAPIObject as KubernetesAPIObject
    participant ContainerAPIObject as ContainerAPIObject
    participant LayerUtils as LayerUtils

    ServiceHelpers->>CreateExperimentAPIObject: getDatasources()
    ServiceHelpers->>CreateExperimentAPIObject: getKubernetesObjects()
    loop for each KubernetesAPIObject
        ServiceHelpers->>KubernetesAPIObject: getContainerAPIObjects()
        loop for each ContainerAPIObject
            ServiceHelpers->>ContainerAPIObject: getContainer_name()
            loop for each datasourceName in datasources
                ServiceHelpers->>LayerUtils: detectLayers(container_name, namespace, datasourceName)
                LayerUtils-->>ServiceHelpers: Map<String, KruizeLayer>
                ServiceHelpers->>ServiceHelpers: merge into aggregatedLayers
            end
            ServiceHelpers->>ContainerAPIObject: setLayerMap(aggregatedLayers)
        end
    end
Loading

File-Level Changes

Change Details Files
Introduce multi-datasource fields on experiment objects with backward-compatible accessors.
  • Mark existing single datasource field as deprecated but still serialized for backward compatibility.
  • Add new datasources List field to KruizeObject and CreateExperimentAPIObject with JSON bindings.
  • Implement getDatasources() helpers that synthesize a list from the legacy single datasource when needed and never return null.
  • Add setters for the datasources list that preserve order and allow duplicates.
src/main/java/com/autotune/analyzer/kruizeObject/KruizeObject.java
src/main/java/com/autotune/analyzer/serviceObjects/CreateExperimentAPIObject.java
Extend layer detection to iterate over and aggregate layers from multiple datasources per container.
  • Refactor ServiceHelpers.detectLayers to fetch datasources list from CreateExperimentAPIObject instead of a single datasource.
  • Iterate over all configured datasources, calling LayerUtils.detectLayers for each and merging the resulting KruizeLayer maps.
  • Add logging for missing datasources, per-datasource success/failure, and aggregated results, while swallowing per-datasource exceptions to allow partial success.
  • Ensure backward compatibility by handling empty or null datasources lists and skipping detection safely.
src/main/java/com/autotune/analyzer/utils/ServiceHelpers.java
Add unit tests validating multi-datasource behavior, aggregation, and backward compatibility.
  • Create MultiDatasourceTest to verify KruizeObject and CreateExperimentAPIObject behaviors for single, multiple, and legacy datasource configurations.
  • Create MultiDatasourceLayerDetectionTest to validate datasources iteration, layer map aggregation semantics, and structural expectations around layer maps.
  • Cover edge cases such as empty/null datasources, order preservation, duplicate entries, case sensitivity, and multi-datasource scenarios (Prometheus, Cryostat, custom).
src/test/java/com/autotune/analyzer/kruizeObject/MultiDatasourceTest.java
src/test/java/com/autotune/analyzer/utils/MultiDatasourceLayerDetectionTest.java

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!

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

bharathappali and others added 3 commits June 9, 2026 16:08
Signed-off-by: bharathappali <abharath@redhat.com>
Signed-off-by: Saad Khan <saakhan@ibm.com>
Signed-off-by: Saad Khan <saakhan@ibm.com>
@khansaad khansaad force-pushed the add-cryostat-support branch from 251c3cc to f76fc43 Compare June 9, 2026 18:46
khansaad added 9 commits June 10, 2026 18:42
Signed-off-by: Saad Khan <saakhan@ibm.com>
Signed-off-by: Saad Khan <saakhan@ibm.com>
Signed-off-by: Saad Khan <saakhan@ibm.com>
Signed-off-by: Saad Khan <saakhan@ibm.com>
Signed-off-by: Saad Khan <saakhan@ibm.com>
Signed-off-by: Saad Khan <saakhan@ibm.com>
Signed-off-by: Saad Khan <saakhan@ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

2 participants