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 99c667f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/client/v1/client/discoverer/discover.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ func (c *client) discover(ctx context.Context) (err error) {
}

oldAddrs := c.GetAddrs(ctx)
log.Debug("discovered connected IPs: %v", connected)
c.addrs.Store(&connected)
return c.disconnectOldAddrs(ctx, oldAddrs, connected)
}
Expand Down Expand Up @@ -358,6 +359,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())
})
return nodes, nil
Expand Down Expand Up @@ -403,6 +407,7 @@ func (c *client) discoverAddrs(
log.Debugf("resource based discovery connect from discoverer API for addr = %s failed %v", addr, errors.ErrAddrCouldNotDiscover(err, addr))
err = nil
} else {
log.Debugf("discovered healthy pods IP: %s, Node Usage: %f, Pod Usage: %f", addr, node.GetMemory().GetUsage(), node.GetPods().GetPods()[i].GetMemory().GetUsage()
addrs = append(addrs, addr)
}

Expand Down

0 comments on commit 99c667f

Please sign in to comment.