Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[BULK-PROFILE]-8: Add the BulkProfileService servlet - #1994

#1994
Open
bharathappali wants to merge 21 commits into
kruize:runtimes-iirjkruize/autotune:runtimes-iirjfrom
bharathappali:feat-bulk-prof-8bharathappali/autotune:feat-bulk-prof-8Copy head branch name to clipboard
Open

[BULK-PROFILE]-8: Add the BulkProfileService servlet#1994
bharathappali wants to merge 21 commits into
kruize:runtimes-iirjkruize/autotune:runtimes-iirjfrom
bharathappali:feat-bulk-prof-8bharathappali/autotune:feat-bulk-prof-8Copy head branch name to clipboard

Conversation

@bharathappali

@bharathappali bharathappali commented Jun 24, 2026

Copy link
Copy Markdown
Member

Description

This PR is built on top of #1992

#1992 should be merged before this PR

This PR adds the servlet for exposing the CRUD API's for the bulk profile service

Fixes #1977

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 end-to-end support for managing bulk profiles, from REST API exposure through DAO and Hibernate integration down to database schema migration.

New Features:

  • Introduce BulkProfileService servlet to provide CRUD REST APIs for managing bulk profiles, including optional webhook notifications on updates.
  • Add BulkProfile and BulkProfileUpdateRequest service objects to represent bulk profile configurations and partial updates.
  • Persist bulk profiles via new KruizeBulkProfileEntry JPA entity and corresponding bulk profile table schema.

Enhancements:

  • Extend ExperimentDAO/DAOImpl and DBConstants with bulk profile CRUD queries, including listing enabled profiles.
  • Register bulk profile entity with Hibernate and expose the bulk profile endpoint in the Analyzer server context.

Build:

  • Add database migration to create the kruize_bulk_profile table with JSONB columns and metadata fields.

@sourcery-ai

sourcery-ai Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Adds a new BulkProfile REST servlet, service-layer DTOs, and DB entity/DAO support to manage bulk profile configurations with CRUD operations and webhook notifications.

Sequence diagram for BulkProfileService update with webhook

sequenceDiagram
    actor Client
    participant BulkProfileService
    participant ExperimentDAO
    participant KruizeBulkProfileEntry
    participant GenericRestApiClient
    participant WebhookEndpoint

    Client->>BulkProfileService: doPut(profile_name)
    BulkProfileService->>ExperimentDAO: loadBulkProfileByName(profileName)
    ExperimentDAO-->>BulkProfileService: KruizeBulkProfileEntry
    BulkProfileService->>KruizeBulkProfileEntry: toBulkProfile()
    BulkProfileService->>BulkProfileService: apply BulkProfileUpdateRequest
    BulkProfileService->>KruizeBulkProfileEntry: fromBulkProfile(BulkProfile)
    BulkProfileService->>ExperimentDAO: updateBulkProfileToDB(KruizeBulkProfileEntry)
    ExperimentDAO-->>BulkProfileService: ValidationOutputData
    alt [update successful]
        BulkProfileService->>GenericRestApiClient: callKruizeAPI(payload)
        GenericRestApiClient->>WebhookEndpoint: POST payload
        WebhookEndpoint-->>GenericRestApiClient: 200 OK
        GenericRestApiClient-->>BulkProfileService: HttpResponseWrapper
    end
    BulkProfileService-->>Client: 200 OK with BulkProfile
Loading

File-Level Changes

Change Details Files
Introduce BulkProfile REST servlet exposing CRUD operations and webhooks for bulk profile configurations.
  • Add BulkProfileService servlet handling GET/POST/PUT/DELETE with JSON payloads for bulk profile definitions
  • Implement request parsing, validation, and error handling with consistent JSON responses
  • Trigger optional webhook callbacks on profile update using GenericRestApiClient
src/main/java/com/autotune/analyzer/services/BulkProfileService.java
Define BulkProfile service-layer DTOs for API requests and updates.
  • Add BulkProfile model with nested Cluster and RecommendationSettings types and appropriate JSON annotations
  • Add BulkProfileUpdateRequest DTO to support partial updates via PUT requests
src/main/java/com/autotune/analyzer/serviceObjects/BulkProfile.java
src/main/java/com/autotune/analyzer/serviceObjects/BulkProfileUpdateRequest.java
Add database persistence layer for bulk profiles, including entity mapping, DAO methods, and SQL constants.
  • Create KruizeBulkProfileEntry JPA entity mapping bulk profile data to JSONB-backed kruize_bulk_profile table and conversion helpers to/from BulkProfile
  • Register KruizeBulkProfileEntry with Hibernate session factory and add Flyway migration to create kruize_bulk_profile table
  • Extend ExperimentDAO/ExperimentDAOImpl with CRUD and query methods for bulk profiles, including enabled-only queries and conflict handling
  • Add HQL constants for selecting, listing and deleting bulk profiles and enabled profiles only
src/main/java/com/autotune/database/table/lm/KruizeBulkProfileEntry.java
src/main/java/com/autotune/database/init/KruizeHibernateUtil.java
src/main/java/com/autotune/database/dao/ExperimentDAO.java
src/main/java/com/autotune/database/dao/ExperimentDAOImpl.java
src/main/java/com/autotune/database/helper/DBConstants.java
migrations/lm/v111__create_kruize_bulk_profile_table.sql
Wire the new servlet and endpoint into the analyzer server context.
  • Register BulkProfileService servlet in Analyzer.addServlets
  • Expose /bulkProfiles endpoint in ServerContext for bulk profile operations
src/main/java/com/autotune/analyzer/Analyzer.java
src/main/java/com/autotune/utils/ServerContext.java

Possibly linked issues


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

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • The HQL constants for bulk profiles mix entity field names and column names (e.g. LOAD_ALL_ENABLED_BULK_PROFILES and DELETE_BULK_PROFILE_BY_NAME use profile_name instead of the KruizeBulkProfileEntry field profileName), which will break the queries; they should consistently use entity property names in JPQL.
  • The BulkProfile.description field is not mapped to KruizeBulkProfileEntry or the kruize_bulk_profile table, so descriptions will be silently dropped on persistence and reload; add a column and mapping if description is meant to round-trip.
  • The DB migration defines recommendation_settings JSONB NOT NULL, but BulkProfileService does not validate that recommendation_settings is present and KruizeBulkProfileEntry.fromBulkProfile only sets it when non-null, so inserts/updates can violate the NOT NULL constraint; either relax the schema or enforce/normalize a non-null value in the service layer.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The HQL constants for bulk profiles mix entity field names and column names (e.g. `LOAD_ALL_ENABLED_BULK_PROFILES` and `DELETE_BULK_PROFILE_BY_NAME` use `profile_name` instead of the `KruizeBulkProfileEntry` field `profileName`), which will break the queries; they should consistently use entity property names in JPQL.
- The `BulkProfile.description` field is not mapped to `KruizeBulkProfileEntry` or the `kruize_bulk_profile` table, so descriptions will be silently dropped on persistence and reload; add a column and mapping if description is meant to round-trip.
- The DB migration defines `recommendation_settings JSONB NOT NULL`, but `BulkProfileService` does not validate that `recommendation_settings` is present and `KruizeBulkProfileEntry.fromBulkProfile` only sets it when non-null, so inserts/updates can violate the NOT NULL constraint; either relax the schema or enforce/normalize a non-null value in the service layer.

## Individual Comments

### Comment 1
<location path="src/main/java/com/autotune/analyzer/services/BulkProfileService.java" line_range="41-50" />
<code_context>
+        this.updatedAt = updatedAt;
+    }
+
+    /**
+     * Cluster configuration within a bulk profile
+     */
</code_context>
<issue_to_address>
**suggestion (typo):** REST path documentation does not match the registered servlet context

The Javadoc mentions `/bulkProfile`, but `ServerContext.BULK_PROFILE_SERVICE` is registered at `ROOT_CONTEXT + "bulkProfiles"` (plural). Please align the documented path with the actual servlet mapping.

Suggested implementation:

```java
 * REST path: {@code /bulkProfiles}

```

If the Javadoc mentions `/bulkProfile` in multiple places (e.g., examples, descriptions, or method-level documentation), apply the same string replacement there as well to ensure all documented paths consistently use `/bulkProfiles`, matching `ServerContext.BULK_PROFILE_SERVICE` at `ROOT_CONTEXT + "bulkProfiles"`.
</issue_to_address>

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.

Comment on lines +41 to +50
/**
* REST API service for Bulk Profile management
* Provides CRUD operations for bulk profiles and webhook notifications
*/
@WebServlet(asyncSupported = true)
public class BulkProfileService extends HttpServlet {
private static final long serialVersionUID = 1L;
private static final Logger LOGGER = LoggerFactory.getLogger(BulkProfileService.class);
private static final ObjectMapper objectMapper = new ObjectMapper();
private ExperimentDAO experimentDAO;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

suggestion (typo): REST path documentation does not match the registered servlet context

The Javadoc mentions /bulkProfile, but ServerContext.BULK_PROFILE_SERVICE is registered at ROOT_CONTEXT + "bulkProfiles" (plural). Please align the documented path with the actual servlet mapping.

Suggested implementation:

 * REST path: {@code /bulkProfiles}

If the Javadoc mentions /bulkProfile in multiple places (e.g., examples, descriptions, or method-level documentation), apply the same string replacement there as well to ensure all documented paths consistently use /bulkProfiles, matching ServerContext.BULK_PROFILE_SERVICE at ROOT_CONTEXT + "bulkProfiles".

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>
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>
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>
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>
Signed-off-by: bharathappali <abharath@redhat.com>
Signed-off-by: bharathappali <abharath@redhat.com>
…ulk profile

Signed-off-by: bharathappali <abharath@redhat.com>
Signed-off-by: bharathappali <abharath@redhat.com>
Signed-off-by: bharathappali <abharath@redhat.com>
@bharathappali bharathappali moved this to Under Review in Monitoring Jul 24, 2026
@rbadagandi1 rbadagandi1 added this to the Release 0.0.1 milestone Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Under Review

Development

Successfully merging this pull request may close these issues.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.