printer: print commit hash version for extensions (#43095)
close pingcap/tidb#43096
This commit is contained in:
16
Makefile
16
Makefile
@ -159,23 +159,29 @@ else
|
||||
CGO_ENABLED=1 $(GOBUILD) -gcflags="all=-N -l" $(RACE_FLAG) -ldflags '$(LDFLAGS) $(CHECK_FLAG)' -o '$(TARGET)' ./tidb-server
|
||||
endif
|
||||
|
||||
init-submodule:
|
||||
git submodule init && git submodule update --force
|
||||
|
||||
enterprise-prepare:
|
||||
git submodule init && git submodule update && cd extension/enterprise/generate && $(GO) generate -run genfile main.go
|
||||
cd extension/enterprise/generate && $(GO) generate -run genfile main.go
|
||||
|
||||
enterprise-clear:
|
||||
cd extension/enterprise/generate && $(GO) generate -run clear main.go
|
||||
|
||||
enterprise-docker: enterprise-prepare
|
||||
enterprise-docker: init-submodule enterprise-prepare
|
||||
docker build -t "$(DOCKERPREFIX)tidb:latest" --build-arg 'GOPROXY=$(shell go env GOPROXY),' -f Dockerfile.enterprise .
|
||||
|
||||
enterprise-server-build:
|
||||
ifeq ($(TARGET), "")
|
||||
CGO_ENABLED=1 $(GOBUILD) -tags enterprise $(RACE_FLAG) -ldflags '$(LDFLAGS) $(CHECK_FLAG)' -o bin/tidb-server tidb-server/main.go
|
||||
CGO_ENABLED=1 $(GOBUILD) -tags enterprise $(RACE_FLAG) -ldflags '$(LDFLAGS) $(CHECK_FLAG) $(EXTENSION_FLAG)' -o bin/tidb-server tidb-server/main.go
|
||||
else
|
||||
CGO_ENABLED=1 $(GOBUILD) -tags enterprise $(RACE_FLAG) -ldflags '$(LDFLAGS) $(CHECK_FLAG)' -o '$(TARGET)' tidb-server/main.go
|
||||
CGO_ENABLED=1 $(GOBUILD) -tags enterprise $(RACE_FLAG) -ldflags '$(LDFLAGS) $(CHECK_FLAG) $(EXTENSION_FLAG)' -o '$(TARGET)' tidb-server/main.go
|
||||
endif
|
||||
|
||||
enterprise-server: enterprise-prepare enterprise-server-build
|
||||
enterprise-server:
|
||||
@make init-submodule
|
||||
@make enterprise-prepare
|
||||
@make enterprise-server-build
|
||||
|
||||
server_check:
|
||||
ifeq ($(TARGET), "")
|
||||
|
||||
@ -66,6 +66,11 @@ LDFLAGS += -X "github.com/pingcap/tidb/util/versioninfo.TiDBGitHash=$(shell git
|
||||
LDFLAGS += -X "github.com/pingcap/tidb/util/versioninfo.TiDBGitBranch=$(shell git rev-parse --abbrev-ref HEAD)"
|
||||
LDFLAGS += -X "github.com/pingcap/tidb/util/versioninfo.TiDBEdition=$(TIDB_EDITION)"
|
||||
|
||||
EXTENSION_FLAG =
|
||||
ifeq ($(shell if [ -a extension/enterprise/.git ]; then echo "true"; fi),true)
|
||||
EXTENSION_FLAG += -X "github.com/pingcap/tidb/util/versioninfo.TiDBEnterpriseExtensionGitHash=$(shell cd extension/enterprise && git rev-parse HEAD)"
|
||||
endif
|
||||
|
||||
TEST_LDFLAGS = -X "github.com/pingcap/tidb/config.checkBeforeDropLDFlag=1"
|
||||
COVERAGE_SERVER_LDFLAGS = -X "github.com/pingcap/tidb/tidb-server.isCoverageServer=1"
|
||||
|
||||
|
||||
@ -27,6 +27,10 @@ TiDB_BUILD_UTCTIME=$(date -u '+%Y-%m-%d %H:%M:%S')
|
||||
TIDB_GIT_HASH=$(git rev-parse HEAD)
|
||||
TIDB_GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
||||
TIDB_EDITION=${TIDB_EDITION:-Community}
|
||||
TIDB_ENTERPRISE_EXTENSION_GIT_HASH=""
|
||||
if [ -a "extension/enterprise/.git" ]; then
|
||||
TIDB_ENTERPRISE_EXTENSION_GIT_HASH=$(cd extension/enterprise && git rev-parse HEAD)
|
||||
fi
|
||||
|
||||
cat <<EOF
|
||||
STABLE_TiDB_RELEASE_VERSION ${TiDB_RELEASE_VERSION}
|
||||
@ -34,4 +38,5 @@ STABLE_TiDB_BUILD_UTCTIME ${TiDB_BUILD_UTCTIME}
|
||||
STABLE_TIDB_GIT_HASH ${TIDB_GIT_HASH}
|
||||
STABLE_TIDB_GIT_BRANCH ${TIDB_GIT_BRANCH}
|
||||
STABLE_TIDB_EDITION ${TIDB_EDITION}
|
||||
STABLE_TIDB_ENTERPRISE_EXTENSION_GIT_HASH ${TIDB_ENTERPRISE_EXTENSION_GIT_HASH}
|
||||
EOF
|
||||
|
||||
@ -78,6 +78,7 @@ go_binary(
|
||||
"github.com/pingcap/tidb/parser/mysql.TiDBReleaseVersion": "{STABLE_TiDB_RELEASE_VERSION}",
|
||||
"github.com/pingcap/tidb/util/versioninfo.TiDBBuildTS": "{STABLE_TiDB_BUILD_UTCTIME}",
|
||||
"github.com/pingcap/tidb/util/versioninfo.TiDBGitHash": "{STABLE_TIDB_GIT_HASH}",
|
||||
"github.com/pingcap/tidb/util/versioninfo.TiDBEnterpriseExtensionGitHash": "{STABLE_TIDB_ENTERPRISE_EXTENSION_GIT_HASH}",
|
||||
"github.com/pingcap/tidb/util/versioninfo.TiDBGitBranch": "{STABLE_TIDB_GIT_BRANCH}",
|
||||
"github.com/pingcap/tidb/util/versioninfo.TiDBEdition": "{STABLE_TIDB_EDITION}",
|
||||
},
|
||||
|
||||
@ -31,7 +31,7 @@ import (
|
||||
|
||||
// PrintTiDBInfo prints the TiDB version information.
|
||||
func PrintTiDBInfo() {
|
||||
logutil.BgLogger().Info("Welcome to TiDB.",
|
||||
fields := []zap.Field{
|
||||
zap.String("Release Version", mysql.TiDBReleaseVersion),
|
||||
zap.String("Edition", versioninfo.TiDBEdition),
|
||||
zap.String("Git Commit Hash", versioninfo.TiDBGitHash),
|
||||
@ -40,7 +40,12 @@ func PrintTiDBInfo() {
|
||||
zap.String("GoVersion", buildVersion),
|
||||
zap.Bool("Race Enabled", israce.RaceEnabled),
|
||||
zap.Bool("Check Table Before Drop", config.CheckTableBeforeDrop),
|
||||
zap.String("TiKV Min Version", versioninfo.TiKVMinVersion))
|
||||
zap.String("TiKV Min Version", versioninfo.TiKVMinVersion),
|
||||
}
|
||||
if versioninfo.TiDBEnterpriseExtensionGitHash != "" {
|
||||
fields = append(fields, zap.String("Enterprise Extension Commit Hash", versioninfo.TiDBEnterpriseExtensionGitHash))
|
||||
}
|
||||
logutil.BgLogger().Info("Welcome to TiDB.", fields...)
|
||||
configJSON, err := json.Marshal(config.GetGlobalConfig())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@ -50,6 +55,10 @@ func PrintTiDBInfo() {
|
||||
|
||||
// GetTiDBInfo returns the git hash and build time of this tidb-server binary.
|
||||
func GetTiDBInfo() string {
|
||||
enterpriseVersion := ""
|
||||
if versioninfo.TiDBEnterpriseExtensionGitHash != "" {
|
||||
enterpriseVersion = fmt.Sprintf("\nEnterprise Extension Commit Hash: %s", versioninfo.TiDBEnterpriseExtensionGitHash)
|
||||
}
|
||||
return fmt.Sprintf("Release Version: %s\n"+
|
||||
"Edition: %s\n"+
|
||||
"Git Commit Hash: %s\n"+
|
||||
@ -59,7 +68,8 @@ func GetTiDBInfo() string {
|
||||
"Race Enabled: %v\n"+
|
||||
"TiKV Min Version: %s\n"+
|
||||
"Check Table Before Drop: %v\n"+
|
||||
"Store: %s",
|
||||
"Store: %s"+
|
||||
"%s",
|
||||
mysql.TiDBReleaseVersion,
|
||||
versioninfo.TiDBEdition,
|
||||
versioninfo.TiDBGitHash,
|
||||
@ -70,6 +80,7 @@ func GetTiDBInfo() string {
|
||||
versioninfo.TiKVMinVersion,
|
||||
config.CheckTableBeforeDrop,
|
||||
config.GetGlobalConfig().Store,
|
||||
enterpriseVersion,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@ -26,5 +26,6 @@ var (
|
||||
TiDBGitBranch = "None"
|
||||
TiDBEdition = CommunityEdition
|
||||
// TiKVMinVersion is the minimum version of TiKV that can be compatible with the current TiDB.
|
||||
TiKVMinVersion = "6.2.0-alpha"
|
||||
TiKVMinVersion = "6.2.0-alpha"
|
||||
TiDBEnterpriseExtensionGitHash = ""
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user