-
Notifications
You must be signed in to change notification settings - Fork 84
Refactor role validation logic in validator.go #879
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
base: main
Are you sure you want to change the base?
Changes from all commits
3af3411
c5ef090
dbc7909
e29adbd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -209,15 +209,16 @@ func validateGangPolicy(ms *workloadv1alpha1.ModelServing) field.ErrorList { | |||||||||
| minRoleReplicasPath := field.NewPath("spec").Child("template").Child("gangPolicy").Child("minRoleReplicas") | ||||||||||
|
|
||||||||||
| // Create a map of role names for quick lookup | ||||||||||
| roleNames := make(map[string]bool) | ||||||||||
| roleMap := make(map[string]workloadv1alpha1.Role) | ||||||||||
| for _, role := range ms.Spec.Template.Roles { | ||||||||||
| roleNames[role.Name] = true | ||||||||||
| roleMap[role.Name] = role | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // Validate each minRoleReplicas entry | ||||||||||
| for roleName, minReplicas := range minRoleReplicas { | ||||||||||
| // Check if the role exists | ||||||||||
| if !roleNames[roleName] { | ||||||||||
| roleElement, ok := roleMap[roleName] | ||||||||||
| if !ok { | ||||||||||
| allErrs = append(allErrs, field.Invalid( | ||||||||||
| minRoleReplicasPath.Key(roleName), | ||||||||||
| roleName, | ||||||||||
|
|
@@ -226,35 +227,30 @@ func validateGangPolicy(ms *workloadv1alpha1.ModelServing) field.ErrorList { | |||||||||
| continue | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // Find the role to check its actual replicas | ||||||||||
| for _, role := range ms.Spec.Template.Roles { | ||||||||||
| if role.Name == roleName { | ||||||||||
| /// Calculate total replicas for this role | ||||||||||
| // minRoleReplicas is compared against the number of Role replicas | ||||||||||
| replicas := int32(1) | ||||||||||
| if role.Replicas != nil { | ||||||||||
| replicas = *role.Replicas | ||||||||||
| } | ||||||||||
| // Find the role in the roleMap then check its actual replicas | ||||||||||
| /// Calculate total replicas for this role | ||||||||||
|
||||||||||
| /// Calculate total replicas for this role | |
| // Calculate total replicas for this role |
Copilot
AI
Apr 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The triple-slash comment marker (///) is inconsistent with typical Go commenting style and reads like an accidental duplication. Please replace with a normal // comment (or remove if redundant) to keep comments consistent and avoid confusion.
| /// Calculate total replicas for this role | |
| // Calculate total replicas for this role |
Uh oh!
There was an error while loading. Please reload this page.