Skip to content

Commit

Permalink
Merge branch 'master' into fix-strict-collation
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot authored Aug 22, 2022
2 parents cb687db + afc0d5c commit 5ce08c0
Show file tree
Hide file tree
Showing 23 changed files with 37 additions and 283 deletions.
16 changes: 1 addition & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -96,27 +96,13 @@ GITHASH := $(shell git rev-parse HEAD)
GITBRANCH := $(shell git rev-parse --abbrev-ref HEAD)
GOVERSION := $(shell go version)

# CDC LDFLAGS.
# Version LDFLAGS.
LDFLAGS += -X "$(CDC_PKG)/pkg/version.ReleaseVersion=$(RELEASE_VERSION)"
LDFLAGS += -X "$(CDC_PKG)/pkg/version.BuildTS=$(BUILDTS)"
LDFLAGS += -X "$(CDC_PKG)/pkg/version.GitHash=$(GITHASH)"
LDFLAGS += -X "$(CDC_PKG)/pkg/version.GitBranch=$(GITBRANCH)"
LDFLAGS += -X "$(CDC_PKG)/pkg/version.GoVersion=$(GOVERSION)"

# DM LDFLAGS.
LDFLAGS += -X "$(DM_PKG)/pkg/utils.ReleaseVersion=$(RELEASE_VERSION)"
LDFLAGS += -X "$(DM_PKG)/pkg/utils.BuildTS=$(BUILDTS)"
LDFLAGS += -X "$(DM_PKG)/pkg/utils.GitHash=$(GITHASH)"
LDFLAGS += -X "$(DM_PKG)/pkg/utils.GitBranch=$(GITBRANCH)"
LDFLAGS += -X "$(DM_PKG)/pkg/utils.GoVersion=$(GOVERSION)"

# Engine LDFLAGS.
LDFLAGS += -X "$(ENGINE_PKG)/pkg/version.ReleaseVersion=$(RELEASE_VERSION)"
LDFLAGS += -X "$(ENGINE_PKG)/pkg/version.BuildTS=$(BUILDTS)"
LDFLAGS += -X "$(ENGINE_PKG)/pkg/version.GitHash=$(GITHASH)"
LDFLAGS += -X "$(ENGINE_PKG)/pkg/version.GitBranch=$(GITBRANCH)"
LDFLAGS += -X "$(ENGINE_PKG)/pkg/version.GoVersion=$(GOVERSION)"

include tools/Makefile

default: build buildsucc
Expand Down
6 changes: 3 additions & 3 deletions cmd/dm-master/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/pingcap/tiflow/dm/pkg/log"
"github.com/pingcap/tiflow/dm/pkg/terror"
"github.com/pingcap/tiflow/dm/pkg/utils"
"github.com/pingcap/tiflow/pkg/version"
)

func main() {
Expand Down Expand Up @@ -59,9 +60,8 @@ func main() {
utils.LogHTTPProxies(true)

// 3. print process version information
utils.PrintInfo("dm-master", func() {
log.L().Info("", zap.Stringer("dm-master config", cfg))
})
version.LogVersionInfo("dm-master")
log.L().Info("", zap.Stringer("dm-master config", cfg))

// 4. start the server
ctx, cancel := context.WithCancel(context.Background())
Expand Down
4 changes: 2 additions & 2 deletions cmd/dm-syncer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (

"github.com/pingcap/tiflow/dm/config"
"github.com/pingcap/tiflow/dm/pkg/log"
"github.com/pingcap/tiflow/dm/pkg/utils"
"github.com/pingcap/tiflow/pkg/version"
)

// commonConfig collects common item for both new config and old config.
Expand Down Expand Up @@ -132,7 +132,7 @@ func (c *commonConfig) parse(args []string) (*config.SubTaskConfig, error) {
return nil, errors.Trace(err)
}
if c.printVersion {
fmt.Println(utils.GetRawInfo())
fmt.Println(version.GetRawInfo())
return nil, flag.ErrHelp
}

Expand Down
7 changes: 3 additions & 4 deletions cmd/dm-syncer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import (
"github.com/pingcap/tiflow/dm/pb"
"github.com/pingcap/tiflow/dm/pkg/log"
"github.com/pingcap/tiflow/dm/pkg/terror"
"github.com/pingcap/tiflow/dm/pkg/utils"
"github.com/pingcap/tiflow/dm/syncer"
"github.com/pingcap/tiflow/pkg/version"

"github.com/pingcap/errors"
globalLog "github.com/pingcap/log"
Expand Down Expand Up @@ -70,9 +70,8 @@ func main() {
globalLog.ReplaceGlobals(lg, r)

// 3. print process version information
utils.PrintInfo("dm-syncer", func() {
log.L().Info("", zap.Stringer("dm-syncer conf", conf))
})
version.LogVersionInfo("dm-syncer")
log.L().Info("", zap.Stringer("dm-syncer conf", conf))

sync := syncer.NewSyncer(conf, nil, nil) // do not support shard DDL for singleton syncer.
sc := make(chan os.Signal, 1)
Expand Down
7 changes: 3 additions & 4 deletions cmd/dm-worker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ import (
"go.uber.org/zap"

lightningLog "github.com/pingcap/tidb/br/pkg/lightning/log"

"github.com/pingcap/tiflow/dm/ctl/common"
"github.com/pingcap/tiflow/dm/pkg/log"
"github.com/pingcap/tiflow/dm/pkg/terror"
"github.com/pingcap/tiflow/dm/pkg/utils"
"github.com/pingcap/tiflow/dm/worker"
"github.com/pingcap/tiflow/pkg/version"
)

func main() {
Expand Down Expand Up @@ -67,9 +67,8 @@ func main() {
lightningLogger := lg.With(zap.String("component", "lightning"))
lightningLog.SetAppLogger(lightningLogger)

utils.PrintInfo("dm-worker", func() {
log.L().Info("", zap.Stringer("dm-worker config", cfg))
})
version.LogVersionInfo("dm-worker")
log.L().Info("", zap.Stringer("dm-worker config", cfg))

sc := make(chan os.Signal, 1)
signal.Notify(sc,
Expand Down
3 changes: 2 additions & 1 deletion dm/config/subtask.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
"github.com/pingcap/tiflow/dm/pkg/terror"
"github.com/pingcap/tiflow/dm/pkg/utils"
"github.com/pingcap/tiflow/engine/pkg/promutil"
"github.com/pingcap/tiflow/pkg/version"
)

// task modes.
Expand Down Expand Up @@ -507,7 +508,7 @@ func (c *SubTaskConfig) Parse(arguments []string, verifyDecryptPassword bool) er
}

if c.printVersion {
fmt.Println(utils.GetRawInfo())
fmt.Println(version.GetRawInfo())
return flag.ErrHelp
}

Expand Down
3 changes: 2 additions & 1 deletion dm/ctl/ctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (

"github.com/chzyer/readline"
"github.com/pingcap/errors"
"github.com/pingcap/tiflow/pkg/version"
"github.com/spf13/cobra"
"go.uber.org/zap/zapcore"
)
Expand Down Expand Up @@ -187,7 +188,7 @@ func MainStart(args []string) {
if printVersion, err := cmd.Flags().GetBool("version"); err != nil {
return errors.Trace(err)
} else if printVersion {
cmd.Println(utils.GetRawInfo())
cmd.Println(version.GetRawInfo())
os.Exit(0)
}

Expand Down
3 changes: 2 additions & 1 deletion dm/master/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"github.com/pingcap/tiflow/dm/pkg/log"
"github.com/pingcap/tiflow/dm/pkg/terror"
"github.com/pingcap/tiflow/dm/pkg/utils"
"github.com/pingcap/tiflow/pkg/version"
)

const (
Expand Down Expand Up @@ -174,7 +175,7 @@ func (c *Config) Parse(arguments []string) error {
}

if c.printVersion {
fmt.Println(utils.GetRawInfo())
fmt.Println(version.GetRawInfo())
return flag.ErrHelp
}

Expand Down
4 changes: 2 additions & 2 deletions dm/master/http_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ import (
"github.com/pingcap/tiflow/dm/pb"
"github.com/pingcap/tiflow/dm/pkg/log"
"github.com/pingcap/tiflow/dm/pkg/terror"
"github.com/pingcap/tiflow/dm/pkg/utils"
"github.com/pingcap/tiflow/pkg/version"
)

// statusHandler handles process status.
type statusHandler struct{}

func (h *statusHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
w.Header().Set("Content-Type", "text/plain")
text := utils.GetRawInfo()
text := version.GetRawInfo()
if _, err := w.Write([]byte(text)); err != nil {
log.L().Error("write status response", log.ShortError(err))
}
Expand Down
5 changes: 3 additions & 2 deletions dm/master/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ import (
"github.com/pingcap/tiflow/dm/pkg/shardddl/pessimism"
"github.com/pingcap/tiflow/dm/pkg/terror"
"github.com/pingcap/tiflow/dm/pkg/utils"
"github.com/pingcap/tiflow/pkg/version"
)

// use task config from integration test `sharding`.
Expand Down Expand Up @@ -1391,7 +1392,7 @@ func (t *testMaster) TestServer(c *check.C) {
cfg.AdvertiseAddr = cfg.MasterAddr

basicServiceCheck := func(c *check.C, cfg *Config) {
t.testHTTPInterface(c, fmt.Sprintf("http://%s/status", cfg.AdvertiseAddr), []byte(utils.GetRawInfo()))
t.testHTTPInterface(c, fmt.Sprintf("http://%s/status", cfg.AdvertiseAddr), []byte(version.GetRawInfo()))
t.testHTTPInterface(c, fmt.Sprintf("http://%s/debug/pprof/", cfg.AdvertiseAddr), []byte("Types of profiles available"))
// HTTP API in this unit test is unstable, but we test it in `http_apis` in integration test.
// t.testHTTPInterface(c, fmt.Sprintf("http://%s/apis/v1alpha1/status/test-task", cfg.AdvertiseAddr), []byte("task test-task has no source or not exist"))
Expand Down Expand Up @@ -1605,7 +1606,7 @@ func (t *testMaster) TestMasterTLS(c *check.C) {

func (t *testMaster) testTLSPrefix(c *check.C, cfg *Config) {
t.testNormalServerLifecycle(c, cfg, func(c *check.C, cfg *Config) {
t.testHTTPInterface(c, fmt.Sprintf("https://%s/status", cfg.AdvertiseAddr), []byte(utils.GetRawInfo()))
t.testHTTPInterface(c, fmt.Sprintf("https://%s/status", cfg.AdvertiseAddr), []byte(version.GetRawInfo()))
t.testHTTPInterface(c, fmt.Sprintf("https://%s/debug/pprof/", cfg.AdvertiseAddr), []byte("Types of profiles available"))
})
}
Expand Down
4 changes: 2 additions & 2 deletions dm/pkg/upgrade/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"github.com/pingcap/tiflow/dm/common"
"github.com/pingcap/tiflow/dm/pkg/etcdutil"
"github.com/pingcap/tiflow/dm/pkg/terror"
"github.com/pingcap/tiflow/dm/pkg/utils"
"github.com/pingcap/tiflow/pkg/version"
)

const (
Expand All @@ -35,7 +35,7 @@ const (

var (
// CurrentVersion represents the current version of the cluster.
CurrentVersion = NewVersion(currentInternalNo, utils.ReleaseVersion)
CurrentVersion = NewVersion(currentInternalNo, version.ReleaseVersion)
// MinVersion represents the minimum version of the cluster.
// this version only be set after finished importing from v1.0.x, but has not upgraded to the current version.
MinVersion = NewVersion(minInternalNo, "min-ver")
Expand Down
71 changes: 0 additions & 71 deletions dm/pkg/utils/printer.go

This file was deleted.

51 changes: 0 additions & 51 deletions dm/pkg/utils/printer_test.go

This file was deleted.

3 changes: 2 additions & 1 deletion dm/worker/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/pingcap/tiflow/dm/pkg/log"
"github.com/pingcap/tiflow/dm/pkg/terror"
"github.com/pingcap/tiflow/dm/pkg/utils"
"github.com/pingcap/tiflow/pkg/version"
)

// SampleConfigFile is sample config file of dm-worker.
Expand Down Expand Up @@ -145,7 +146,7 @@ func (c *Config) Parse(arguments []string) error {
}

if c.printVersion {
fmt.Println(utils.GetRawInfo())
fmt.Println(version.GetRawInfo())
return flag.ErrHelp
}

Expand Down
4 changes: 2 additions & 2 deletions dm/worker/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ import (
"github.com/pingcap/tiflow/dm/loader"
"github.com/pingcap/tiflow/dm/pkg/log"
"github.com/pingcap/tiflow/dm/pkg/metricsproxy"
"github.com/pingcap/tiflow/dm/pkg/utils"
"github.com/pingcap/tiflow/dm/relay"
"github.com/pingcap/tiflow/pkg/version"
)

const (
Expand Down Expand Up @@ -73,7 +73,7 @@ type statusHandler struct{}

func (h *statusHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
w.Header().Set("Content-Type", "text/plain")
text := utils.GetRawInfo()
text := version.GetRawInfo()
_, err := w.Write([]byte(text))
if err != nil && !common.IsErrNetClosing(err) {
log.L().Error("fail to write status response", log.ShortError(err))
Expand Down
Loading

0 comments on commit 5ce08c0

Please sign in to comment.