Skip to content
This repository has been archived by the owner on Jul 13, 2022. It is now read-only.

Commit

Permalink
Do not continue loop in case of an error
Browse files Browse the repository at this point in the history
  • Loading branch information
ricoberger committed Mar 10, 2021
1 parent ca6ac84 commit 7979f6d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/exporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,27 @@ func New(projectID, username, password string) (*Exporter, error) {

func Run(interval int64, exporter *Exporter) {
for {
log.Infof("Scrape Quota and Usage Metrics")

token, err := auth.GetToken(exporter.ProjectID, exporter.Username, exporter.Password)
if err != nil {
log.WithError(err).Error("Could not get API Token")
time.Sleep(60 * time.Second)
continue
}

quota, err := api.GetQuota(exporter.ProjectID, token)
if err != nil {
log.WithError(err).Error("Could not get quota")
time.Sleep(60 * time.Second)
continue
}

usage, err := api.GetCurrentUsage(exporter.ProjectID, token)
if err != nil {
log.WithError(err).Error("Could not get current usage")
time.Sleep(60 * time.Second)
continue
}

computeCoresTotal.Reset()
Expand Down

0 comments on commit 7979f6d

Please sign in to comment.