From 3a18622b321b26d46584138f3ae990f564bdf45b Mon Sep 17 00:00:00 2001 From: DuodenumL Date: Tue, 23 Nov 2021 16:28:44 +0800 Subject: [PATCH] set the unreachable nodes as unavailable (#508) --- rpc/transform.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rpc/transform.go b/rpc/transform.go index 2588e17a6..765006b5c 100644 --- a/rpc/transform.go +++ b/rpc/transform.go @@ -51,7 +51,9 @@ func toRPCNetwork(n *enginetypes.Network) *pb.Network { func toRPCNode(ctx context.Context, n *types.Node) *pb.Node { var nodeInfo string - if info, err := n.Info(ctx); err == nil { + var info *enginetypes.Info + var err error + if info, err = n.Info(ctx); err == nil { bytes, _ := json.Marshal(info) nodeInfo = string(bytes) } else { @@ -70,7 +72,7 @@ func toRPCNode(ctx context.Context, n *types.Node) *pb.Node { StorageUsed: n.StorageUsed(), Volume: n.Volume, VolumeUsed: n.VolumeUsed, - Available: n.Available, + Available: n.Available && err == nil, Labels: n.Labels, InitCpu: toRPCCPUMap(n.InitCPU), InitMemory: n.InitMemCap,