Skip to content

Conversation

@khansaad
Copy link
Contributor

@khansaad khansaad commented Jan 19, 2026

Description

This PR adds the metric details and the corresponding code changes for the JVM info details as part of the runtime 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

Introduce a structured config model that can carry both resource and runtime (env) recommendations and integrate it into the recommendation generation pipeline.

New Features:

  • Add support for carrying runtime (environment) recommendations in the recommendation config structure, gated by supported runtime data sources.
  • Expose a runtime recommendation hook in the recommendation model interface for future JVM/runtime-specific logic.

Enhancements:

  • Refactor recommendation config handling to use a dedicated Config object instead of raw nested maps across the engine, autoscalers, and models.
  • Extend recommendation notifications to indicate when runtime recommendations are available.
  • Add enum abstractions for different config types (requests, limits, env) to better organize recommendation data.

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Jan 19, 2026

Reviewer's Guide

Introduces a new Config abstraction to hold recommendations (requests, limits, and future runtime env) and starts wiring runtime/JVM-aware recommendations into the engine, including notifications and autoscaler consumers, while keeping runtime logic mostly stubbed for now.

Sequence diagram for generating recommendations with runtime env list

sequenceDiagram
    participant NS as NamespaceData
    participant RE as RecommendationEngine
    participant KO as KruizeObject
    participant RM as RecommendationModel
    participant DRM as DataSourceCollection
    participant DSI as DataSourceInfo
    participant MRM as MappedRecommendationForModel

    NS->>RE: generateRecommendationsBasedOnNamespace(namespaceData, kruizeObject)
    RE->>RE: generateNamespaceRecommendationBasedOnModel(..., kruizeObject, ...)
    RE->>RE: generateRecommendationBasedOnModel(monitoringStartTime, model, containerData, monitoringEndTime, kruizeObject, currentConfigMap, termsEntry)
    RE->>KO: getRecommendation_settings()
    KO-->>RE: RecommendationSettings

    RE->>KO: getDataSource()
    KO-->>RE: datasourceName
    RE->>DRM: getInstance()
    DRM-->>RE: DataSourceCollection
    RE->>DRM: getDataSourcesCollection()
    DRM-->>RE: Map datasourceMap
    RE->>RE: dataSourceInfo = datasourceMap.get(datasourceName)
    RE->>DSI: getServiceName()
    DSI-->>RE: serviceName
    RE->>RE: handleRuntimeRecommendations(kruizeObject)
    RE-->>RE: runtimeRecommList(List RecommendationConfigEnv)

    RE->>RE: populateRecommendation(termEntry, recommendationModel, monitoringStartTime, monitoringEndTime, containerCpuLimit, numPods, cpuThreshold, memoryThreshold, recommendationAcceleratorRequestMap, runtimeRecommList)

    activate RE
    RE->>MRM: new MappedRecommendationForModel()
    RE->>RE: build requestsMap and limitsMap
    RE->>MRM: getConfig()
    MRM-->>RE: Config config
    RE->>config: setRequests(requestsMap)
    RE->>config: setLimits(limitsMap)
    alt runtimeRecommList not null and not empty
        RE->>MRM: getConfig()
        MRM-->>RE: Config config
        RE->>config: setEnv(runtimeRecommList)
        RE->>RM: addNotification(INFO_RUNTIMES_RECOMMENDATIONS_AVAILABLE)
    end
    RE->>MRM: setConfig(config)
    deactivate RE

    RE-->>NS: mappedRecommendationForModel
Loading

Class diagram for new Config and runtime recommendation model

classDiagram
    class Config {
        +Map~AnalyzerConstants.RecommendationItem, RecommendationConfigItem~ requests
        +Map~AnalyzerConstants.RecommendationItem, RecommendationConfigItem~ limits
        +List~RecommendationConfigEnv~ env
        +Map getRequests()
        +void setRequests(Map requests)
        +Map getLimits()
        +void setLimits(Map limits)
        +List getEnv()
        +void setEnv(List env)
    }

    class RecommendationConfigEnv {
        -String name
        -String value
        -String errorMsg
        +RecommendationConfigEnv(String name, String value)
        +String getName()
        +void setName(String name)
        +String getValue()
        +void setValue(String value)
        +String getErrorMsg()
        +void setErrorMsg(String errorMsg)
    }

    class MappedRecommendationForModel {
        -int podsCount
        -double confidence_level
        -Config config
        -HashMap~AnalyzerConstants.ResourceSetting, HashMap~AnalyzerConstants.RecommendationItem, RecommendationConfigItem~~ variation
        -HashMap~String, List~RecommendationNotification~~ notificationHashMap
        +MappedRecommendationForModel()
        +int getPodsCount()
        +void setPodsCount(int podsCount)
        +double getConfidence_level()
        +void setConfidence_level(double confidence_level)
        +Config getConfig()
        +void setConfig(Config config)
    }

    class RecommendationModel {
        <<interface>>
        +RecommendationConfigItem getCpuRequestRecommendation(Map filteredResultsMap, ArrayList notifications)
        +RecommendationConfigItem getMemoryRequestRecommendation(Map filteredResultsMap, ArrayList notifications)
        +RecommendationConfigItem getCpuLimitRecommendation(Map filteredResultsMap, ArrayList notifications)
        +RecommendationConfigItem getMemoryLimitRecommendation(Map filteredResultsMap, ArrayList notifications)
        +Map getAcceleratorRequestRecommendation(Map filteredResultsMap, ArrayList notifications)
        +RecommendationConfigEnv getRuntimeRecommendation(Map filteredResultsMap, ArrayList notifications)
        +String getModelName()
        +void validate()
    }

    class GenericRecommendationModel {
        +String name
        +RecommendationConfigEnv getRuntimeRecommendation(Map filteredResultsMap, ArrayList notifications)
        +String getModelName()
        +void validate()
        +RecommendationConfigItem getCpuRequestRecommendation(Map filteredResultsMap, ArrayList notifications)
        +RecommendationConfigItem getMemoryRequestRecommendation(Map filteredResultsMap, ArrayList notifications)
        +RecommendationConfigItem getCpuLimitRecommendation(Map filteredResultsMap, ArrayList notifications)
        +RecommendationConfigItem getMemoryLimitRecommendation(Map filteredResultsMap, ArrayList notifications)
        +Map getAcceleratorRequestRecommendation(Map filteredResultsMap, ArrayList notifications)
    }

    class RecommendationEngine {
        +boolean generateRecommendationsBasedOnTerms(ContainerData containerData, NamespaceData namespaceData, KruizeObject kruizeObject)
        -MappedRecommendationForModel generateRecommendationBasedOnModel(Timestamp monitoringStartTime, RecommendationModel model, ContainerData containerData, Timestamp monitoringEndTime, KruizeObject kruizeObject, HashMap currentConfigMap, Map.Entry termsEntry)
        -List~RecommendationConfigEnv~ handleRuntimeRecommendations(KruizeObject kruizeObject)
        -boolean populateRecommendation(Map.Entry termEntry, RecommendationModel recommendationModel, Timestamp monitoringStartTime, Timestamp monitoringEndTime, double containerCpuLimit, int numPods, double cpuThreshold, double memoryThreshold, Map recommendationAcceleratorRequestMap, List runtimeListToPopulate)
        -void addIfNotEmpty(List list, String name, StringBuilder valueBuilder)
    }

    class RecommendationNotification {
        <<enum>>
        INFO_COST_RECOMMENDATIONS_AVAILABLE
        INFO_PERFORMANCE_RECOMMENDATIONS_AVAILABLE
        INFO_MODEL_RECOMMENDATIONS_AVAILABLE
        INFO_RUNTIMES_RECOMMENDATIONS_AVAILABLE
    }

    class AnalyzerConstants {
    }

    class ResourceSetting {
        <<enum>>
        requests
        limits
    }

    class RuntimesSetting {
        <<enum>>
        env
    }

    class ConfigType {
        <<enum>>
        REQUESTS
        LIMITS
        ENV
        -Enum sourceEnum
    }

    AnalyzerConstants <|-- ResourceSetting
    AnalyzerConstants <|-- RuntimesSetting
    AnalyzerConstants <|-- ConfigType

    RecommendationModel <|.. GenericRecommendationModel

    Config "1" o-- "*" RecommendationConfigEnv : env
    MappedRecommendationForModel "1" o-- "1" Config : config

    RecommendationEngine --> RecommendationModel
    RecommendationEngine --> MappedRecommendationForModel
    RecommendationEngine --> Config
    RecommendationEngine --> RecommendationConfigEnv
    RecommendationEngine --> RecommendationNotification
    ConfigType --> ResourceSetting
    ConfigType --> RuntimesSetting
Loading

File-Level Changes

Change Details Files
Refactor recommendation config structure to a dedicated Config class and propagate it through recommendation generation and autoscalers.
  • Replace HashMap<ResourceSetting, Map<RecommendationItem, RecommendationConfigItem>> with Config in MappedRecommendationForModel and related code paths.
  • Update recommendation population in RecommendationEngine.populateRecommendation to build a Config object via setters for requests and limits instead of mutating a map.
  • Adjust VpaAutoscalerImpl and AcceleratorAutoscalerImpl to read request/limit recommendations from Config getters instead of ResourceSetting-keyed maps.
  • Change autoscaler utilities and method signatures to use AnalyzerConstants.ConfigType instead of ResourceSetting where appropriate.
src/main/java/com/autotune/analyzer/recommendations/engine/RecommendationEngine.java
src/main/java/com/autotune/analyzer/recommendations/objects/MappedRecommendationForModel.java
src/main/java/com/autotune/analyzer/autoscaler/vpa/VpaAutoscalerImpl.java
src/main/java/com/autotune/analyzer/autoscaler/accelerator/AcceleratorAutoscalerImpl.java
src/main/java/com/autotune/analyzer/autoscaler/accelerator/utils/AcceleratorAutoscalerUtils.java
src/main/java/com/autotune/analyzer/utils/AnalyzerConstants.java
src/main/java/com/autotune/analyzer/recommendations/Config.java
Add plumbing and data structures for runtime (e.g., JVM) environment recommendations without implementing full logic yet.
  • Introduce RecommendationConfigEnv to represent recommended environment entries with optional error messages.
  • Extend RecommendationModel and GenericRecommendationModel with a getRuntimeRecommendation hook (currently TODO).
  • Add an env list to Config and a helper in RecommendationEngine to set runtime env recommendations and INFO-level notifications when present.
  • Implement handleRuntimeRecommendations in RecommendationEngine to validate datasource support and return a (currently empty) runtime env list, wiring the result into populateRecommendation.
  • Add a helper addIfNotEmpty in RecommendationEngine for building env entries and a new INFO_RUNTIMES_RECOMMENDATIONS_AVAILABLE notification and message constants.
src/main/java/com/autotune/analyzer/recommendations/RecommendationConfigEnv.java
src/main/java/com/autotune/analyzer/recommendations/Config.java
src/main/java/com/autotune/analyzer/recommendations/model/RecommendationModel.java
src/main/java/com/autotune/analyzer/recommendations/model/GenericRecommendationModel.java
src/main/java/com/autotune/analyzer/recommendations/engine/RecommendationEngine.java
src/main/java/com/autotune/analyzer/recommendations/RecommendationConstants.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

@khansaad khansaad moved this to In Progress in Monitoring Jan 19, 2026
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

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

1 participant