Skip to content

Commit 590baa2

Browse files
committed
print all scheduler names if not uniq
Signed-off-by: kangclzjc <kangz@nvidia.com>
1 parent ee85576 commit 590baa2

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

operator/api/config/v1alpha1/defaults.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ func SetDefaults_OperatorConfiguration(operatorConfig *OperatorConfiguration) {
7373
// Principle: respect all user-explicit values first.
7474
//
7575
// 1. If user did not include kube in profiles, add kube. Whether kube is default: only if no other profile is default, set kube as default.
76-
// 2. If user did not set any default (no profile has default: true), set kube as default (only when we added kube above — do not override user's explicit kube default: false).
77-
// Otherwise (one non-kube default, or two+ defaults) we do not change; validation will reject invalid cases.
76+
// 2. If user did not set any default (no profile has default: true), set kube as default. Validation will reject invalid cases.
7877
func SetDefaults_SchedulerConfiguration(cfg *SchedulerConfiguration) {
7978
if len(cfg.Profiles) == 0 {
8079
cfg.Profiles = []SchedulerProfile{
@@ -110,8 +109,7 @@ func SetDefaults_SchedulerConfiguration(cfg *SchedulerConfiguration) {
110109
return
111110
}
112111
// 2. No default → set kube as default.
113-
// Only set kube as default if user did not explicitly set kube as default.
114-
if defaultCount == 0 && !hasKube {
112+
if defaultCount == 0 {
115113
cfg.Profiles[kubeIdx].Default = true
116114
}
117115
}

operator/internal/webhook/admission/pcs/validation/podcliqueset.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,26 +150,22 @@ func (v *pcsValidator) validatePodCliqueTemplates(fldPath *field.Path) ([]string
150150
if def := schedulerbackend.GetDefault(); def != nil {
151151
return def.Name()
152152
}
153-
return "default-scheduler" // fallback when backend not initialized (e.g. in tests)
153+
return "default-scheduler"
154154
}
155155
return item
156156
}))
157157
if len(uniqueSchedulerNames) > 1 {
158-
allErrs = append(allErrs, field.Invalid(fldPath.Child("spec").Child("podSpec").Child("schedulerName"), uniqueSchedulerNames[0], "the schedulerName for all pods have to be the same"))
158+
allErrs = append(allErrs, field.Invalid(fldPath.Child("spec").Child("podSpec").Child("schedulerName"), strings.Join(uniqueSchedulerNames, ", "), "the schedulerName for all pods have to be the same"))
159159
}
160160

161161
// Validate that the scheduler name is enabled (present in OperatorConfiguration profiles or default)
162162
pcsSchedulerName := ""
163163
if len(uniqueSchedulerNames) > 0 && uniqueSchedulerNames[0] != "" {
164164
pcsSchedulerName = uniqueSchedulerNames[0]
165165
}
166-
if pcsSchedulerName == "" {
167-
if def := schedulerbackend.GetDefault(); def != nil {
168-
pcsSchedulerName = def.Name()
169-
}
170-
}
166+
171167
// default-scheduler is the pod-facing name for kube-scheduler and is always accepted when kube backend is enabled
172-
if pcsSchedulerName != "" && pcsSchedulerName != "default-scheduler" && schedulerbackend.Get(pcsSchedulerName) == nil {
168+
if pcsSchedulerName != "default-scheduler" && schedulerbackend.Get(pcsSchedulerName) == nil {
173169
allErrs = append(allErrs, field.Invalid(
174170
fldPath.Child("spec").Child("podSpec").Child("schedulerName"),
175171
pcsSchedulerName,

0 commit comments

Comments
 (0)