Skip to content

Commit

Permalink
fix: update clusternode with ip
Browse files Browse the repository at this point in the history
Signed-off-by: OrangeBao <[email protected]>
  • Loading branch information
OrangeBao committed Nov 28, 2023
1 parent b1fe778 commit 3dd1de9
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions pkg/clusterlink/agent-manager/auto_detect_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,16 @@ func (r *AutoDetectReconciler) SetupWithManager(mgr manager.Manager) error {
}

func detectIP(interfaceName string) (string, string) {
// TODO: only use ipv4, to support ipv6
detectFunc := func(version int) (string, error) {
i, _, err := autodetection.FilteredEnumeration([]string{interfaceName}, nil, nil, version)
_, n, err := autodetection.FilteredEnumeration([]string{interfaceName}, nil, nil, version)
if err != nil {
return "", fmt.Errorf("auto detect interface error: %v, version: %d", err, version)
}

if len(i.Name) == 0 {
return "", fmt.Errorf("auto detect interface error: interface name is '', version: %d", version)
if len(n.IP) == 0 {
return "", fmt.Errorf("auto detect interface error: ip is nil, version: %d", version)
}
return i.Name, nil
return n.IP.String(), nil
}

ipv4, err := detectFunc(4)
Expand Down

0 comments on commit 3dd1de9

Please sign in to comment.