Skip to content

Commit

Permalink
print error when loading validator names from inventory failed
Browse files Browse the repository at this point in the history
  • Loading branch information
pk910 committed Aug 17, 2023
1 parent 260cb8a commit 95269c4
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions services/validatornames.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,18 @@ type validatorNamesRangesResponse struct {
func (vn *ValidatorNames) LoadFromRangesApi(apiUrl string) error {
vn.namesMutex.Lock()
defer vn.namesMutex.Unlock()
logrus.Debugf("Loading validator names from inventory: %v", apiUrl)

client := &http.Client{Timeout: time.Second * 120}
resp, err := client.Get(apiUrl)
if err != nil {
logrus.Errorf("Could not fetch validator names from inventory (%v): %v", apiUrl, err)
return err
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
if resp.StatusCode == http.StatusNotFound {
logrus.Errorf("Could not fetch validator names from inventory (%v): not found", apiUrl)
return nil
}
data, _ := ioutil.ReadAll(resp.Body)
Expand Down

0 comments on commit 95269c4

Please sign in to comment.