fix: prevent panic on health check if a member has no IPs

If a member has no IP addresses, prevent cluster health checks from failing with a panic by checking for the length of member IPs and not assuming there's always at least 1 IP.

Signed-off-by: Utku Ozdemir <utku.ozdemir@siderolabs.com>
This commit is contained in:
Utku Ozdemir 2022-09-02 14:59:46 +02:00
parent 7471d7f017
commit 0847400f72
No known key found for this signature in database
GPG Key ID: 65933E76F0549B0D

View File

@ -5,6 +5,7 @@
package check
import (
"fmt"
"net/netip"
"github.com/talos-systems/talos/pkg/cluster"
@ -72,6 +73,10 @@ func memberToNodeInfo(member *clussterres.Member) (cluster.NodeInfo, error) {
return cluster.NodeInfo{}, err
}
if len(ips) == 0 {
return cluster.NodeInfo{}, fmt.Errorf("no IP address found for member: %s", member.Metadata().ID())
}
return cluster.NodeInfo{
InternalIP: ips[0],
IPs: ips,