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
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Main (unreleased)

- Add an option to the windows static mode installer for expanding environment vars in the yaml config. (@erikbaranowski)

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

### Bugfixes

- Fix an issue in `remote.s3` where the exported content of an object would be an empty string if `remote.s3` failed to fully retrieve
Expand Down
7 changes: 7 additions & 0 deletions pkg/operator/kubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package operator
import (
"context"
"fmt"
"sort"

"github.com/go-kit/log"
"github.com/go-kit/log/level"
Expand Down Expand Up @@ -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
}

Expand Down
Loading