From 99c667f5b405a6136ae3f9445b60e9f864c9a6c5 Mon Sep 17 00:00:00 2001 From: Yusuke Kato Date: Thu, 7 Nov 2024 21:56:45 +0900 Subject: [PATCH] Update internal/client/v1/client/discoverer/discover.go Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Signed-off-by: Yusuke Kato Signed-off-by: kpango --- internal/client/v1/client/discoverer/discover.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/client/v1/client/discoverer/discover.go b/internal/client/v1/client/discoverer/discover.go index b271ddc6b5..81b4a49868 100644 --- a/internal/client/v1/client/discoverer/discover.go +++ b/internal/client/v1/client/discoverer/discover.go @@ -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) } @@ -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 @@ -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) }