Skip to content

Commit

Permalink
This is an automated cherry-pick of pingcap#11198
Browse files Browse the repository at this point in the history
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
  • Loading branch information
lance6716 authored and ti-chi-bot committed Jul 11, 2024
1 parent 0020851 commit 05e4813
Show file tree
Hide file tree
Showing 5 changed files with 368 additions and 6 deletions.
67 changes: 67 additions & 0 deletions dm/checker/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,7 @@ func (c *Checker) Process(ctx context.Context, pr chan pb.ProcessResult) {
}
warnLeft, errLeft := c.warnCnt, c.errCnt

<<<<<<< HEAD
// remove success result if not pass
results := result.Results[:0]
for _, r := range result.Results {
Expand Down Expand Up @@ -655,6 +656,9 @@ func (c *Checker) Process(ctx context.Context, pr chan pb.ProcessResult) {
}
}
result.Results = results
=======
filterResults(result, c.warnCnt, c.errCnt, false)
>>>>>>> 92e2909787 (dep: update tidb package (#11198))

c.updateInstruction(result)

Expand Down Expand Up @@ -682,6 +686,69 @@ func (c *Checker) Process(ctx context.Context, pr chan pb.ProcessResult) {
}
}

<<<<<<< HEAD
=======
func filterResults(
result *checker.Results,
warnCnt, errCnt int64,
keepSuccessWhenNoFailure bool,
) {
// remove success result if not pass
results := result.Results[:0]
for _, r := range result.Results {
if r.State == checker.StateSuccess {
continue
}

// handle results without r.Errors
if len(r.Errors) == 0 {
switch r.State {
case checker.StateWarning:
if warnCnt == 0 {
continue
}
warnCnt--
results = append(results, r)
case checker.StateFailure:
if errCnt == 0 {
continue
}
errCnt--
results = append(results, r)
}
continue
}

subErrors := make([]*checker.Error, 0, len(r.Errors))
for _, e := range r.Errors {
switch e.Severity {
case checker.StateWarning:
if warnCnt == 0 {
continue
}
warnCnt--
subErrors = append(subErrors, e)
case checker.StateFailure:
if errCnt == 0 {
continue
}
errCnt--
subErrors = append(subErrors, e)
}
}
// skip display an empty Result
if len(subErrors) > 0 {
r.Errors = subErrors
results = append(results, r)
}
}
if keepSuccessWhenNoFailure && len(results) == 0 {
return
}
result.Results = results
}

>>>>>>> 92e2909787 (dep: update tidb package (#11198))
// updateInstruction updates the check result's Instruction.
func (c *Checker) updateInstruction(result *checker.Results) {
for _, r := range result.Results {
Expand Down
27 changes: 27 additions & 0 deletions dm/checker/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,30 @@ func RunCheckOnConfigs(

return checker.Do(ctx, c.checkList)
}
<<<<<<< HEAD
=======

// RunCheckOnConfigs returns the check result for given subtask configs. Caller
// should be noticed that result may be very large. The result will be truncated
// to `warnLimit` and `errLimit`, but the total count in summary will be the same
// as the original result.
//
// when `dumpWholeInstance` is true, checker will require SELECT ON *.*
// privileges for SourceDumpPrivilegeChecker.
//
// This function is used by cloud services.
func RunCheckOnConfigs(
ctx context.Context,
cfgs []*config.SubTaskConfig,
dumpWholeInstance bool,
warnLimit, errLimit int64,
) (*checker.Results, error) {
result, err := runCheckOnConfigs(ctx, cfgs, dumpWholeInstance)
if err != nil || result == nil {
return result, err
}

filterResults(result, warnLimit, errLimit, true)
return result, nil
}
>>>>>>> 92e2909787 (dep: update tidb package (#11198))
2 changes: 1 addition & 1 deletion dm/tests/check_task/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function test_privileges_can_migrate() {
run_sql_source1 "create table checktask1.test_privilege(id int primary key, b varchar(10))"
run_sql_source1 "insert into checktask1.test_privilege values (1, 'a'),(2, 'b');"
run_sql_tidb "create user 'test1'@'%' identified by '123456';"
run_sql_tidb "grant select, create, insert, update, delete, alter, drop, index, config on *.* to 'test1'@'%';"
run_sql_tidb "grant select, create, insert, update, delete, alter, drop, index, config, create view on *.* to 'test1'@'%';"
run_sql_tidb "flush privileges;"
run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \
"start-task $cur/conf/task-priv.yaml --remove-meta" \
Expand Down
38 changes: 37 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,22 @@ require (
github.com/pierrec/lz4/v4 v4.1.18
github.com/pingcap/check v0.0.0-20211026125417-57bd13f7b5f0
github.com/pingcap/errors v0.11.5-0.20240318064555-6bd07397691f
<<<<<<< HEAD
github.com/pingcap/failpoint v0.0.0-20240412033321-fd0796e60f86
github.com/pingcap/kvproto v0.0.0-20240522024016-df42997c2c57
github.com/pingcap/log v1.1.1-0.20240314023424-862ccc32f18d
github.com/pingcap/tidb v1.1.0-beta.0.20240527072219-a97e6464c01d
github.com/pingcap/tidb/pkg/parser v0.0.0-20240527072219-a97e6464c01d
github.com/prometheus/client_golang v1.19.1
=======
github.com/pingcap/failpoint v0.0.0-20240527053858-9b3b6e34194a
github.com/pingcap/kvproto v0.0.0-20240227073058-929ab83f9754
github.com/pingcap/log v1.1.1-0.20240314023424-862ccc32f18d
github.com/pingcap/tidb v1.1.0-beta.0.20240530025951-afd8de1f6218
github.com/pingcap/tidb-dashboard v0.0.0-20240326110213-9768844ff5d7
github.com/pingcap/tidb/pkg/parser v0.0.0-20240530025951-afd8de1f6218
github.com/prometheus/client_golang v1.19.0
>>>>>>> 92e2909787 (dep: update tidb package (#11198))
github.com/prometheus/client_model v0.6.1
github.com/r3labs/diff v1.1.0
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475
Expand Down Expand Up @@ -127,6 +137,8 @@ require (
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.0.0 // indirect
github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358 // indirect
github.com/AzureAD/microsoft-authentication-library-for-go v1.2.1 // indirect
github.com/andybalholm/brotli v1.0.5 // indirect
github.com/apache/arrow/go/v12 v12.0.1 // indirect
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.6 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.36 // indirect
Expand All @@ -149,25 +161,49 @@ require (
github.com/go-ldap/ldap/v3 v3.4.4 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
<<<<<<< HEAD
=======
github.com/go-resty/resty/v2 v2.11.0 // indirect
github.com/goccy/go-reflect v1.2.0 // indirect
>>>>>>> 92e2909787 (dep: update tidb package (#11198))
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang-jwt/jwt/v5 v5.2.0 // indirect
github.com/google/flatbuffers v2.0.8+incompatible // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/s2a-go v0.1.7 // indirect
github.com/iancoleman/strcase v0.2.0 // indirect
github.com/influxdata/tdigest v0.0.1 // indirect
github.com/jellydator/ttlcache/v3 v3.0.1 // indirect
<<<<<<< HEAD
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
github.com/ks3sdklib/aws-sdk-go v1.2.6 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/ncruces/go-strftime v0.1.9 // indirect
=======
github.com/jfcg/sixb v1.3.8 // indirect
github.com/jfcg/sorty/v2 v2.1.0 // indirect
github.com/joomcode/errorx v1.0.1 // indirect
github.com/klauspost/asmfmt v1.3.2 // indirect
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
github.com/ks3sdklib/aws-sdk-go v1.2.9 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8 // indirect
github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3 // indirect
github.com/otiai10/copy v1.2.0 // indirect
>>>>>>> 92e2909787 (dep: update tidb package (#11198))
github.com/robfig/cron/v3 v3.0.1 // indirect
github.com/segmentio/asm v1.2.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/zeebo/xxh3 v1.0.2 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.22.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.22.0 // indirect
golang.org/x/arch v0.3.0 // indirect
<<<<<<< HEAD
google.golang.org/appengine v1.6.8 // indirect
=======
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
>>>>>>> 92e2909787 (dep: update tidb package (#11198))
google.golang.org/genproto v0.0.0-20240401170217-c3f982113cda // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
k8s.io/api v0.28.6 // indirect
Expand Down Expand Up @@ -341,7 +377,7 @@ require (
github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/xdg/stringprep v1.0.3 // indirect
github.com/xiang90/probing v0.0.0-20221125231312-a49e3df8f510 // indirect
github.com/xitongsys/parquet-go v1.6.0 // indirect
github.com/xitongsys/parquet-go v1.6.3-0.20240520233950-75e935fc3e17 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
go.etcd.io/bbolt v1.3.9 // indirect
go.etcd.io/etcd/client/v2 v2.305.12 // indirect
Expand Down
Loading

0 comments on commit 05e4813

Please sign in to comment.