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

VTAdmin: Support for schema migrations view/create #17134

Merged
merged 8 commits into from
Nov 29, 2024

Conversation

beingnoble03
Copy link
Member

@beingnoble03 beingnoble03 commented Nov 4, 2024

Description

This PR adds a screen for schema migrations list for a particular keyspace, and a screen to create schema migration request. Also includes some related API changes.

Screenshots

Screenshot 2024-11-04 at 7 56 55 PM Screenshot 2024-11-08 at 3 25 40 PM

Related Issue(s)

Checklist

  • "Backport to:" labels have been added if this change should be back-ported to release branches
  • If this change is to be back-ported to previous releases, a justification is included in the PR description
  • Tests were added or are not required
  • Did the new or modified tests pass consistently locally and on CI?
  • Documentation was added or is not required

Deployment Notes

Copy link
Contributor

vitess-bot bot commented Nov 4, 2024

Review Checklist

Hello reviewers! 👋 Please follow this checklist when reviewing this Pull Request.

General

  • Ensure that the Pull Request has a descriptive title.
  • Ensure there is a link to an issue (except for internal cleanup and flaky test fixes), new features should have an RFC that documents use cases and test cases.

Tests

  • Bug fixes should have at least one unit or end-to-end test, enhancement and new features should have a sufficient number of tests.

Documentation

  • Apply the release notes (needs details) label if users need to know about this change.
  • New features should be documented.
  • There should be some code comments as to why things are implemented the way they are.
  • There should be a comment at the top of each new or modified test to explain what the test does.

New flags

  • Is this flag really necessary?
  • Flag names must be clear and intuitive, use dashes (-), and have a clear help text.

If a workflow is added or modified:

  • Each item in Jobs should be named in order to mark it as required.
  • If the workflow needs to be marked as required, the maintainer team must be notified.

Backward compatibility

  • Protobuf changes should be wire-compatible.
  • Changes to _vt tables and RPCs need to be backward compatible.
  • RPC changes should be compatible with vitess-operator
  • If a flag is removed, then it should also be removed from vitess-operator and arewefastyet, if used there.
  • vtctl command output order should be stable and awk-able.

@vitess-bot vitess-bot bot added NeedsBackportReason If backport labels have been applied to a PR, a justification is required NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsIssue A linked issue is missing for this Pull Request NeedsWebsiteDocsUpdate What it says labels Nov 4, 2024
@github-actions github-actions bot added this to the v22.0.0 milestone Nov 4, 2024
@beingnoble03 beingnoble03 added Type: Enhancement Logical improvement (somewhere between a bug and feature) Component: VTAdmin VTadmin interface and removed NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsWebsiteDocsUpdate What it says NeedsIssue A linked issue is missing for this Pull Request NeedsBackportReason If backport labels have been applied to a PR, a justification is required labels Nov 4, 2024
Copy link

codecov bot commented Nov 4, 2024

Codecov Report

Attention: Patch coverage is 43.33333% with 17 lines in your changes missing coverage. Please review.

Project coverage is 67.41%. Comparing base (4980d6f) to head (3db89f7).
Report is 32 commits behind head on main.

Files with missing lines Patch % Lines
go/vt/vtadmin/http/schema_migrations.go 0.00% 11 Missing ⚠️
go/vt/vtadmin/api.go 68.42% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #17134      +/-   ##
==========================================
+ Coverage   67.39%   67.41%   +0.02%     
==========================================
  Files        1570     1574       +4     
  Lines      252892   253247     +355     
==========================================
+ Hits       170437   170734     +297     
- Misses      82455    82513      +58     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@beingnoble03 beingnoble03 force-pushed the vtadmin-schema-migrations branch from cdbf4bc to f27341a Compare November 4, 2024 14:41
@beingnoble03 beingnoble03 force-pushed the vtadmin-schema-migrations branch from f27341a to ddc420a Compare November 4, 2024 14:45
@beingnoble03 beingnoble03 marked this pull request as ready for review November 4, 2024 14:48
@rohit-nayak-ps
Copy link
Contributor

This UI is only for the vitess ddl strategy. So we don't need that option while creating.

I will let @shlomi-noach comment on the UI requirements for a first cut. We will also need a detail screen from the list view.

@shlomi-noach
Copy link
Contributor

Hey there! A few comments:

  • DDL strategy can include DDL strategy flags. So for example it could look like vitess --postpone-completion --singleton-context --cut-over-threshold=15s. In light of that, let leave it editable. But then, it also requires quite a length box. I'd say keyspace has too much space, and DDL strategy too little.
  • It is possible to submit a migration with direct DDL strategy -- but then it won't show in the schema migrations page.
  • However, the strategy mysql is a hybrid of the two - and will show in the schema migrations page.

So yes, let's allow free text in the DDL strategy flag.

@beingnoble03
Copy link
Member Author

As discussed, I've removed the ddl-strategy text box, to allow only vitess ddl strategy. We can add the advanced options in a follow-up PR?

@shlomi-noach
Copy link
Contributor

As discussed, I've removed the ddl-strategy text box, to allow only vitess ddl strategy.

This looks to be a misunderstanding, in #17134 (comment) I indicated that we should keep it after all?

@rohit-nayak-ps
Copy link
Contributor

As discussed, I've removed the ddl-strategy text box, to allow only vitess ddl strategy.

This looks to be a misunderstanding, in #17134 (comment) I indicated that we should keep it after all?

My bad. The plan was to create an initial PR with defaults and then add UI for the strategy options. But maybe we should just add the text box to start with, so that we do support everything and then replace them with the UI later. @beingnoble03, can you please reinstate the text box, sorry for the confusion.

@shlomi-noach
Copy link
Contributor

@rohit-nayak-ps no problem, feel free to lead the way. I'll set some time next week to think about what we discussed over zoom, and how the UI can take shape in the next iteration.

@beingnoble03
Copy link
Member Author

@rohit-nayak-ps @shlomi-noach done, also increased the size of the box as mentioned.

@rohit-nayak-ps
Copy link
Contributor

  • On creating a new migration, it goes to the Migrations screen but without choosing a keyspace, so it shows up empty and is confusing. Also on refreshing it goes back to the empty screen because it doesn't remember the chosen keyspace.

  • We should also have a details page for each migration with more details including the actual sql query.

  • i created a migration in a sharded keyspace and it only shows one of the shards in the detail.

  • Also I think we should change the default strategy to vitess: since that is how we expect most users to run migrations. Remove gh-ost (already unsupported) and pt-osc (slated to be removed soon): https://vitess.io/docs/22.0/user-guides/schema-changes/ddl-strategies/.

  • Regarding UI: can we align the timestamps so that it is easier to compare.

@beingnoble03
Copy link
Member Author

beingnoble03 commented Nov 13, 2024

  • On creating a new migration, it goes to the Migrations screen but without choosing a keyspace, so it shows up empty and is confusing. Also on refreshing it goes back to the empty screen because it doesn't remember the chosen keyspace.

Fixed.

  • We should also have a details page for each migration with more details including the actual sql query.

Can this be done in follow-up PRs?

  • i created a migration in a sharded keyspace and it only shows one of the shards in the detail.
Screenshot 2024-11-13 at 10 52 42 PM

This is how it shows migrations for resharded keyspace. It shows different entries for different shards, even for the same migration. This is the format we get from GetSchemaMigrations (different objs for different shards). Please let me know if we can to club this together in UI, we can do this in a follow-up PR.

Done.

  • Regarding UI: can we align the timestamps so that it is easier to compare.

Done.

@beingnoble03 beingnoble03 force-pushed the vtadmin-schema-migrations branch from 7ad0af7 to fefdb5d Compare November 13, 2024 17:35
Copy link
Contributor

@rohit-nayak-ps rohit-nayak-ps left a comment

Choose a reason for hiding this comment

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

Nice. Let's should do the following in a followup:

  • Show a single line for each migration, keyed with UUID. That line can show just the shards involved and a consolidated status (similar to how we show a combined Workflow status for all streams)
  • Add a details page where all the shards involved along with more info like the actual query itself is shown

@rohit-nayak-ps rohit-nayak-ps requested review from notfelineit and removed request for notfelineit November 19, 2024 18:57
@deepthi deepthi requested review from shlomi-noach and removed request for harshit-gangal, ajm188 and shlomi-noach November 25, 2024 18:25

const history = useHistory();

const [formData, setFormData] = useState<FormData>(DEFAULT_FORM_DATA);
Copy link
Contributor

Choose a reason for hiding this comment

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

This implementation of the form fields will cause the entire page to rerender whenever a parameter of formData changes, since below, we set formData to a brand new object each time.

Would prefer using flat state vars or simply using the HTML form data in a submission - however this is a nonblocking comment as you/we can refactor in a separate PR! 😄

Copy link
Member Author

Choose a reason for hiding this comment

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

👍 I think this makes more sense to be done in a separate PR, as there are other components using the same structure.

import { vtctldata } from '../proto/vtadmin';

/**
* SCEMA_MIGRATION_STATUS maps numeric schema migration status back to human readable strings.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* SCEMA_MIGRATION_STATUS maps numeric schema migration status back to human readable strings.
* SCHEMA_MIGRATION_STATUS maps numeric schema migration status back to human readable strings.

/**
* SCEMA_MIGRATION_STATUS maps numeric schema migration status back to human readable strings.
*/
export const SCEMA_MIGRATION_STATUS = Object.entries(invertBy(vtctldata.SchemaMigration.Status)).reduce(
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
export const SCEMA_MIGRATION_STATUS = Object.entries(invertBy(vtctldata.SchemaMigration.Status)).reduce(
export const SCHEMA_MIGRATION_STATUS = Object.entries(invertBy(vtctldata.SchemaMigration.Status)).reduce(

);

export const formatSchemaMigrationStatus = (schemaMigration: vtctldata.ISchemaMigration) =>
schemaMigration.status && SCEMA_MIGRATION_STATUS[schemaMigration.status];
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
schemaMigration.status && SCEMA_MIGRATION_STATUS[schemaMigration.status];
schemaMigration.status && SCHEMA_MIGRATION_STATUS[schemaMigration.status];

Signed-off-by: Noble Mittal <[email protected]>
@rohit-nayak-ps rohit-nayak-ps merged commit 68b25b3 into vitessio:main Nov 29, 2024
102 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: VTAdmin VTadmin interface Type: Enhancement Logical improvement (somewhere between a bug and feature)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants