Skip to content

Commit

Permalink
feat(pkg/operator): sort endpoints in reconciler for better perf (#5943)
Browse files Browse the repository at this point in the history
Signed-off-by: hainenber <[email protected]>
Co-authored-by: Paschalis Tsilias <[email protected]>
  • Loading branch information
hainenber and tpaschalis authored Jan 12, 2024
1 parent b76b620 commit eae8c03
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
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

0 comments on commit eae8c03

Please sign in to comment.