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

feat: Add warning on duplicate clients for round-robin and shuffle schedulers #1878

Merged
merged 2 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions scheduler/scheduler_round_robin.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ func (s *syncClient) syncRoundRobin(ctx context.Context, resolvedResources chan<
if table.Multiplex != nil {
clients = table.Multiplex(s.client)
}
// Detect duplicate clients while multiplexing
seenClients := make(map[string]bool)
for _, c := range clients {
if _, ok := seenClients[c.ID()]; !ok {
seenClients[c.ID()] = true
} else {
s.logger.Warn().Str("client", c.ID()).Str("table", table.Name).Msg("multiplex returned duplicate client")
}
}
preInitialisedClients[i] = clients
// we do this here to avoid locks so we initial the metrics structure once in the main goroutines
// and then we can just read from it in the other goroutines concurrently given we are not writing to it.
Expand Down
9 changes: 9 additions & 0 deletions scheduler/scheduler_shuffle.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ func (s *syncClient) syncShuffle(ctx context.Context, resolvedResources chan<- *
if table.Multiplex != nil {
clients = table.Multiplex(s.client)
}
// Detect duplicate clients while multiplexing
seenClients := make(map[string]bool)
for _, c := range clients {
if _, ok := seenClients[c.ID()]; !ok {
seenClients[c.ID()] = true
} else {
s.logger.Warn().Str("client", c.ID()).Str("table", table.Name).Msg("multiplex returned duplicate client")
}
}
preInitialisedClients[i] = clients
// we do this here to avoid locks so we initial the metrics structure once in the main goroutines
// and then we can just read from it in the other goroutines concurrently given we are not writing to it.
Expand Down