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

Introduce multiple service group categories and maximumMaxReplicas for each of them #428

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

AVSBharadwaj
Copy link
Collaborator

@AVSBharadwaj AVSBharadwaj commented Jan 9, 2025

code Implementation of this Issue: #426

Introduces:

  • feature for introducing multiple categories of service types ( like default, fintech-service, critical-service, etc
  • feature for having multiple maximumMaxReplicas value one for each of the service-categories mentioned above

Copy link
Collaborator

@sanposhiho sanposhiho left a comment

Choose a reason for hiding this comment

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

initial review path

pkg/config/config.go Outdated Show resolved Hide resolved
pkg/hpa/service.go Outdated Show resolved Hide resolved
pkg/config/config.go Outdated Show resolved Hide resolved
pkg/config/config.go Outdated Show resolved Hide resolved
Copy link
Collaborator

Choose a reason for hiding this comment

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

You haven't added any tests for this enhancement. Please always make sure you add a test for every change basically. In this case, you have to add test cases at TestClient_UpdateHPAFromTortoiseRecommendation.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I am still working on the tests.

pkg/config/config.go Outdated Show resolved Hide resolved
pkg/config/config.go Outdated Show resolved Hide resolved
@AVSBharadwaj AVSBharadwaj force-pushed the multiple-service-groups-feature branch from 343c435 to 00134fe Compare January 21, 2025 09:37
@AVSBharadwaj AVSBharadwaj force-pushed the multiple-service-groups-feature branch from d6b89b9 to c15336c Compare January 22, 2025 01:17

// Ensure ServiceGroupNames in MaximumMaxReplicas match defined ServiceGroups
serviceGroupMap := make(map[string]bool)
for _, sg := range config.ServiceGroups {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
for _, sg := range config.ServiceGroups {
for _, sg := range config.ServiceGroups {
if sg.Name == "" {
return fmt.Errorf("Name of the service group should not be empty")
}

Comment on lines +403 to +405
if seenServiceGroups[sg.Name] {
return fmt.Errorf("duplicate ServiceGroupName found: %s", sg.Name)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This duplicate check can be done in the above loop at L388.


// Check all entries in MaximumMaxReplicasPerService have non-nil ServiceGroupName
for _, maxReplicas := range config.MaximumMaxReplicasPerService {
if maxReplicas.ServiceGroupName == "" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

this empty check could be done in the above loop at 393.

Comment on lines +416 to +419
if config.MaximumMinReplicas > minOfMaximumMaxReplicas {
return fmt.Errorf("MaximumMinReplicas should be less than or equal to MaximumMaxReplicas")
}
if config.PreferredMaxReplicas >= int(config.MaximumMaxReplicas) {
if config.PreferredMaxReplicas >= int(minOfMaximumMaxReplicas) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think config.MaximumMaxReplicas and minOfMaximumMaxReplicas should be validated with PreferredMaxReplicas and MaximumMinReplicas separately for better error messages.

Copy link
Collaborator

Choose a reason for hiding this comment

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

you should add test cases for all validations that you added.

klog.InfoS("Namespace matched", "serviceGroup", serviceGroup.Name, "namespace", tortoiseNamespace)
return serviceGroup.Name
}
// TODO(avs): Add logic for matching labels in the future.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not within this PR? If you meant not to implement this within this PR, you should remove LabelSelector support from the config for now. (and add the one when you actually implement logic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants