Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3. Adding Recommendation Updater Abstraction and VPA Updater [KRUIZE-VPA Integration] #1412

Merged
merged 9 commits into from
Dec 13, 2024

Conversation

shekhar316
Copy link
Contributor

Description

This PR introduces a basic abstraction for the RecommendationUpdater.

  • The RecommendationUpdater interface is created, with a generic implementation provided by RecommendationUpdaterImpl.
  • The VpaUpdaterImpl extends RecommendationUpdaterImpl to offer a VPA-specific implementation for updating resource recommendations.
  • Additionally, the necessary constants and exceptions are included to support the functionality.
  • This abstraction lays the foundation for adding more specific updater implementations in the future.

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?

Tested on both the ResourceHub cluster and the Kind cluster to verify any issues.

Test Configuration

Kubernetes clusters tested on: ResourceHub (OpenShift), Kind

Checklist 🎯

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

Additional information

This PR is based on PR#1411. Please merge PR#1411 before this one.

@shekhar316 shekhar316 added this to the Kruize 0.3 Release milestone Dec 5, 2024
@shekhar316 shekhar316 requested a review from dinogun December 5, 2024 20:52
@shekhar316 shekhar316 self-assigned this Dec 5, 2024
@shekhar316 shekhar316 force-pushed the adding-updater-abstraction branch from a46287c to 9e1d5e0 Compare December 6, 2024 08:49
@shekhar316 shekhar316 changed the title 3. Adding Recommendation Updater Abstraction and VPA Updater [KRUIZE-VPA Integration] 3. [Testing - In Progress] Adding Recommendation Updater Abstraction and VPA Updater [KRUIZE-VPA Integration] Dec 10, 2024
Signed-off-by: Shekhar Saxena <[email protected]>
@shekhar316 shekhar316 changed the title 3. [Testing - In Progress] Adding Recommendation Updater Abstraction and VPA Updater [KRUIZE-VPA Integration] 3. Adding Recommendation Updater Abstraction and VPA Updater [KRUIZE-VPA Integration] Dec 10, 2024
@dinogun
Copy link
Contributor

dinogun commented Dec 10, 2024

@bharathappali @msvinaykumar Can you please review this PR, thanks

Signed-off-by: Shekhar Saxena <[email protected]>
@shekhar316
Copy link
Contributor Author

Hi @bharathappali ,

I’ve pushed the changes incorporating the modifications and suggestions you provided. Thank you for your review and valuable feedback. Could you please review it again?

Thank you!

Signed-off-by: Shekhar Saxena <[email protected]>
Copy link
Member

@bharathappali bharathappali left a comment

Choose a reason for hiding this comment

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

LGTM!

try {
// checks if updater is installed or not
if (isUpdaterInstalled()) {
LOGGER.info(String.format(AnalyzerConstants.RecommendationUpdaterConstants.InfoMsgs.CREATEING_VPA, kruizeObject.getExperimentName()));
Copy link
Contributor

Choose a reason for hiding this comment

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

This might create too much logging if we are apply VPA for every object in the cluster. I'd suggest make it LOGGER.debug. Only error's should be logged by default

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree. I've updated the info messages to debug messages which are experiment specific. Thanks for pointing out.

Comment on lines 260 to 263
LOGGER.info(String.format(AnalyzerConstants.RecommendationUpdaterConstants.InfoMsgs.RECOMMENDATION_VALUE,
AnalyzerConstants.RecommendationItem.CPU, containerName, cpuRecommendationValue));
LOGGER.info(String.format(AnalyzerConstants.RecommendationUpdaterConstants.InfoMsgs.RECOMMENDATION_VALUE,
AnalyzerConstants.RecommendationItem.MEMORY, containerName, memoryRecommendationValue));
Copy link
Contributor

Choose a reason for hiding this comment

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

LOGGER.debug

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to use debug messages.

Comment on lines 149 to 161
LOGGER.info(String.format(AnalyzerConstants.RecommendationUpdaterConstants.InfoMsgs.CHECKING_IF_VPA_PRESENT, vpaName));
NamespacedVerticalPodAutoscalerClient client = new DefaultVerticalPodAutoscalerClient();
VerticalPodAutoscalerList vpas = client.v1().verticalpodautoscalers().inAnyNamespace().list();

if (null != vpas && null != vpas.getItems() && !vpas.getItems().isEmpty()) {
for (VerticalPodAutoscaler vpa : vpas.getItems()) {
if (vpaName.equals(vpa.getMetadata().getName())) {
LOGGER.info(String.format(AnalyzerConstants.RecommendationUpdaterConstants.InfoMsgs.VPA_WITH_NAME_FOUND, vpaName));
return vpa;
}
}
}
LOGGER.info(String.format(AnalyzerConstants.RecommendationUpdaterConstants.InfoMsgs.VPA_WITH_NAME_NOT_FOUND, vpaName));
Copy link
Contributor

Choose a reason for hiding this comment

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

This is called while applying recommendations right? Please use LOGGER.debug everywhere

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, as we discussed, it will verify before applying the recommendations or before creating the vpa objects.

}
}
}
LOGGER.info(String.format(AnalyzerConstants.RecommendationUpdaterConstants.InfoMsgs.VPA_WITH_NAME_NOT_FOUND, vpaName));
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be LOGGER.error right? Others should be debug

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated this one to error message.

@Override
public boolean isUpdaterInstalled() {
try {
LOGGER.info(AnalyzerConstants.RecommendationUpdaterConstants.InfoMsgs.CHECKING_IF_UPDATER_INSTALLED,
Copy link
Contributor

Choose a reason for hiding this comment

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

General rule to follow, only log it as info if it is a rare occurence, eg once per kruize start. All other items which are on a per experiment basis should only be logged as debug unless there is a justification

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing it out @dinogun! I’ve updated the info logs to debug messages and ensured that only error messages are logged by default. I’ll ensure this in future implementations also.

Signed-off-by: Shekhar Saxena <[email protected]>
@shekhar316 shekhar316 requested a review from dinogun December 13, 2024 13:06
Copy link
Contributor

@dinogun dinogun left a comment

Choose a reason for hiding this comment

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

LGTM

@dinogun dinogun merged commit da8ae97 into kruize:mvp_demo Dec 13, 2024
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants