From 9f3d157fa4353b6feb493b3c0e8cdc5eafe6ab29 Mon Sep 17 00:00:00 2001 From: Hylke Visser Date: Wed, 26 Sep 2018 10:57:28 +0200 Subject: [PATCH] Update Go to 1.11 and Alpine to 3.8; fix fmt/vet issues --- .gitlab-ci.yml | 6 +++--- .travis.yml | 2 +- Dockerfile | 2 +- README.md | 2 +- backend/pktfwd/backend.go | 14 +++++++------- backend/pktfwd/backend_test.go | 12 ++++++------ exchange/exchange.go | 2 ++ exchange/metrics.go | 12 ++++++++++++ 8 files changed, 33 insertions(+), 19 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5f466d1..c8b8a72 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -17,7 +17,7 @@ before_script: tests: stage: test - image: golang:1.8 + image: golang:1.11 services: - thethingsnetwork/rabbitmq - redis @@ -33,7 +33,7 @@ tests: binaries: stage: build - image: golang:latest + image: golang:1.11 script: - mkdir release - export CI_BUILD_DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ) @@ -58,7 +58,7 @@ sign: - master@thethingsnetwork/gateway-connector-bridge - develop@thethingsnetwork/gateway-connector-bridge stage: sign - image: golang:latest + image: golang:1.11 script: - pushd release - shasum -a 256 $(ls) > checksums diff --git a/.travis.yml b/.travis.yml index a91163f..a499a3a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ services: - docker go: - - 1.8 + - "1.11" cache: directories: diff --git a/Dockerfile b/Dockerfile index eb8c1a1..a49df98 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM alpine +FROM alpine:3.8 RUN apk --update --no-cache add ca-certificates ADD ./release/gateway-connector-bridge-linux-amd64 /usr/local/bin/gateway-connector-bridge ADD ./assets ./assets diff --git a/README.md b/README.md index a80f368..cf6c244 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ The Things Network's `gateway-connector` protocol sends protocol buffers over MQ ## Development -- Make sure you have [Go](https://golang.org) installed (version 1.7 or later). +- Make sure you have [Go](https://golang.org) installed (recommended version 1.11, version 1.8 or later is known to work). - Set up your [Go environment](https://golang.org/doc/code.html#GOPATH). - Make sure you have [Redis](http://redis.io/download) **installed** and **running**. - Make sure you have [RabbitMQ](https://www.rabbitmq.com/download.html) and its [MQTT plugin](https://www.rabbitmq.com/mqtt.html) **installed** and **running**. diff --git a/backend/pktfwd/backend.go b/backend/pktfwd/backend.go index ddc020d..51bacf2 100644 --- a/backend/pktfwd/backend.go +++ b/backend/pktfwd/backend.go @@ -554,14 +554,14 @@ func newRXPacketFromRXPK(mac lorawan.EUI64, rxpk RXPK) (*types.UplinkMessage, er rxPacket.Message.GatewayMetadata.RSSI = float32(sig.RSSIS) } antenna := &pb_gateway.RxMetadata_Antenna{ - Antenna: uint32(sig.Ant), - Channel: uint32(sig.Chan), - ChannelRSSI: float32(sig.RSSIC), - RSSI: float32(sig.RSSIS), + Antenna: uint32(sig.Ant), + Channel: uint32(sig.Chan), + ChannelRSSI: float32(sig.RSSIC), + RSSI: float32(sig.RSSIS), RSSIStandardDeviation: float32(sig.RSSISD), - SNR: float32(sig.LSNR), - FrequencyOffset: int64(sig.FOff), - FineTime: sig.FTime, + SNR: float32(sig.LSNR), + FrequencyOffset: int64(sig.FOff), + FineTime: sig.FTime, } if eTime, err := base64.StdEncoding.DecodeString(sig.ETime); err == nil && len(eTime) > 0 { antenna.EncryptedTime = eTime diff --git a/backend/pktfwd/backend_test.go b/backend/pktfwd/backend_test.go index d13783a..c3c1446 100644 --- a/backend/pktfwd/backend_test.go +++ b/backend/pktfwd/backend_test.go @@ -314,9 +314,9 @@ func TestBackend(t *testing.T) { }, }, GatewayConfiguration: pb_gateway.TxConfiguration{ - Timestamp: 12345, - Frequency: 868100000, - Power: 14, + Timestamp: 12345, + Frequency: 868100000, + Power: 14, PolarizationInversion: true, }, Payload: []byte{1, 2, 3, 4}, @@ -444,9 +444,9 @@ func TestNewTXPKFromTXPacket(t *testing.T) { }, }, GatewayConfiguration: pb_gateway.TxConfiguration{ - Timestamp: 12345, - Frequency: 868100000, - Power: 14, + Timestamp: 12345, + Frequency: 868100000, + Power: 14, PolarizationInversion: true, }, Payload: []byte{1, 2, 3, 4}, diff --git a/exchange/exchange.go b/exchange/exchange.go index d7eb7aa..3dc35b4 100644 --- a/exchange/exchange.go +++ b/exchange/exchange.go @@ -20,6 +20,7 @@ import ( "github.com/TheThingsNetwork/gateway-connector-bridge/types" "github.com/apex/log" "github.com/deckarep/golang-set" + "github.com/spf13/viper" ) // Exchange routes messages between northbound backends (servers that are up the chain) @@ -75,6 +76,7 @@ func New(ctx log.Interface, killWhenIdleFor time.Duration) *Exchange { gateways: mapset.NewSet(), killWhenIdleFor: killWhenIdleFor, } + info.WithLabelValues(viper.GetString("buildDate"), viper.GetString("gitCommit"), viper.GetString("id"), viper.GetString("version")).Set(1) if killWhenIdleFor > 0 { e.idleWatchdog = time.AfterFunc(killWhenIdleFor, func() { ctx.Fatalf("Exchange was idle for more than %v", killWhenIdleFor) diff --git a/exchange/metrics.go b/exchange/metrics.go index d5d2b59..d70c6a9 100644 --- a/exchange/metrics.go +++ b/exchange/metrics.go @@ -9,6 +9,17 @@ import ( "github.com/prometheus/client_golang/prometheus" ) +var info = prometheus.NewGaugeVec( + prometheus.GaugeOpts{ + Namespace: "ttn", + Subsystem: "bridge", + Name: "info", + Help: "Information about the TTN environment.", + }, []string{ + "build_date", "git_commit", "id", "version", + }, +) + var connectedGateways = prometheus.NewGauge( prometheus.GaugeOpts{ Namespace: "ttn", @@ -73,6 +84,7 @@ func registerStatus() { } func init() { + prometheus.MustRegister(info) prometheus.MustRegister(connectedGateways) prometheus.MustRegister(handledCounter) for mType := lorawan.MType(0); mType < 8; mType++ {