Add Bulk Profile service - #34
Open
bharathappali wants to merge 8 commits into
Open
Conversation
Signed-off-by: bharathappali <abharath@redhat.com>
Reviewer's GuideIntroduce a bulk profile feature that retrieves bulk profiles from the Kruize backend, models them as Java POJOs, and converts enabled profiles into bulk job requests, including new REST client endpoints and supporting constants. Sequence diagram for fetching enabled bulk profilessequenceDiagram
participant BulkProfileService
participant KruizeClient
participant ObjectMapper
BulkProfileService->>KruizeClient: getBulkProfiles()
KruizeClient-->>BulkProfileService: JSON string
BulkProfileService->>ObjectMapper: readValue(json, List<BulkProfile>)
ObjectMapper-->>BulkProfileService: List<BulkProfile>
BulkProfileService->>BulkProfileService: filter(p.getEnabled())
BulkProfileService-->>BulkProfileService: List<BulkProfile> enabledProfiles
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- In
BulkProfileService.convertProfileToBulkJob,profile.getRecommendationSettings()is dereferenced without a null check, which can lead to NPEs if the field is omitted in the response; consider validatingrecommendationSettingsbefore readingmeasurementDuration. - The bulk job conversion logic currently assumes a single cluster (
profile.getClusters().get(0)and first datasource only); if multiple clusters/datasources are expected, it might be better to make this handling explicit or document/enforce the single-cluster constraint. - The REST client
getBulkProfile(profileName)method is added but not yet used byBulkProfileService; if per-profile retrieval is part of the intended workflow, consider wiring it into the service or removing it until needed to avoid unused API surface.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `BulkProfileService.convertProfileToBulkJob`, `profile.getRecommendationSettings()` is dereferenced without a null check, which can lead to NPEs if the field is omitted in the response; consider validating `recommendationSettings` before reading `measurementDuration`.
- The bulk job conversion logic currently assumes a single cluster (`profile.getClusters().get(0)` and first datasource only); if multiple clusters/datasources are expected, it might be better to make this handling explicit or document/enforce the single-cluster constraint.
- The REST client `getBulkProfile(profileName)` method is added but not yet used by `BulkProfileService`; if per-profile retrieval is part of the intended workflow, consider wiring it into the service or removing it until needed to avoid unused API surface.
## Individual Comments
### Comment 1
<location path="src/main/java/com/kruize/optimizer/service/BulkProfileService.java" line_range="174" />
<code_context>
+ }
+
+ // Add measurement duration from recommendation settings
+ String measurementDuration = profile.getRecommendationSettings().getMeasurementDuration();
+ if (measurementDuration != null && !measurementDuration.isEmpty()) {
+ bulkJob.put("measurement_duration", measurementDuration);
</code_context>
<issue_to_address>
**issue (bug_risk):** Guard against null `recommendationSettings` to avoid a potential NPE.
If `profile.getRecommendationSettings()` is null, this line will throw a `NullPointerException`. Please add a null check (and optionally a default value) before calling `getMeasurementDuration()`.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| } | ||
|
|
||
| // Add measurement duration from recommendation settings | ||
| String measurementDuration = profile.getRecommendationSettings().getMeasurementDuration(); |
There was a problem hiding this comment.
issue (bug_risk): Guard against null recommendationSettings to avoid a potential NPE.
If profile.getRecommendationSettings() is null, this line will throw a NullPointerException. Please add a null check (and optionally a default value) before calling getMeasurementDuration().
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>
bharathappali
force-pushed
the
feat-bulk-prof-4
branch
from
July 9, 2026 07:42
1ff6016 to
99eba31
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR is built on top of #33
#33 needs to be merged before this PR
This PR adds bulk profile service
Summary by Sourcery
Introduce a bulk profile capability that can be fetched from the Kruize backend and converted into bulk job requests.
New Features: