Update go1.13 (in order to use Math.Round), and address comments

This commit is contained in:
Yue Zhu 2019-10-01 12:13:36 -04:00
parent f31a0e9c39
commit d1ca787cd4
4 changed files with 9 additions and 6 deletions

View File

@ -3,7 +3,7 @@ sudo: required
dist: trusty
go:
- 1.9.2
- 1.13
env:
- DOCKER_TAG=$TRAVIS_TAG

View File

@ -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

View File

@ -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.

View File

@ -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