Skip to content

Commit

Permalink
Merge branch 'master' into unify-metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
nolouch authored Dec 20, 2023
2 parents 60d2ec9 + 48dbce1 commit a4e6b94
Show file tree
Hide file tree
Showing 171 changed files with 4,596 additions and 1,951 deletions.
19 changes: 14 additions & 5 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,12 @@ linters:
- makezero
- gosec
- bodyclose
# TODO: enable when all existing errors are fixed
# - testifylint
disable:
- errcheck
linters-settings:
gocritic:
# Which checks should be enabled; can't be combined with 'disabled-checks';
# See https://go-critic.github.io/overview#checks-overview
# To check which checks are enabled run `GL_DEBUG=gocritic golangci-lint run`
# By default list of stable checks is used.
enabled-checks:
# Which checks should be disabled; can't be combined with 'enabled-checks'; default is empty
disabled-checks:
- regexpMust
Expand All @@ -33,3 +30,15 @@ linters-settings:
- G402
- G404
- G601
testifylint:
enable:
- bool-compare
- compares
- empty
- error-is-as
- error-nil
- expected-actual
- len
- require-error
- suite-dont-use-pkg
- suite-extra-assert-call
26 changes: 17 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ ifeq ($(ENABLE_FIPS), 1)
BUILD_TOOL_CGO_ENABLED := 1
endif

LDFLAGS += -X "$(PD_PKG)/pkg/versioninfo.PDReleaseVersion=$(shell git describe --tags --dirty --always)"
RELEASE_VERSION ?= $(shell git describe --tags --dirty --always)
ifeq ($(RUN_CI), 1)
RELEASE_VERSION := None
endif

LDFLAGS += -X "$(PD_PKG)/pkg/versioninfo.PDReleaseVersion=$(RELEASE_VERSION)"
LDFLAGS += -X "$(PD_PKG)/pkg/versioninfo.PDBuildTS=$(shell date -u '+%Y-%m-%d %I:%M:%S')"
LDFLAGS += -X "$(PD_PKG)/pkg/versioninfo.PDGitHash=$(shell git rev-parse HEAD)"
LDFLAGS += -X "$(PD_PKG)/pkg/versioninfo.PDGitBranch=$(shell git rev-parse --abbrev-ref HEAD)"
Expand Down Expand Up @@ -160,14 +165,14 @@ SHELL := env PATH='$(PATH)' GOBIN='$(GO_TOOLS_BIN_PATH)' $(shell which bash)

install-tools:
@mkdir -p $(GO_TOOLS_BIN_PATH)
@which golangci-lint >/dev/null 2>&1 || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GO_TOOLS_BIN_PATH) v1.51.2
@which golangci-lint >/dev/null 2>&1 || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GO_TOOLS_BIN_PATH) v1.55.2
@grep '_' tools.go | sed 's/"//g' | awk '{print $$2}' | xargs go install

.PHONY: install-tools

#### Static checks ####

check: install-tools tidy static generate-errdoc check-test
check: install-tools tidy static generate-errdoc

static: install-tools
@ echo "gofmt ..."
Expand All @@ -194,11 +199,7 @@ check-plugin:
@echo "checking plugin..."
cd ./plugin/scheduler_example && $(MAKE) evictLeaderPlugin.so && rm evictLeaderPlugin.so

check-test:
@echo "checking test..."
./scripts/check-test.sh

.PHONY: check static tidy generate-errdoc check-plugin check-test
.PHONY: check static tidy generate-errdoc check-plugin

#### Test utils ####

Expand Down Expand Up @@ -260,7 +261,13 @@ test-tso-consistency: install-tools
CGO_ENABLED=1 go test -race -tags without_dashboard,tso_consistency_test,deadlock $(TSO_INTEGRATION_TEST_PKGS) || { $(FAILPOINT_DISABLE); exit 1; }
@$(FAILPOINT_DISABLE)

.PHONY: test basic-test test-with-cover test-tso-function test-tso-consistency
REAL_CLUSTER_TEST_PATH := $(ROOT_PATH)/tests/integrations/realtiup

test-real-cluster:
# testing with the real cluster...
cd $(REAL_CLUSTER_TEST_PATH) && $(MAKE) check

.PHONY: test basic-test test-with-cover test-tso-function test-tso-consistency test-real-cluster

#### Daily CI coverage analyze ####

Expand Down Expand Up @@ -292,6 +299,7 @@ clean-test:
rm -rf /tmp/test_pd*
rm -rf /tmp/pd-tests*
rm -rf /tmp/test_etcd*
rm -f $(REAL_CLUSTER_TEST_PATH)/playground.log
go clean -testcache

clean-build:
Expand Down
2 changes: 1 addition & 1 deletion client/errs/errno.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ var (
ErrClientGetMultiResponse = errors.Normalize("get invalid value response %v, must only one", errors.RFCCodeText("PD:client:ErrClientGetMultiResponse"))
ErrClientGetServingEndpoint = errors.Normalize("get serving endpoint failed", errors.RFCCodeText("PD:client:ErrClientGetServingEndpoint"))
ErrClientFindGroupByKeyspaceID = errors.Normalize("can't find keyspace group by keyspace id", errors.RFCCodeText("PD:client:ErrClientFindGroupByKeyspaceID"))
ErrClientWatchGCSafePointV2Stream = errors.Normalize("watch gc safe point v2 stream failed, %s", errors.RFCCodeText("PD:client:ErrClientWatchGCSafePointV2Stream"))
ErrClientWatchGCSafePointV2Stream = errors.Normalize("watch gc safe point v2 stream failed", errors.RFCCodeText("PD:client:ErrClientWatchGCSafePointV2Stream"))
)

// grpcutil errors
Expand Down
2 changes: 1 addition & 1 deletion client/errs/errs.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func ZapError(err error, causeError ...error) zap.Field {
}
if e, ok := err.(*errors.Error); ok {
if len(causeError) >= 1 {
err = e.Wrap(causeError[0]).FastGenWithCause()
err = e.Wrap(causeError[0])
} else {
err = e.FastGenByArgs()
}
Expand Down
20 changes: 20 additions & 0 deletions client/http/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ const (
store = "/pd/api/v1/store"
Stores = "/pd/api/v1/stores"
StatsRegion = "/pd/api/v1/stats/region"
membersPrefix = "/pd/api/v1/members"
leaderPrefix = "/pd/api/v1/leader"
transferLeader = "/pd/api/v1/leader/transfer"
// Config
Config = "/pd/api/v1/config"
ClusterVersion = "/pd/api/v1/config/cluster-version"
Expand Down Expand Up @@ -72,6 +75,8 @@ const (
MinResolvedTSPrefix = "/pd/api/v1/min-resolved-ts"
Status = "/pd/api/v1/status"
Version = "/pd/api/v1/version"
// Micro Service
microServicePrefix = "/pd/api/v2/ms"
)

// RegionByID returns the path of PD HTTP API to get region by ID.
Expand Down Expand Up @@ -124,6 +129,16 @@ func StoreLabelByID(id uint64) string {
return fmt.Sprintf("%s/%d/label", store, id)
}

// LabelByStoreID returns the path of PD HTTP API to set store label.
func LabelByStoreID(storeID int64) string {
return fmt.Sprintf("%s/%d/label", store, storeID)
}

// TransferLeaderByID returns the path of PD HTTP API to transfer leader by ID.
func TransferLeaderByID(leaderID string) string {
return fmt.Sprintf("%s/%s", transferLeader, leaderID)
}

// ConfigWithTTLSeconds returns the config API with the TTL seconds parameter.
func ConfigWithTTLSeconds(ttlSeconds float64) string {
return fmt.Sprintf("%s?ttlSecond=%.0f", Config, ttlSeconds)
Expand Down Expand Up @@ -173,3 +188,8 @@ func PProfProfileAPIWithInterval(interval time.Duration) string {
func PProfGoroutineWithDebugLevel(level int) string {
return fmt.Sprintf("%s?debug=%d", PProfGoroutine, level)
}

// MicroServiceMembers returns the path of PD HTTP API to get the members of microservice.
func MicroServiceMembers(service string) string {
return fmt.Sprintf("%s/members/%s", microServicePrefix, service)
}
Loading

0 comments on commit a4e6b94

Please sign in to comment.