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

Implement Migration Complexity Explanation providing the summary and rationale for reported complexity #2166

Merged
merged 11 commits into from
Jan 9, 2025

Conversation

sanyamsinghal
Copy link
Collaborator

@sanyamsinghal sanyamsinghal commented Jan 9, 2025

Describe the changes in this pull request

Different explanation in case of html and json. Html also includes the summary about categories and issues count.

https://yugabyte.atlassian.net/browse/DB-14717

Describe if there are any user-facing changes

  • Analyze Schema report has stopped reporting migration complexity
  • Assessment Report will have one more field - MigrationComplexityExplanation

Sample HTML Report

  1. Non zero issues
image
  1. Zero Issues
image

Sample JSON Report

image

How was this pull request tested?

Manually.
This is a new field in the assessment report which we plan to add to test later with other UI changes.
Also have to modified the upgrade unit test for the new field.

Does your PR have changes that can cause upgrade issues?

Component Breaking changes?
MetaDB No
Name registry json No
Data File Descriptor Json No
Export Snapshot Status Json No
Import Data State No
Export Status Json No
Data .sql files of tables No
Export and import data queue No
Schema Dump No
AssessmentDB No
Sizing DB No
Migration Assessment Report Json No
Callhome Json No
YugabyteD Tables No
TargetDB Metadata Tables No


// ======================================= Migration Complexity Explanation ==========================================

const explainTemplateHTML = `
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would like to avoid having HTML in multiple places. It should all ideally be in the template file. Morevoer, field AssessmentReport.MigrationComplexityExplanation having HTML would be weird.
But I get why you did this. (because json and HTML have different requirements).

Here's one way to do this:

  1. in AssessmentReport, instead of storing just the final string in MigrationComplexityExplanation, store the actual ExplanationData struct.
  2. in HTML template, you have all the necessary information to build the table there.
  3. for json, just exclude the summaries from it. (in fact there's no harm in even keeping it tbh).

Copy link
Contributor

@priyanshi-yb priyanshi-yb Jan 9, 2025

Choose a reason for hiding this comment

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

Agree to this, we should keep all the HTML code in that template

for json, just exclude the summaries from it. (in fact there's no harm in even keeping it tbh).

yes we can keep it in JSON as well, in case of tests and all you are anyways ignoring it

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added a TODO comment

yb-voyager/cmd/migration_complexity.go Outdated Show resolved Hide resolved
yb-voyager/src/utils/utils.go Outdated Show resolved Hide resolved
yb-voyager/cmd/migration_complexity.go Outdated Show resolved Hide resolved
var err error
assessmentReport.MigrationComplexityExplanation, err = buildMigrationComplexityExplanation(source.DBType, assessmentReport, "")
if err != nil {
utils.PrintAndLog("ERROR: unable to build migration complexity explanation for json report: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

why utils.PrintAndLog, use return fmt.Errorf(..) ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was thinking of showing something on console also for users to know that explanation is not there for xyz reason

Copy link
Contributor

@priyanshi-yb priyanshi-yb Jan 9, 2025

Choose a reason for hiding this comment

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

The top level functions which is calling the generateAssessmentReportJson must be printing the error on console for users so it will come eventually right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

will this not look good? any suggestions?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The top level functions which is calling the generateAssessmentReportJson must be printing the error on console for users so it will come eventually right?

No, what i did was to not error out the cmd if building explanation fails...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

are you suggesting to error out in this scenario?

Copy link
Contributor

@priyanshi-yb priyanshi-yb Jan 9, 2025

Choose a reason for hiding this comment

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

Oh, I see. Ideally, we should return the error,and mostly the errors occur while buildMigrationComplexityExplanation is generating HTML string, etc.
For the case, we should fail the command for this new addition, we can use env var approach and if user faces any blocker we can always ask them to disable it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

hmm makes sense, this is the standard code - creating template and executing it.
Should not be error here ideally.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

yb-voyager/cmd/assessMigrationCommand.go Outdated Show resolved Hide resolved
yb-voyager/cmd/common.go Show resolved Hide resolved
yb-voyager/cmd/migration_complexity.go Show resolved Hide resolved
@sanyamsinghal sanyamsinghal changed the title Implement Migration Complexity Explainability providing the summary and rationale for reported complexity Implement Migration Complexity Explanation providing the summary and rationale for reported complexity Jan 9, 2025
@sanyamsinghal sanyamsinghal self-assigned this Jan 9, 2025

// TODO: discuss if the html should be in main report or here
const explainTemplateHTML = `
<p>Below is a detailed breakdown of issues by category, showing the count for each impact level.</p>
Copy link
Collaborator

Choose a reason for hiding this comment

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

How about Below is a breakdown of the issues detected in different categories for each impact level ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah better.

Copy link
Collaborator

@makalaaneesh makalaaneesh left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@priyanshi-yb priyanshi-yb left a comment

Choose a reason for hiding this comment

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

LGTM


var result []MigrationComplexityCategorySummary
for _, summary := range summaryMap {
summary.Category = utils.SnakeCaseToTitleCase(summary.Category)
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of using this function we can get the Feature heading for that Enum to be consistent with the heading in report.
but given that we are anyways changing the UI, we can revisit it later so okay for now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah lets revisit this. The category here is being fetched from the analyze schema issue.

I see the same issues of formatting in schema reports. We need to fix the root.

@sanyamsinghal sanyamsinghal merged commit 7802ecb into main Jan 9, 2025
67 checks passed
@sanyamsinghal sanyamsinghal deleted the sanyam/mig-explainability branch January 9, 2025 11:59
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.

4 participants