diff --git a/.travis.yml b/.travis.yml index bf71152..4f474e6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ sudo: required dist: trusty go: - - 1.9.2 + - 1.13 env: - DOCKER_TAG=$TRAVIS_TAG diff --git a/Dockerfile b/Dockerfile index 0c03bec..6c9ebd1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,7 +17,7 @@ RUN apt-get update && \ RUN \ mkdir -p /goroot && \ - curl https://storage.googleapis.com/golang/go1.9.2.linux-amd64.tar.gz | tar xvzf - -C /goroot --strip-components=1 + curl https://storage.googleapis.com/golang/go1.13.linux-amd64.tar.gz | tar xvzf - -C /goroot --strip-components=1 ADD . $APPLOC WORKDIR $APPLOC diff --git a/Makefile.COMMON b/Makefile.COMMON index f8aa1b3..9198cf9 100644 --- a/Makefile.COMMON +++ b/Makefile.COMMON @@ -44,7 +44,7 @@ SRC ?= $(shell find . -type f -name "*.go" ! -path "./.build/*") GOOS ?= $(shell uname | tr A-Z a-z) GOARCH ?= $(subst x86_64,amd64,$(patsubst i%86,386,$(shell uname -m))) -GO_VERSION ?= 1.5.3 +GO_VERSION ?= 1.13 # Check for the correct version of go in the path. If we find it, use it. # Otherwise, prepare to build go locally. diff --git a/collectors/osd.go b/collectors/osd.go index 5d38373..8c76ef2 100644 --- a/collectors/osd.go +++ b/collectors/osd.go @@ -5,6 +5,7 @@ import ( "encoding/json" "fmt" "log" + "math" "regexp" "strconv" @@ -820,11 +821,11 @@ func (o *OSDCollector) collectPGRecoveryState(ch chan<- prometheus.Metric) error // We need previous PG state in order to update the metric when a PG has // completed recovery or backfill. Or it could be an empty string if // unknown. - prevPGState := o.pgStateCache[pg.PGID] + prevPGState, prevPGStateFound := o.pgStateCache[pg.PGID] prevNumObjectsRecovered := o.pgObjectsRecoveredCache[pg.PGID] prevBackfillTargets := o.pgBackfillTargetsCache[pg.PGID] - if prevPGState == "" || strings.Contains(prevPGState, "recovering") || strings.Contains(pg.State, "recovering") || + if !prevPGStateFound || strings.Contains(prevPGState, "recovering") || strings.Contains(pg.State, "recovering") || strings.Contains(prevPGState, "backfilling") || strings.Contains(pg.State, "backfilling") { query, err := o.performPGQuery(pg.PGID) if err != nil { @@ -845,7 +846,9 @@ func (o *OSDCollector) collectPGRecoveryState(ch chan<- prometheus.Metric) error } // Average out the total number of objects backfilled to each OSD - eachOSDIncrease := float64(o.pgObjectsRecoveredCache[pg.PGID]-prevNumObjectsRecovered) / float64(len(prevBackfillTargets)) + // The average number rounds to the nearest integer, rounding half + // away from zero. + eachOSDIncrease := math.Round(float64(o.pgObjectsRecoveredCache[pg.PGID]-prevNumObjectsRecovered) / float64(len(prevBackfillTargets))) for osdID := range prevBackfillTargets { // It is possible that osdID has gone from the backfill_targets