Skip to content

Commit

Permalink
Merge branch 'master' into fix-series-sample-limit
Browse files Browse the repository at this point in the history
  • Loading branch information
bwplotka authored Jul 10, 2020
2 parents 61d8981 + 7bb9eea commit 8982200
Show file tree
Hide file tree
Showing 46 changed files with 1,262 additions and 712 deletions.
6 changes: 0 additions & 6 deletions .bingo/Variables.mk
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,6 @@ $(MINIO): .bingo/minio.mod
@echo "(re)installing $(GOBIN)/minio-v0.0.0-20200527010300-cccf2de129da"
@cd .bingo && $(GO) build -modfile=minio.mod -o=$(GOBIN)/minio-v0.0.0-20200527010300-cccf2de129da "github.com/minio/minio"

MISSPELL := $(GOBIN)/misspell-v0.3.4
$(MISSPELL): .bingo/misspell.mod
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
@echo "(re)installing $(GOBIN)/misspell-v0.3.4"
@cd .bingo && $(GO) build -modfile=misspell.mod -o=$(GOBIN)/misspell-v0.3.4 "github.com/client9/misspell/cmd/misspell"

PROMETHEUS_ARRAY := $(GOBIN)/prometheus-v2.4.3+incompatible $(GOBIN)/prometheus-v1.8.2-0.20200507164740-ecee9c8abfd1
$(PROMETHEUS_ARRAY): .bingo/prometheus.mod .bingo/prometheus.1.mod
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
Expand Down
5 changes: 0 additions & 5 deletions .bingo/misspell.mod

This file was deleted.

2 changes: 0 additions & 2 deletions .bingo/variables.env
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ LICHE="${gobin}/liche-v0.0.0-20181124191719-2a2e6e56f6c6"

MINIO="${gobin}/minio-v0.0.0-20200527010300-cccf2de129da"

MISSPELL="${gobin}/misspell-v0.3.4"

PROMETHEUS_ARRAY="${gobin}/prometheus-v2.4.3+incompatible${gobin}/prometheus-v1.8.2-0.20200507164740-ecee9c8abfd1"

PROMTOOL="${gobin}/promtool-v1.8.2-0.20200522113006-f4dd45609a05"
Expand Down
46 changes: 26 additions & 20 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,40 +29,46 @@ output:

linters:
enable:
# Sorted alphabetically.
- deadcode
- errcheck
- goconst
- godot
- gofmt
- goimports
- gosimple
- govet
- ineffassign
- misspell
- staticcheck
- structcheck
- typecheck
- unparam
- unused
- varcheck

linters-settings:
errcheck:
exclude: ./.errcheck_excludes.txt
errcheck:
exclude: ./.errcheck_excludes.txt
misspell:
locale: US

issues:
exclude-rules:
# These are not being checked since these methods exist
# so that no one else could implement them.
- linters:
- unused
text: "SourceStoreAPI.implementsStoreAPI"
- linters:
- unused
text: "SourceStoreAPI.producesBlocks"
- linters:
- unused
text: "Source.producesBlocks"
- linters:
- unused
text: "newMockAlertmanager"
- linters:
- unused
text: "ruleAndAssert"
exclude-rules:
# These are not being checked since these methods exist
# so that no one else could implement them.
- linters:
- unused
text: "SourceStoreAPI.implementsStoreAPI"
- linters:
- unused
text: "SourceStoreAPI.producesBlocks"
- linters:
- unused
text: "Source.producesBlocks"
- linters:
- unused
text: "newMockAlertmanager"
- linters:
- unused
text: "ruleAndAssert"
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@ We use *breaking* word for marking changes that are not backward compatible (rel

### Fixed

* [#2665](https://github.com/thanos-io/thanos/pull/2665) Swift: fix issue with missing Content-Type HTTP headers.
- [#2665](https://github.com/thanos-io/thanos/pull/2665) Swift: fix issue with missing Content-Type HTTP headers.
- [#2800](https://github.com/thanos-io/thanos/pull/2800) Query: Fix handling of `--web.external-prefix` and `--web.route-prefix`
- [#2834](https://github.com/thanos-io/thanos/pull/2834) Query: Fix rendered JSON state value for rules and alerts should be in lowercase
- [#2858](https://github.com/thanos-io/thanos/pull/2858) Store: Fix `--store.grpc.series-sample-limit` implementation. The limit is now applied to the sum of all samples fetched across all queried blocks via a single Series call, instead of applying it individually to each block.
- [#2866](https://github.com/thanos-io/thanos/pull/2866) Receive, Querier: Fixed leaks on receive and qwuerier Store API Series, which were leaking on errors.

### Changed
### Added
- [#2832](https://github.com/thanos-io/thanos/pull/2832) ui: React: Add runtime and build info page

- [#2305](https://github.com/thanos-io/thanos/pull/2305) Receive,Sidecar,Ruler: Propagate correct (stricter) MinTime for no-block TSDBs.

## [v0.14.0](https://github.com/thanos-io/thanos/releases) - IN PROGRESS

Expand Down
13 changes: 2 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,9 @@ check-docs: $(EMBEDMD) $(LICHE) build
@find . -type f -name "*.md" | SED_BIN="$(SED)" xargs scripts/cleanup-white-noise.sh
$(call require_clean_work_tree,"check documentation")

.PHONY: check-comments
check-comments: ## Checks Go code comments if they have trailing period (excludes protobuffers and vendor files). Comments with more than 3 spaces at beginning are omitted from the check, example: '// - foo'.
@printf ">> checking Go comments trailing periods\n\n\n"
@./scripts/build-check-comments.sh

.PHONY: format
format: ## Formats Go code including imports and cleans up white noise.
format: $(GOIMPORTS) check-comments
format: $(GOIMPORTS)
@echo ">> formatting code"
@gofmt -s -w $(FILES_TO_FMT)
@$(GOIMPORTS) -w $(FILES_TO_FMT)
Expand Down Expand Up @@ -261,7 +256,7 @@ lint: go-lint react-app-lint
# --mem-profile-path string Path to memory profile output file
# to debug big allocations during linting.
.PHONY: go-lint
go-lint: check-git deps $(GOLANGCI_LINT) $(MISSPELL) $(FAILLINT)
go-lint: check-git deps $(GOLANGCI_LINT) $(FAILLINT)
$(call require_clean_work_tree,"detected not clean master before running lint")
@echo ">> verifying modules being imported"
@# TODO(bwplotka): Add, Printf, DefaultRegisterer, NewGaugeFunc and MustRegister once exception are accepted. Add fmt.{Errorf}=github.com/pkg/errors.{Errorf} once https://github.com/fatih/faillint/issues/10 is addressed.
Expand All @@ -273,12 +268,8 @@ github.com/prometheus/client_golang/prometheus.{NewCounter,NewCounterVec,NewCoun
NewHistorgram,NewHistogramVec,NewSummary,NewSummaryVec}=github.com/prometheus/client_golang/prometheus/promauto.{NewCounter,\
NewCounterVec,NewCounterVec,NewGauge,NewGaugeVec,NewGaugeFunc,NewHistorgram,NewHistogramVec,NewSummary,NewSummaryVec}" ./...
@$(FAILLINT) -paths "fmt.{Print,Println,Sprint}" -ignore-tests ./...
@echo ">> examining all of the Go files"
@go vet -stdmethods=false ./pkg/... ./cmd/... && go vet doc.go
@echo ">> linting all of the Go files GOGC=${GOGC}"
@$(GOLANGCI_LINT) run
@echo ">> detecting misspells"
@find . -type f | grep -v vendor/ | grep -v pkg/ui/react-app/node_modules | grep -v pkg/ui/static | grep -vE '\./\..*' | xargs $(MISSPELL) -error
@echo ">> detecting white noise"
@find . -type f \( -name "*.md" -o -name "*.go" \) | SED_BIN="$(SED)" xargs scripts/cleanup-white-noise.sh
$(call require_clean_work_tree,"detected white noise")
Expand Down
2 changes: 2 additions & 0 deletions cmd/thanos/config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) The Thanos Authors.
// Licensed under the Apache License 2.0.

//nolint:unparam
// TODO(kakkoyun): Fix linter issues - The pattern we use makes linter unhappy (returning unused config pointers).
package main

import (
Expand Down
36 changes: 35 additions & 1 deletion cmd/thanos/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"fmt"
"math"
"net/http"
"os"
"runtime"
"strings"
"time"

Expand All @@ -19,6 +21,7 @@ import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/prometheus/common/route"
"github.com/prometheus/common/version"
"github.com/prometheus/prometheus/discovery/file"
"github.com/prometheus/prometheus/discovery/targetgroup"
"github.com/prometheus/prometheus/pkg/labels"
Expand Down Expand Up @@ -412,9 +415,38 @@ func runQuery(
router = router.WithPrefix(webRoutePrefix)
}

buildInfo := &v1.ThanosVersion{
Version: version.Version,
Revision: version.Revision,
Branch: version.Branch,
BuildUser: version.BuildUser,
BuildDate: version.BuildDate,
GoVersion: version.GoVersion,
}

CWD, err := os.Getwd()
if err != nil {
CWD = "<error retrieving current working directory>"
level.Warn(logger).Log("msg", "failed to retrieve current working directory", "err", err)
}

birth := time.Now()

var runtimeInfo v1.RuntimeInfoFn = func() v1.RuntimeInfo {
status := v1.RuntimeInfo{
StartTime: birth,
CWD: CWD,
GoroutineCount: runtime.NumGoroutine(),
GOMAXPROCS: runtime.GOMAXPROCS(0),
GOGC: os.Getenv("GOGC"),
GODEBUG: os.Getenv("GODEBUG"),
}
return status
}

ins := extpromhttp.NewInstrumentationMiddleware(reg)
// TODO(bplotka in PR #513 review): pass all flags, not only the flags needed by prefix rewriting.
ui.NewQueryUI(logger, reg, stores, webExternalPrefix, webPrefixHeaderName).Register(router, ins)
ui.NewQueryUI(logger, reg, stores, webExternalPrefix, webPrefixHeaderName, runtimeInfo, *buildInfo).Register(router, ins)

api := v1.NewAPI(
logger,
Expand All @@ -431,6 +463,8 @@ func runQuery(
flagsMap,
instantDefaultMaxSourceResolution,
maxConcurrentQueries,
runtimeInfo,
buildInfo,
)

api.Register(router.WithPrefix("/api/v1"), tracer, logger, ins)
Expand Down
4 changes: 2 additions & 2 deletions docs/contributing/coding-style-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -1016,13 +1016,13 @@ Misspell is amazing, it catches typos in comments and docs.
No Grammarly plugin for this yet ): (We wish).
Ensured [here](https://github.com/thanos-io/thanos/blob/40526f52f54d4501737e5246c0e71e56dd7e0b2d/Makefile#L317).
Ensured [here](https://github.com/thanos-io/thanos/blob/40526f52f54d4501737e5246c0e71e56dd7e0b2d/Makefile#L#300), using [golangci-lint](https://github.com/golangci/golangci-lint) / [misspell](https://github.com/client9/misspell).
#### Comments Should be Full Sentences
All comments should be full sentences. They should start with an uppercase letter and end with a period.
Ensured [here](https://github.com/thanos-io/thanos/blob/40526f52f54d4501737e5246c0e71e56dd7e0b2d/Makefile#L194).
Ensured [here](https://github.com/thanos-io/thanos/blob/40526f52f54d4501737e5246c0e71e56dd7e0b2d/Makefile#L300) using [golangci-lint](https://github.com/golangci/golangci-lint) / [godot](https://github.com/tetafro/godot).
# Bash
Expand Down
2 changes: 1 addition & 1 deletion docs/storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Current object storage client implementations:
| [Google Cloud Storage](./storage.md#gcs) | Stable (production usage) | yes | @bwplotka |
| [AWS/S3](./storage.md#s3) | Stable (production usage) | yes | @bwplotka |
| [Azure Storage Account](./storage.md#azure) | Stable (production usage) | no | @vglafirov |
| [OpenStack Swift](./storage.md#openstack-swift) | Beta (working PoCs, testing usage) | no | @sudhi-vm |
| [OpenStack Swift](./storage.md#openstack-swift) | Beta (working PoCs, testing usage) | yes | @sudhi-vm |
| [Tencent COS](./storage.md#tencent-cos) | Beta (testing usage) | no | @jojohappy |
| [AliYun OSS](./storage.md#aliyun-oss) | Beta (testing usage) | no | @shaulboozhiao,@wujinhu |
| [Local Filesystem](./storage.md#filesystem) | Beta (testing usage) | yes | @bwplotka |
Expand Down
3 changes: 2 additions & 1 deletion pkg/compact/compact.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/prometheus/prometheus/pkg/labels"
"github.com/prometheus/prometheus/tsdb"
terrors "github.com/prometheus/prometheus/tsdb/errors"

"github.com/thanos-io/thanos/pkg/block"
"github.com/thanos-io/thanos/pkg/block/metadata"
"github.com/thanos-io/thanos/pkg/compact/downsample"
Expand Down Expand Up @@ -118,7 +119,7 @@ func UntilNextDownsampling(m *metadata.Meta) (time.Duration, error) {
}
}

// SyncMetas synchronises local state of block metas with what we have in the bucket.
// SyncMetas synchronizes local state of block metas with what we have in the bucket.
func (s *Syncer) SyncMetas(ctx context.Context) error {
s.mtx.Lock()
defer s.mtx.Unlock()
Expand Down
3 changes: 2 additions & 1 deletion pkg/discovery/dns/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
tsdberrors "github.com/prometheus/prometheus/tsdb/errors"

"github.com/thanos-io/thanos/pkg/discovery/dns/miekgdns"
"github.com/thanos-io/thanos/pkg/extprom"
)
Expand Down Expand Up @@ -53,7 +54,7 @@ func (t ResolverType) ToResolver(logger log.Logger) ipLookupResolver {
}

// NewProvider returns a new empty provider with a given resolver type.
// If empty resolver type is net.DefaultResolver.w
// If empty resolver type is net.DefaultResolver.
func NewProvider(logger log.Logger, reg prometheus.Registerer, resolverType ResolverType) *Provider {
p := &Provider{
resolver: NewResolver(resolverType.ToResolver(logger)),
Expand Down
2 changes: 1 addition & 1 deletion pkg/gate/gate.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
promgate "github.com/prometheus/prometheus/pkg/gate"
)

// Gate is an interface that mimics prometheus/pkg/gate behaviour.
// Gate is an interface that mimics prometheus/pkg/gate behavior.
type Gate interface {
Start(ctx context.Context) error
Done()
Expand Down
5 changes: 3 additions & 2 deletions pkg/model/units_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ package model
import (
"testing"

"github.com/thanos-io/thanos/pkg/testutil"
"gopkg.in/yaml.v2"

"github.com/thanos-io/thanos/pkg/testutil"
)

func TestBytes_Marshalling(t *testing.T) {
func TestBytes_Marshaling(t *testing.T) {
value := Bytes(1048576)

encoded, err := yaml.Marshal(&value)
Expand Down
4 changes: 2 additions & 2 deletions pkg/objstore/objtesting/acceptance_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"github.com/thanos-io/thanos/pkg/objstore"
)

// TestObjStoreAcceptanceTest_e2e tests all known implementation against interface behaviour contract we agreed on.
// This ensures consistent behaviour across all implementations.
// TestObjStoreAcceptanceTest_e2e tests all known implementation against interface behavior contract we agreed on.
// This ensures consistent behavior across all implementations.
// NOTE: This test assumes strong consistency, but in the same way it does not guarantee that if it passes, the
// used object store is strongly consistent.
func TestObjStore_AcceptanceTest_e2e(t *testing.T) {
Expand Down
5 changes: 3 additions & 2 deletions pkg/objstore/oss/oss.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ import (
alioss "github.com/aliyun/aliyun-oss-go-sdk/oss"
"github.com/go-kit/kit/log"
"github.com/pkg/errors"
"gopkg.in/yaml.v2"

"github.com/thanos-io/thanos/pkg/objstore"
"github.com/thanos-io/thanos/pkg/objstore/clientutil"
"gopkg.in/yaml.v2"
)

// Part size for multi part upload.
Expand Down Expand Up @@ -300,7 +301,7 @@ func (b *Bucket) setRange(start, end int64, name string) (alioss.Option, error)
return opt, nil
}

func (b *Bucket) getRange(ctx context.Context, name string, off, length int64) (io.ReadCloser, error) {
func (b *Bucket) getRange(_ context.Context, name string, off, length int64) (io.ReadCloser, error) {
if len(name) == 0 {
return nil, errors.New("given object name should not empty")
}
Expand Down
14 changes: 5 additions & 9 deletions pkg/objstore/swift/swift.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ import (
"github.com/gophercloud/gophercloud/openstack/objectstorage/v1/objects"
"github.com/gophercloud/gophercloud/pagination"
"github.com/pkg/errors"
"github.com/thanos-io/thanos/pkg/objstore"
"gopkg.in/yaml.v2"

"github.com/thanos-io/thanos/pkg/objstore"
)

// DirDelim is the delimiter used to model a directory structure in an object store bucket.
Expand Down Expand Up @@ -55,12 +56,7 @@ func NewContainer(logger log.Logger, conf []byte) (*Container, error) {
return nil, err
}

authOpts, err := authOptsFromConfig(sc)
if err != nil {
return nil, err
}

provider, err := openstack.AuthenticatedClient(authOpts)
provider, err := openstack.AuthenticatedClient(authOptsFromConfig(sc))
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -193,7 +189,7 @@ func parseConfig(conf []byte) (*SwiftConfig, error) {
return &sc, err
}

func authOptsFromConfig(sc *SwiftConfig) (gophercloud.AuthOptions, error) {
func authOptsFromConfig(sc *SwiftConfig) gophercloud.AuthOptions {
authOpts := gophercloud.AuthOptions{
IdentityEndpoint: sc.AuthUrl,
Username: sc.Username,
Expand Down Expand Up @@ -237,7 +233,7 @@ func authOptsFromConfig(sc *SwiftConfig) (gophercloud.AuthOptions, error) {
authOpts.Scope.ProjectID = sc.ProjectID
}
}
return authOpts, nil
return authOpts
}

func (c *Container) createContainer(name string) error {
Expand Down
4 changes: 1 addition & 3 deletions pkg/objstore/swift/swift_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ func TestAuthOptsFromConfig(t *testing.T) {
ProjectDomainName: "projectDomain",
}

authOpts, err := authOptsFromConfig(input)
testutil.Ok(t, err)

authOpts := authOptsFromConfig(input)
testutil.Equals(t, "http://identity.something.com/v3", authOpts.IdentityEndpoint)
testutil.Equals(t, "thanos", authOpts.Username)
testutil.Equals(t, "userDomain", authOpts.DomainName)
Expand Down
Loading

0 comments on commit 8982200

Please sign in to comment.