-
Notifications
You must be signed in to change notification settings - Fork 288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
checker(dm): make start-task/resume-task/check-task
return pre-check result only warning
#4118
Changes from 9 commits
e8d865f
cb7d6ef
85a0fd4
d13e6ff
d09ecab
c000cd5
1edde50
0574595
c41787d
fb60433
e16f98d
0c1792a
b64d32a
ce09d4c
a64ef81
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -15,28 +15,31 @@ package checker | |||||||||
|
||||||||||
import ( | ||||||||||
"context" | ||||||||||
"fmt" | ||||||||||
|
||||||||||
"github.com/pingcap/tiflow/dm/dm/config" | ||||||||||
"github.com/pingcap/tiflow/dm/dm/pb" | ||||||||||
"github.com/pingcap/tiflow/dm/pkg/terror" | ||||||||||
) | ||||||||||
|
||||||||||
var ( | ||||||||||
// ErrorMsgHeader used as the header of the error message when checking config failed. | ||||||||||
ErrorMsgHeader = "fail to check synchronization configuration with type" | ||||||||||
// CheckTaskMsgHeader used as the header of the error/warning message when checking config failed. | ||||||||||
CheckTaskMsgHeader = "fail to check synchronization configuration with type" | ||||||||||
|
||||||||||
CheckTaskSuccess = "check pass!!!" | ||||||||||
|
||||||||||
// CheckSyncConfigFunc holds the CheckSyncConfig function. | ||||||||||
CheckSyncConfigFunc func(ctx context.Context, cfgs []*config.SubTaskConfig, errCnt, warnCnt int64) error | ||||||||||
CheckSyncConfigFunc func(ctx context.Context, cfgs []*config.SubTaskConfig, errCnt, warnCnt int64) (string, error) | ||||||||||
) | ||||||||||
|
||||||||||
func init() { | ||||||||||
CheckSyncConfigFunc = CheckSyncConfig | ||||||||||
} | ||||||||||
|
||||||||||
// CheckSyncConfig checks synchronization configuration. | ||||||||||
func CheckSyncConfig(ctx context.Context, cfgs []*config.SubTaskConfig, errCnt, warnCnt int64) error { | ||||||||||
func CheckSyncConfig(ctx context.Context, cfgs []*config.SubTaskConfig, errCnt, warnCnt int64) (string, error) { | ||||||||||
if len(cfgs) == 0 { | ||||||||||
return nil | ||||||||||
return "", nil | ||||||||||
} | ||||||||||
|
||||||||||
// all `IgnoreCheckingItems` and `Mode` of sub-task are same, so we take first one | ||||||||||
|
@@ -53,25 +56,29 @@ func CheckSyncConfig(ctx context.Context, cfgs []*config.SubTaskConfig, errCnt, | |||||||||
} | ||||||||||
checkingItems := config.FilterCheckingItems(ignoreCheckingItems) | ||||||||||
if len(checkingItems) == 0 { | ||||||||||
return nil | ||||||||||
return "", nil | ||||||||||
} | ||||||||||
|
||||||||||
c := NewChecker(cfgs, checkingItems, errCnt, warnCnt) | ||||||||||
|
||||||||||
if err := c.Init(ctx); err != nil { | ||||||||||
return terror.Annotate(err, "fail to initial checker") | ||||||||||
return "", terror.Annotate(err, "fail to initial checker") | ||||||||||
} | ||||||||||
defer c.Close() | ||||||||||
|
||||||||||
pr := make(chan pb.ProcessResult, 1) | ||||||||||
c.Process(ctx, pr) | ||||||||||
for len(pr) > 0 { | ||||||||||
if len(pr) > 0 { | ||||||||||
r := <-pr | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how about we always assume there is one result in Lines 44 to 47 in d8dab8d
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It can be seen that I think we can modify these unreasonable places after the end of this feature. Result is also. @Ehco1996 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. actully it depends on requirements, i am not sure if we have a plan to merge full-time/sync-time sync_diff in to checker? if so i thinks it's better to treat checker as a unit |
||||||||||
// we only want first error | ||||||||||
if len(r.Errors) > 0 { | ||||||||||
return terror.ErrTaskCheckSyncConfigError.Generate(ErrorMsgHeader, r.Errors[0].Message, string(r.Detail)) | ||||||||||
return "", terror.ErrTaskCheckSyncConfigError.Generate(CheckTaskMsgHeader, r.Errors[0].Message, string(r.Detail)) | ||||||||||
} | ||||||||||
if len(r.Detail) == 0 { | ||||||||||
return CheckTaskSuccess, nil | ||||||||||
} | ||||||||||
return fmt.Sprintf("%s: no errors but some warnings\n detail: %v", CheckTaskMsgHeader, string(r.Detail)), nil | ||||||||||
okJiang marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
} | ||||||||||
|
||||||||||
return nil | ||||||||||
return "", nil | ||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -445,7 +445,7 @@ func (s *Server) DMAPIStartTask(c *gin.Context) { | |
for i := range subTaskConfigList { | ||
subTaskConfigPList[i] = &subTaskConfigList[i] | ||
} | ||
if err = checker.CheckSyncConfigFunc(newCtx, subTaskConfigPList, | ||
if _, err = checker.CheckSyncConfigFunc(newCtx, subTaskConfigPList, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so user use openapi to start-task can not see the warnings ?, i thinks we need log theso these warnnings at leaset |
||
common.DefaultErrorCnt, common.DefaultWarnCnt); err != nil { | ||
_ = c.Error(terror.WithClass(err, terror.ClassDMMaster)) | ||
return | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see details, golangci/golangci-lint#1372