Skip to content

Commit

Permalink
Update internal/client/v1/client/discoverer/discover.go
Browse files Browse the repository at this point in the history
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Signed-off-by: Yusuke Kato <[email protected]>
Signed-off-by: kpango <[email protected]>
  • Loading branch information
kpango and coderabbitai[bot] committed Nov 8, 2024
1 parent 3f18b2b commit 2386fc6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
10 changes: 6 additions & 4 deletions internal/client/v1/client/discoverer/discover.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,9 @@ func (c *client) discoverNodes(ctx context.Context) (nodes *payload.Info_Nodes,
return nil, err
}
slices.SortFunc(nodes.Nodes, func(left, right *payload.Info_Node) int {
if left.GetMemory() == nil || right.GetMemory() == nil {
return 0 // Default comparison value; adjust as needed.
}
return cmp.Compare(left.GetMemory().GetUsage(), right.GetMemory().GetUsage())

Check warning on line 364 in internal/client/v1/client/discoverer/discover.go

View check run for this annotation

Codecov / codecov/patch

internal/client/v1/client/discoverer/discover.go#L357-L364

Added lines #L357 - L364 were not covered by tests
})
return nodes, nil

Check warning on line 366 in internal/client/v1/client/discoverer/discover.go

View check run for this annotation

Codecov / codecov/patch

internal/client/v1/client/discoverer/discover.go#L366

Added line #L366 was not covered by tests
Expand All @@ -379,14 +382,13 @@ func (c *client) discoverAddrs(
maxPodLen = l
}
slices.SortFunc(nodes.Nodes[i].Pods.Pods, func(left, right *payload.Info_Pod) int {
if left.GetMemory() == nil || right.GetMemory() == nil {
return 0 // Default comparison value; adjust as needed.
}
return cmp.Compare(left.GetMemory().GetUsage(), right.GetMemory().GetUsage())

Check warning on line 388 in internal/client/v1/client/discoverer/discover.go

View check run for this annotation

Codecov / codecov/patch

internal/client/v1/client/discoverer/discover.go#L377-L388

Added lines #L377 - L388 were not covered by tests
})
}
}
nbody, err := nodes.MarshalJSON()
if err == nil && nbody != nil {
log.Debug(string(nbody))
}
addrs = make([]string, 0, podLength)
for i := 0; i < maxPodLen; i++ {
for _, node := range nodes.GetNodes() {
Expand Down
5 changes: 0 additions & 5 deletions pkg/index/job/correction/usecase/corrector.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package usecase
import (
"context"
"os"
"slices"
"syscall"
"time"

Expand Down Expand Up @@ -86,10 +85,6 @@ func New(cfg *config.Data) (r runner.Runner, err error) {
discoverer.WithDiscoverDuration(cfg.Corrector.Discoverer.Duration),
discoverer.WithOptions(acOpts...),
discoverer.WithNodeName(cfg.Corrector.NodeName),
discoverer.WithOnDiscoverFunc(func(_ context.Context, _ discoverer.Client, addrs []string) error {
slices.Reverse(addrs)
return nil
}),
)
if err != nil {
return nil, err
Expand Down

0 comments on commit 2386fc6

Please sign in to comment.