Adjust first node-ip based on configured clusterCIDR

Signed-off-by: Roberto Bonafiglia <roberto.bonafiglia@suse.com>
pull/9669/head
Roberto Bonafiglia 2024-02-16 16:52:41 +01:00 committed by Roberto Bonafiglia
parent 29de58c778
commit 1f44f83627
1 changed files with 8 additions and 0 deletions

View File

@ -447,6 +447,14 @@ func get(ctx context.Context, envInfo *cmds.Agent, proxy proxy.Proxy) (*config.N
} }
} }
if controlConfig.ClusterIPRange != nil {
if utilsnet.IPFamilyOfCIDR(controlConfig.ClusterIPRange) != utilsnet.IPFamilyOf(nodeIPs[0]) && len(nodeIPs) > 1 {
firstNodeIP := nodeIPs[0]
nodeIPs[0] = nodeIPs[1]
nodeIPs[1] = firstNodeIP
}
}
nodeExternalIPs, err := util.ParseStringSliceToIPs(envInfo.NodeExternalIP) nodeExternalIPs, err := util.ParseStringSliceToIPs(envInfo.NodeExternalIP)
if err != nil { if err != nil {
return nil, fmt.Errorf("invalid node-external-ip: %w", err) return nil, fmt.Errorf("invalid node-external-ip: %w", err)