Skip to content

Commit 6bf1539

Browse files
Enhancements to YBD payload after assessment refactoring (#2238)
* Bumped up the payload version to 1.2 * Updated the AssessmentIssue payload for YBD to be in sync with standard struct format * Adding MigrationComplexityExplanation to ybd assessment payload
1 parent 7a68e5e commit 6bf1539

File tree

2 files changed

+60
-102
lines changed

2 files changed

+60
-102
lines changed

yb-voyager/cmd/assessMigrationCommand.go

+36-88
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ func packAndSendAssessMigrationPayload(status string, errMsg string) {
166166
// whatever happens later will be stored in the struct's field. so to be on safer side, we will build it again here as per required format.
167167
explanation, err := buildMigrationComplexityExplanation(source.DBType, assessmentReport, "")
168168
if err != nil {
169-
log.Errorf("failed to build migration complexity explanation: %v", err)
169+
log.Errorf("failed to build migration complexity explanation for callhome assessment payload: %v", err)
170170
}
171171

172172
var obfuscatedIssues []callhome.AssessmentIssueCallhome
@@ -462,15 +462,22 @@ func createMigrationAssessmentCompletedEvent() *cp.MigrationAssessmentCompletedE
462462
utils.PrintAndLog("failed to calculate the total sharded table size from tableIndexStats: %v", err)
463463
}
464464

465-
assessmentIssues := flattenAssessmentReportToAssessmentIssues(assessmentReport)
465+
assessmentIssues := convertAssessmentIssueToYugabyteDAssessmentIssue(assessmentReport)
466+
// we will build this twice for json and html reports both, at the time of report generation.
467+
// whatever happens later will be stored in the struct's field. so to be on safer side, we will build it again here as per required format.
468+
explanation, err := buildMigrationComplexityExplanation(source.DBType, assessmentReport, "")
469+
if err != nil {
470+
log.Errorf("failed to build migration complexity explanation for yugabyted assessment payload: %v", err)
471+
}
466472

467473
payload := AssessMigrationPayload{
468-
PayloadVersion: ASSESS_MIGRATION_YBD_PAYLOAD_VERSION,
469-
VoyagerVersion: assessmentReport.VoyagerVersion,
470-
TargetDBVersion: assessmentReport.TargetDBVersion,
471-
MigrationComplexity: assessmentReport.MigrationComplexity,
472-
SchemaSummary: assessmentReport.SchemaSummary,
473-
AssessmentIssues: assessmentIssues,
474+
PayloadVersion: ASSESS_MIGRATION_YBD_PAYLOAD_VERSION,
475+
VoyagerVersion: assessmentReport.VoyagerVersion,
476+
TargetDBVersion: assessmentReport.TargetDBVersion,
477+
MigrationComplexity: assessmentReport.MigrationComplexity,
478+
MigrationComplexityExplanation: explanation,
479+
SchemaSummary: assessmentReport.SchemaSummary,
480+
AssessmentIssues: assessmentIssues,
474481
SourceSizeDetails: SourceDBSizeDetails{
475482
TotalIndexSize: assessmentReport.GetTotalIndexSize(),
476483
TotalTableSize: assessmentReport.GetTotalTableSize(),
@@ -510,84 +517,25 @@ func createMigrationAssessmentCompletedEvent() *cp.MigrationAssessmentCompletedE
510517
return ev
511518
}
512519

513-
// flatten UnsupportedDataTypes, UnsupportedFeatures, MigrationCaveats
514-
func flattenAssessmentReportToAssessmentIssues(ar AssessmentReport) []AssessmentIssueYugabyteD {
515-
var issues []AssessmentIssueYugabyteD
516-
517-
var dataTypesDocsLink string
518-
switch source.DBType {
519-
case POSTGRESQL:
520-
dataTypesDocsLink = UNSUPPORTED_DATATYPES_DOC_LINK
521-
case ORACLE:
522-
dataTypesDocsLink = UNSUPPORTED_DATATYPES_DOC_LINK_ORACLE
523-
}
524-
for _, unsupportedDataType := range ar.UnsupportedDataTypes {
525-
issues = append(issues, AssessmentIssueYugabyteD{
526-
Type: constants.DATATYPE,
527-
TypeDescription: GetCategoryDescription(constants.DATATYPE),
528-
Subtype: unsupportedDataType.DataType,
529-
ObjectName: fmt.Sprintf("%s.%s.%s", unsupportedDataType.SchemaName, unsupportedDataType.TableName, unsupportedDataType.ColumnName),
530-
SqlStatement: "",
531-
DocsLink: dataTypesDocsLink,
532-
})
533-
}
534-
535-
for _, unsupportedFeature := range ar.UnsupportedFeatures {
536-
for _, object := range unsupportedFeature.Objects {
537-
issues = append(issues, AssessmentIssueYugabyteD{
538-
Type: constants.FEATURE,
539-
TypeDescription: GetCategoryDescription(constants.FEATURE),
540-
Subtype: unsupportedFeature.FeatureName,
541-
SubtypeDescription: unsupportedFeature.FeatureDescription, // TODO: test payload once we add desc for unsupported features
542-
ObjectName: object.ObjectName,
543-
SqlStatement: object.SqlStatement,
544-
DocsLink: unsupportedFeature.DocsLink,
545-
MinimumVersionsFixedIn: unsupportedFeature.MinimumVersionsFixedIn,
546-
})
547-
}
548-
}
549-
550-
for _, migrationCaveat := range ar.MigrationCaveats {
551-
for _, object := range migrationCaveat.Objects {
552-
issues = append(issues, AssessmentIssueYugabyteD{
553-
Type: constants.MIGRATION_CAVEATS,
554-
TypeDescription: GetCategoryDescription(constants.MIGRATION_CAVEATS),
555-
Subtype: migrationCaveat.FeatureName,
556-
SubtypeDescription: migrationCaveat.FeatureDescription,
557-
ObjectName: object.ObjectName,
558-
SqlStatement: object.SqlStatement,
559-
DocsLink: migrationCaveat.DocsLink,
560-
MinimumVersionsFixedIn: migrationCaveat.MinimumVersionsFixedIn,
561-
})
562-
}
563-
}
564-
565-
for _, uqc := range ar.UnsupportedQueryConstructs {
566-
issues = append(issues, AssessmentIssueYugabyteD{
567-
Type: constants.QUERY_CONSTRUCT,
568-
TypeDescription: GetCategoryDescription(constants.QUERY_CONSTRUCT),
569-
Subtype: uqc.ConstructTypeName,
570-
SqlStatement: uqc.Query,
571-
DocsLink: uqc.DocsLink,
572-
MinimumVersionsFixedIn: uqc.MinimumVersionsFixedIn,
573-
})
574-
}
575-
576-
for _, plpgsqlObjects := range ar.UnsupportedPlPgSqlObjects {
577-
for _, object := range plpgsqlObjects.Objects {
578-
issues = append(issues, AssessmentIssueYugabyteD{
579-
Type: constants.PLPGSQL_OBJECT,
580-
TypeDescription: GetCategoryDescription(constants.PLPGSQL_OBJECT),
581-
Subtype: plpgsqlObjects.FeatureName,
582-
SubtypeDescription: plpgsqlObjects.FeatureDescription,
583-
ObjectName: object.ObjectName,
584-
SqlStatement: object.SqlStatement,
585-
DocsLink: plpgsqlObjects.DocsLink,
586-
MinimumVersionsFixedIn: plpgsqlObjects.MinimumVersionsFixedIn,
587-
})
520+
func convertAssessmentIssueToYugabyteDAssessmentIssue(ar AssessmentReport) []AssessmentIssueYugabyteD {
521+
var result []AssessmentIssueYugabyteD
522+
for _, issue := range ar.Issues {
523+
ybdIssue := AssessmentIssueYugabyteD{
524+
Category: issue.Category,
525+
CategoryDescription: issue.CategoryDescription,
526+
Type: issue.Type, // Ques: should we be just sending Name in AssessmentIssueYugabyteD payload
527+
Name: issue.Name,
528+
Description: issue.Description,
529+
Impact: issue.Impact,
530+
ObjectType: issue.ObjectType,
531+
ObjectName: issue.ObjectName,
532+
SqlStatement: issue.SqlStatement,
533+
DocsLink: issue.DocsLink,
534+
MinimumVersionsFixedIn: issue.MinimumVersionsFixedIn,
588535
}
536+
result = append(result, ybdIssue)
589537
}
590-
return issues
538+
return result
591539
}
592540

593541
func runAssessment() error {
@@ -1229,10 +1177,10 @@ func fetchUnsupportedPlPgSQLObjects(schemaAnalysisReport utils.SchemaReport) []U
12291177
})
12301178
}
12311179
feature := UnsupportedFeature{
1232-
FeatureName: issueName,
1233-
DisplayDDL: true,
1234-
DocsLink: docsLink,
1235-
Objects: objects,
1180+
FeatureName: issueName,
1181+
DisplayDDL: true,
1182+
DocsLink: docsLink,
1183+
Objects: objects,
12361184
MinimumVersionsFixedIn: minVersionsFixedIn,
12371185
}
12381186
unsupportedPlpgSqlObjects = append(unsupportedPlpgSqlObjects, feature)

yb-voyager/cmd/common.go

+24-14
Original file line numberDiff line numberDiff line change
@@ -1129,27 +1129,37 @@ type AssessMigrationDBConfig struct {
11291129
// =============== for yugabyted controlplane ==============//
11301130
// TODO: see if this can be accommodated in controlplane pkg, facing pkg cyclic dependency issue
11311131

1132-
var ASSESS_MIGRATION_YBD_PAYLOAD_VERSION = "1.1" // version(s) till now: 1.0, 1.1
1132+
/*
1133+
Version History
1134+
1.0: Introduced AssessmentIssue field for storing assessment issues in flattened format
1135+
1.1: Added TargetDBVersion and AssessmentIssueYugabyteD.MinimumVersionFixedIn
1136+
1.2: Syncing it with original AssessmentIssue(adding fields Category, CategoryDescription, Type, Name, Description, Impact, ObjectType) and MigrationComplexityExplanation;
1137+
*/
1138+
var ASSESS_MIGRATION_YBD_PAYLOAD_VERSION = "1.2"
11331139

11341140
type AssessMigrationPayload struct {
1135-
PayloadVersion string
1136-
VoyagerVersion string
1137-
TargetDBVersion *ybversion.YBVersion
1138-
MigrationComplexity string
1139-
SchemaSummary utils.SchemaSummary
1140-
AssessmentIssues []AssessmentIssueYugabyteD
1141-
SourceSizeDetails SourceDBSizeDetails
1142-
TargetRecommendations TargetSizingRecommendations
1143-
ConversionIssues []utils.AnalyzeSchemaIssue
1141+
PayloadVersion string
1142+
VoyagerVersion string
1143+
TargetDBVersion *ybversion.YBVersion
1144+
MigrationComplexity string
1145+
MigrationComplexityExplanation string
1146+
SchemaSummary utils.SchemaSummary
1147+
AssessmentIssues []AssessmentIssueYugabyteD
1148+
SourceSizeDetails SourceDBSizeDetails
1149+
TargetRecommendations TargetSizingRecommendations
1150+
ConversionIssues []utils.AnalyzeSchemaIssue
11441151
// Depreacted: AssessmentJsonReport is depricated; use the fields directly inside struct
11451152
AssessmentJsonReport AssessmentReportYugabyteD
11461153
}
11471154

11481155
type AssessmentIssueYugabyteD struct {
1149-
Type string `json:"Type"` // Feature, DataType, MigrationCaveat, UQC
1150-
TypeDescription string `json:"TypeDescription"` // Based on AssessmentIssue type
1151-
Subtype string `json:"Subtype"` // GIN Indexes, Advisory Locks etc
1152-
SubtypeDescription string `json:"SubtypeDescription"` // description based on subtype
1156+
Category string `json:"Category"` // expected values: unsupported_features, unsupported_query_constructs, migration_caveats, unsupported_plpgsql_objects, unsupported_datatype
1157+
CategoryDescription string `json:"CategoryDescription"`
1158+
Type string `json:"Type"` // Ex: GIN_INDEXES, SECURITY_INVOKER_VIEWS, STORED_GENERATED_COLUMNS
1159+
Name string `json:"Name"` // Ex: GIN Indexes, Security Invoker Views, Stored Generated Columns
1160+
Description string `json:"Description"` // description based on type/name
1161+
Impact string `json:"Impact"` // // Level-1, Level-2, Level-3 (no default: need to be assigned for each issue)
1162+
ObjectType string `json:"ObjectType"` // For datatype category, ObjectType will be datatype (for eg "geometry")
11531163
ObjectName string `json:"ObjectName"` // Fully qualified object name(empty if NA, eg UQC)
11541164
SqlStatement string `json:"SqlStatement"` // DDL or DML(UQC)
11551165
DocsLink string `json:"DocsLink"` // docs link based on the subtype

0 commit comments

Comments
 (0)