From 0b57e3472954d6f18c51dd5c69a1ccd632a4d00f Mon Sep 17 00:00:00 2001 From: Reuben Rodrigues Date: Fri, 30 Apr 2021 12:55:34 +0000 Subject: [PATCH] cmd: Handle error for invalid inferred O public IP --- CHANGELOG_PENDING.md | 1 + cmd/livepeer/livepeer.go | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG_PENDING.md b/CHANGELOG_PENDING.md index ccc79f9476..74081bd028 100644 --- a/CHANGELOG_PENDING.md +++ b/CHANGELOG_PENDING.md @@ -26,5 +26,6 @@ #### Orchestrator - \#1860 Discard low gas prices to prevent insufficient ticket faceValue errors (@kyriediculous) +- \#1859 Handle error for invalid inferred orchestrator public IP on node startup (@reubenr0d) #### Transcoder diff --git a/cmd/livepeer/livepeer.go b/cmd/livepeer/livepeer.go index d2ca4dc7f5..f4eedd8a82 100644 --- a/cmd/livepeer/livepeer.go +++ b/cmd/livepeer/livepeer.go @@ -1012,17 +1012,21 @@ func getServiceURI(n *core.LivepeerNode, serviceAddr string) (*url.URL, error) { // TODO probably should put this (along w wizard GETs) into common code resp, err := http.Get("https://api.ipify.org?format=text") if err != nil { - glog.Error("Could not look up public IP address") + glog.Errorf("Could not look up public IP err=%v", err) return nil, err } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { - glog.Error("Could not look up public IP address") + glog.Errorf("Could not look up public IP err=%v", err) return nil, err } addr := "https://" + strings.TrimSpace(string(body)) + ":" + RpcPort inferredUri, err := url.ParseRequestURI(addr) + if err != nil { + glog.Errorf("Could not look up public IP err=%v", err) + return nil, err + } if n.Eth == nil { // we won't be looking up onchain sURI so use the inferred one return inferredUri, err @@ -1031,12 +1035,12 @@ func getServiceURI(n *core.LivepeerNode, serviceAddr string) (*url.URL, error) { // On-chain lookup and matching with inferred public address addr, err = n.Eth.GetServiceURI(n.Eth.Account().Address) if err != nil { - glog.Error("Could not get service URI; orchestrator may be unreachable") + glog.Errorf("Could not get service URI; orchestrator may be unreachable err=%v", err) return nil, err } ethUri, err := url.ParseRequestURI(addr) if err != nil { - glog.Error("Could not parse service URI; orchestrator may be unreachable") + glog.Errorf("Could not parse service URI; orchestrator may be unreachable err=%v", err) ethUri, _ = url.ParseRequestURI("http://127.0.0.1:" + RpcPort) } if ethUri.Hostname() != inferredUri.Hostname() || ethUri.Port() != inferredUri.Port() {