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(pkg/operator): sort endpoints in reconciler for better perf #5943

Merged
merged 4 commits into from
Jan 12, 2024
Merged
Changes from 1 commit
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
Next Next commit
feat(pkg/operator): sort endpoints in reconciler for better perf
Signed-off-by: hainenber <[email protected]>
hainenber committed Dec 9, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 1c0c8b59423296d7ab970ba1d5612ba9a21f1b96
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -53,6 +53,8 @@ Main (unreleased)

- Fixes `loki.source.docker` a behavior that synced an incomplete list of targets to the tailer manager. (@FerdinandvHagen)

- Sort kubelet endpoint to reduce pressure on K8s's API server and watcher endpoints. (@hainenber)

### Other changes

- Bump github.com/IBM/sarama from v1.41.2 to v1.42.1
7 changes: 7 additions & 0 deletions pkg/operator/kubelet.go
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ package operator
import (
"context"
"fmt"
"sort"

"github.com/go-kit/log"
"github.com/go-kit/log/level"
@@ -126,6 +127,12 @@ func getNodeAddrs(l log.Logger, nodes *core_v1.NodeList) (addrs []core_v1.Endpoi
if failed {
return nil, fmt.Errorf("failed to get the address from one or more nodes")
}

// Sort endpoints to reduce performance cost on endpoint watchers
sort.SliceStable(addrs, func(i, j int) bool {
return addrs[i].IP < addrs[j].IP
})

return
}