Skip to content

Commit

Permalink
Merge pull request #7 from sgnsys3/main
Browse files Browse the repository at this point in the history
checking for datastore is being deleted
  • Loading branch information
janfuhrer authored Jan 8, 2024
2 parents fbafad0 + aa2a43f commit e5bbbfb
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"log"
"net/http"
"os"
"regexp"
"strconv"
"time"

Expand Down Expand Up @@ -491,6 +492,17 @@ func (e *Exporter) getDatastoreMetric(datastore Datastore, ch chan<- prometheus.

// check if status code is 200
if resp.StatusCode != 200 {
if resp.StatusCode == 400 {
// check if datastore is being deleted
isBeingDeleted, err := regexp.MatchString("(?i)datastore is being deleted", string(body[:]))
if err != nil {
return err
}
if isBeingDeleted {
log.Printf("INFO: Datastore: %s is being deleted, Skip scrape datastore metric", datastore.Store)
return nil
}
}
return fmt.Errorf("ERROR: --Status code %d returned from endpoint: %s", resp.StatusCode, e.endpoint)
}

Expand Down

0 comments on commit e5bbbfb

Please sign in to comment.