Skip to content

Commit

Permalink
Fallback to get host IP when nodeIP is empty
Browse files Browse the repository at this point in the history
Signed-off-by: Zou Yulin <[email protected]>
  • Loading branch information
yulinzou authored and lrq619 committed Jun 3, 2024
1 parent 114042e commit 4dccf25
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions scripts/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ func InstallYQ() {

func GetNodeIP() (string, error) {
// Choose the first ip address starting from 10.
nodeIP, err := ExecShellCmd(`ip route | awk '{print $(NF)}' | awk '/^10\..*/ {print; exit}'`)
if err == nil {
nodeIP, err := ExecShellCmd(`ip route | awk '/ src / {for(i=1; i<=NF; i++) if ($i == "src") print $(i+1)}' | awk '/^10\..*/ {print; exit}'`)
if (nodeIP != "") && (err == nil) {
return nodeIP, nil
}

Expand Down

0 comments on commit 4dccf25

Please sign in to comment.