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

fix: 审核插件 AuditResult 以及相关函数格式变更 #1426

Merged
merged 7 commits into from
Apr 7, 2023
Merged

fix: 审核插件 AuditResult 以及相关函数格式变更 #1426

merged 7 commits into from
Apr 7, 2023

Conversation

jessun
Copy link
Contributor

@jessun jessun commented Apr 7, 2023

fix:

  • 审核插件 gRPC 方法 Audit() 返回结果新增 RuleName;
  • 审核结果 AuditResults 的 Add() 方法支持 RuleName 参数;
  • 相关测试用例代码变更

related: #1411

@jessun jessun requested a review from sjjian April 7, 2023 02:50
@@ -352,7 +352,7 @@ func (i *MysqlDriverImpl) audit(ctx context.Context, sql string) (*driverV2.Audi
buf.WriteString(fmt.Sprintf(", 原因(%s)", advice.Reason))
}
}
i.result.Add(driverV2.RuleLevelNotice, buf.String())
i.result.Add(driverV2.RuleLevelNotice, "", buf.String())
Copy link
Member

Choose a reason for hiding this comment

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

添加索引有相关规则对应

@@ -362,9 +362,9 @@ func (i *MysqlDriverImpl) audit(ctx context.Context, sql string) (*driverV2.Audi
}
if useGhost {
if _, err := i.executeByGhost(ctx, sql, true); err != nil {
i.result.Add(driverV2.RuleLevelError, fmt.Sprintf("表空间大小超过%vMB, 将使用gh-ost进行上线, 但是dry-run抛出如下错误: %v", i.cnf.DDLGhostMinSize, err))
i.result.Add(driverV2.RuleLevelError, "", fmt.Sprintf("表空间大小超过%vMB, 将使用gh-ost进行上线, 但是dry-run抛出如下错误: %v", i.cnf.DDLGhostMinSize, err))
Copy link
Member

Choose a reason for hiding this comment

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

gh-ost 有相关规则对应

} else {
i.result.Add(ghostRule.Level, fmt.Sprintf("表空间大小超过%vMB, 将使用gh-ost进行上线", i.cnf.DDLGhostMinSize))
i.result.Add(ghostRule.Level, "", fmt.Sprintf("表空间大小超过%vMB, 将使用gh-ost进行上线", i.cnf.DDLGhostMinSize))
Copy link
Member

Choose a reason for hiding this comment

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

gh-ost 有相关规则对应

@@ -374,7 +374,7 @@ func (i *MysqlDriverImpl) audit(ctx context.Context, sql string) (*driverV2.Audi
return nil, err
}
if oscCommandLine != "" {
i.result.Add(driverV2.RuleLevelNotice, fmt.Sprintf("[osc]%s", oscCommandLine))
i.result.Add(driverV2.RuleLevelNotice, "", fmt.Sprintf("[osc]%s", oscCommandLine))
Copy link
Member

Choose a reason for hiding this comment

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

osc 有相关规则对应

@@ -81,7 +81,7 @@ func (i *MysqlDriverImpl) CheckExplain(node ast.Node) error {
_, err = i.Ctx.GetExecutionPlan(node.Text())
}
if err != nil {
i.result.Add(driverV2.RuleLevelWarn, fmt.Sprintf(CheckInvalidErrorFormat, err))
i.result.Add(driverV2.RuleLevelWarn, "", fmt.Sprintf(CheckInvalidErrorFormat, err))
Copy link
Member

Choose a reason for hiding this comment

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

预检查有对应的规则

@sjjian sjjian merged commit b890733 into actiontech:main Apr 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants