Skip to content

Commit

Permalink
Merge pull request #303 from OrangeBao/feat_autodetect
Browse files Browse the repository at this point in the history
fix: update clusternode with ip
  • Loading branch information
kosmos-robot committed Nov 28, 2023
2 parents b1fe778 + 3dd1de9 commit 8af15a0
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 8af15a0

Please sign in to comment.