Skip to content

Commit

Permalink
perf: trade off less verbose errors for faster execution (kubernetes-…
Browse files Browse the repository at this point in the history
  • Loading branch information
tzneal authored Feb 19, 2025
1 parent fa5020a commit 5687906
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkg/scheduling/requirements.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func (r Requirements) IsCompatible(requirements Requirements, options ...option.
}

// Compatible ensures the provided requirements can loosely be met.
func (r Requirements) Compatible(requirements Requirements, options ...option.Function[CompatibilityOptions]) (errs error) {
func (r Requirements) Compatible(requirements Requirements, options ...option.Function[CompatibilityOptions]) error {
opts := option.Resolve(options...)

// Custom Labels must intersect, but if not defined are denied.
Expand All @@ -183,10 +183,11 @@ func (r Requirements) Compatible(requirements Requirements, options ...option.Fu
if operator := requirements.Get(key).Operator(); r.Has(key) || operator == corev1.NodeSelectorOpNotIn || operator == corev1.NodeSelectorOpDoesNotExist {
continue
}
errs = multierr.Append(errs, fmt.Errorf("label %q does not have known values%s", key, labelHint(r, key, opts.AllowUndefined)))
// break early so we only report the first error
return fmt.Errorf("label %q does not have known values%s", key, labelHint(r, key, opts.AllowUndefined))
}
// Well Known Labels must intersect, but if not defined, are allowed.
return multierr.Append(errs, r.Intersects(requirements))
return r.Intersects(requirements)
}

func getSuffix(key string) string {
Expand Down

0 comments on commit 5687906

Please sign in to comment.