Skip to content
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

dm: display instruction separately if precheck error is terror.Error #8201

Merged
merged 28 commits into from
Feb 21, 2023

Conversation

D3Hunter
Copy link
Contributor

@D3Hunter D3Hunter commented Feb 8, 2023

What problem does this PR solve?

Issue Number: ref #4287

What is changed and how it works?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Questions

Will it cause performance regression or break compatibility?
Do you need to update user documentation, design documentation or monitoring documentation?

Release note

`None`.

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Feb 8, 2023

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • buchuitoudegou
  • lance6716

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added the release-note-none Denotes a PR that doesn't merit a release note. label Feb 8, 2023
@D3Hunter D3Hunter requested review from lance6716 and buchuitoudegou and removed request for lance6716 February 8, 2023 11:02
@ti-chi-bot ti-chi-bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Feb 8, 2023
@D3Hunter D3Hunter requested a review from lance6716 February 8, 2023 11:02
result.Errors = append(result.Errors, &Error{Severity: state, ShortErr: err.Error()})
if err2, ok := err.(*terror.Error); ok {
result.Errors = append(result.Errors, &Error{Severity: state, ShortErr: err2.ErrorWithoutWorkaround()})
result.Instruction = err2.Workaround()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does it look like?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we trim the [....], from the short_error? Looks confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Errors may contain multiple errors, so instruction should also be prepraed for multiple lines?

Copy link
Contributor Author

@D3Hunter D3Hunter Feb 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

precheck item returns on first error(not failed to precheck kind of error, it's the error that we cannot run precheck normally) meet. if error passed into it is a multi-err instance(tables check), use the else branch.

result.Errors = append(result.Errors, &Error{Severity: state, ShortErr: err.Error()})
if err2, ok := err.(*terror.Error); ok {
result.Errors = append(result.Errors, &Error{Severity: state, ShortErr: err2.ErrorWithoutWorkaround()})
result.Instruction = err2.Workaround()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we trim the [....], from the short_error? Looks confusing.

@@ -204,15 +204,21 @@ func (e *Error) Workaround() string {
return e.workaround
}

// Error implements error interface.
func (e *Error) Error() string {
// ErrorWithoutWorkaround returns err msg without workaround, in some place like cloud we want display it separately.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember the instruction fields have been filled for all the check items (i.e., Results[i].Instruction). Where can we use this function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if precheck fail with err, there is no instruction. it's used in markCheckError

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

err2 := verifyPrivilegesWithResult(result, grants, dumpRequiredPrivs)
if err2 != nil {
result.Errors = append(result.Errors, err2)
result.Instruction = "Please grant the required privileges to the account."
} else {

The instruction is set in the Result and dm-on-cloud uses this field as the solution. Do you mean it's only used in op?

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Feb 9, 2023
Copy link
Contributor

@lance6716 lance6716 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rest lgtm

result.Errors = append(result.Errors, &Error{Severity: state, ShortErr: err.Error()})
if err2, ok := err.(*terror.Error); ok {
result.Errors = append(result.Errors, &Error{Severity: state, ShortErr: err2.ErrorWithoutWorkaround()})
result.Instruction = err2.Workaround()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Errors may contain multiple errors, so instruction should also be prepraed for multiple lines?

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Feb 10, 2023
@D3Hunter
Copy link
Contributor Author

6.6 branch created, will merge it

@D3Hunter
Copy link
Contributor Author

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 4f082b8

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Feb 10, 2023
@D3Hunter
Copy link
Contributor Author

/run-engine-integration-test
/run-verify
/run-dm-integration-test

@lance6716
Copy link
Contributor

some unit tests are failed @D3Hunter

=== FAIL: dm/pkg/terror TestTError (0.00s)

    terror_test.go:59: 

        	Error Trace:	/home/jenkins/agent/workspace/pingcap/tiflow/ghpr_verify/tiflow/dm/pkg/terror/terror_test.go:59

        	Error:      	Not equal: 

        	            	expected: "[code=10002:class=database:scope=upstream:level=medium], Message: bad connection, Workaround: please check your network connection"

        	            	actual  : "[code=10002:class=database:scope=upstream:level=medium]Message: bad connection, Workaround: please check your network connection"

        	            	

        	            	Diff:

        	            	--- Expected

        	            	+++ Actual

        	            	@@ -1 +1 @@

        	            	-[code=10002:class=database:scope=upstream:level=medium], Message: bad connection, Workaround: please check your network connection

        	            	+[code=10002:class=database:scope=upstream:level=medium]Message: bad connection, Workaround: please check your network connection

        	Test:       	TestTError

@ti-chi-bot ti-chi-bot removed the status/can-merge Indicates a PR has been approved by a committer. label Feb 17, 2023
@D3Hunter
Copy link
Contributor Author

/run-all-tests

@D3Hunter
Copy link
Contributor Author

/run-all-tests

@D3Hunter
Copy link
Contributor Author

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: bb8ade8

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Feb 21, 2023
@D3Hunter
Copy link
Contributor Author

/run-all-tests

1 similar comment
@D3Hunter
Copy link
Contributor Author

/run-all-tests

@D3Hunter
Copy link
Contributor Author

/run-verify

@ti-chi-bot ti-chi-bot merged commit e9014db into master Feb 21, 2023
@D3Hunter D3Hunter deleted the precheck-instruction branch February 21, 2023 04:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants