Skip to content

Commit

Permalink
Fix dedupe on events
Browse files Browse the repository at this point in the history
  • Loading branch information
engedaam committed Jun 15, 2023
1 parent be40f2c commit bee0f04
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion pkg/controllers/provisioning/scheduling/events/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package events
import (
"fmt"
"strings"
"time"

v1 "k8s.io/api/core/v1"
"k8s.io/client-go/util/flowcontrol"
Expand Down Expand Up @@ -52,6 +53,7 @@ func PodFailedToSchedule(pod *v1.Pod, err error) events.Event {
Type: v1.EventTypeWarning,
Reason: "FailedScheduling",
Message: fmt.Sprintf("Failed to schedule pod, %s", err),
DedupeValues: []string{string(pod.UID), err.Error()},
DedupeValues: []string{string(pod.UID)},
DedupeTimeout: 5 * time.Minute,
}
}
4 changes: 3 additions & 1 deletion pkg/scheduling/requirements.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,5 +219,7 @@ func (r Requirements) Labels() map[string]string {

func (r Requirements) String() string {
requirements := lo.Reject(r.Values(), func(requirement *Requirement, _ int) bool { return v1alpha5.RestrictedLabels.Has(requirement.Key) })
return strings.Join(lo.Map(requirements, func(requirement *Requirement, _ int) string { return requirement.String() }), ", ")
stringRequirements := lo.Map(requirements, func(requirement *Requirement, _ int) string { return requirement.String() })
sort.Strings(stringRequirements)
return strings.Join(stringRequirements, ", ")
}

0 comments on commit bee0f04

Please sign in to comment.