Skip to content

[vtadmin-web] Add simple /schema view with table definition#7615

Merged
rohit-nayak-ps merged 5 commits intovitessio:masterfrom
tinyspeck:sarabee-vtadmin-web-schema
Mar 9, 2021
Merged

[vtadmin-web] Add simple /schema view with table definition#7615
rohit-nayak-ps merged 5 commits intovitessio:masterfrom
tinyspeck:sarabee-vtadmin-web-schema

Conversation

@doeg
Copy link
Contributor

@doeg doeg commented Mar 5, 2021

Signed-off-by: Sara Bee 855595+doeg@users.noreply.github.com

Description

Pretty straightforward! Only instruments the loading + error handling behaviour for now.

Eventually, this page will show things like:

  • Detailed column information
  • Vindex data
  • Data size + row distribution
  • ... and anything else we can think of. 😎 (We have a bigger list.)

I'll add syntax highlighting later on. I'm not super happy with any of the options + want to be thoughtful about it.

OK
Screen Shot 2021-03-04 at 9 21 42 PM
Screen Shot 2021-03-04 at 9 26 04 PM

404
Screen Shot 2021-03-04 at 9 21 50 PM

Error
Screen Shot 2021-03-04 at 9 22 06 PM

Related Issue(s)

Checklist

  • Should this PR be backported? No
  • Tests were added or are not required
  • Documentation was added or is not required

Deployment Notes

N/A

Impacted Areas in Vitess

Components that this PR will affect:

  • Query Serving
  • VReplication
  • Cluster Management
  • Build/CI
  • VTAdmin

@doeg doeg requested review from ajm188 and rohit-nayak-ps March 5, 2021 02:34
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have been idly wondering if "Table not found" is confusing given that the route is /schema/.... I guess "schema" is a fairly overloaded term in general. 🤔 Definitely open to suggestions.

Copy link
Contributor

Choose a reason for hiding this comment

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

The wording I went with for FindSchema was "no schema found with table %s"

@doeg doeg changed the title Add simple /schema view with table definition [vtadmin-web] Add simple /schema view with table definition Mar 5, 2021
Signed-off-by: Sara Bee <855595+doeg@users.noreply.github.com>
@doeg doeg force-pushed the sarabee-vtadmin-web-schema branch from a199423 to 5aeb9ac Compare March 5, 2021 03:10
Copy link
Contributor

@ajm188 ajm188 left a comment

Choose a reason for hiding this comment

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

lg2m! a couple non-blocking questions

return json as HttpResponse;
// Throw "not ok" responses so that react-query correctly interprets them as errors.
// See https://react-query.tanstack.com/guides/query-functions#handling-and-throwing-errors
if (!json.ok) throw new HttpResponseNotOkError(endpoint, json);
Copy link
Contributor

Choose a reason for hiding this comment

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

"NotOkError" seems redundant to me, how about either throw HttpResponseNotOk or throw HttpResponseError ? (also if this is "just a react/ts convention" please let me know!)

Copy link
Contributor

Choose a reason for hiding this comment

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

(also i know this is a type from previous PRs ....... which i probably approved without comment so .........)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree it's redundant but I do find it descriptive. This error is specifically when response.ok (in the JSON response envelope) is false.

There are other kinds of "HTTP response errors", like MalformedHttpResponseError which occurs when the response envelope is an unexpected shape. (In all cases, the Error suffix is there since it extends the base Error class.)

I added a commit with bit of commentary on the above. If you still feel like HttpResponseNotOkError is redundant, I can change it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Cool, this makes sense to me!

Copy link
Contributor

Choose a reason for hiding this comment

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

The wording I went with for FindSchema was "no schema found with table %s"

<td>{row.keyspace}</td>
<td>{row.tableDefinition?.name}</td>
<td>
<Link to={`/schema/${row.cluster?.id}/${row.keyspace}/${row.tableDefinition?.name}`}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this generate an invalid link if row.cluster and row.tableDefinition aren't defined?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeahhhh... so this is one of the annoying things about all proto fields being optional, even when they basically never are in practice. Validating all the pieces all the time can be so cumbersome.

In this case though, I was just being lazy. I've updated it so that in the rare instance that we can't generate a link, the table name will be rendered as plain text (assuming it's defined... which, y'know, it almost certainly will be).

doeg added 2 commits March 5, 2021 16:14
Signed-off-by: Sara Bee <855595+doeg@users.noreply.github.com>
Signed-off-by: Sara Bee <855595+doeg@users.noreply.github.com>
@doeg
Copy link
Contributor Author

doeg commented Mar 5, 2021

@ajm188 thanks for the comments. I think I addressed them all.

Here's what the placeholder looks like based on your suggestion:

Screen Shot 2021-03-05 at 4 29 28 PM

Signed-off-by: Sara Bee <855595+doeg@users.noreply.github.com>
@doeg doeg force-pushed the sarabee-vtadmin-web-schema branch from a56b854 to 80f6d29 Compare March 5, 2021 21:32
Copy link
Contributor

@ajm188 ajm188 left a comment

Choose a reason for hiding this comment

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

Sorry I was slow on the reply. This looks good to me!

return json as HttpResponse;
// Throw "not ok" responses so that react-query correctly interprets them as errors.
// See https://react-query.tanstack.com/guides/query-functions#handling-and-throwing-errors
if (!json.ok) throw new HttpResponseNotOkError(endpoint, json);
Copy link
Contributor

Choose a reason for hiding this comment

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

Cool, this makes sense to me!

Signed-off-by: Sara Bee <855595+doeg@users.noreply.github.com>
@doeg
Copy link
Contributor Author

doeg commented Mar 7, 2021

Just had to push a sneaky little CSS change for really wide table definitions. 😊 (This will change when we add vindex + column information anyway.)

@rohit-nayak-ps rohit-nayak-ps merged commit 2d82b00 into vitessio:master Mar 9, 2021
@askdba askdba added the Component: VTAdmin VTadmin interface label Mar 10, 2021
@askdba askdba added this to the v10.0 milestone Mar 10, 2021
@doeg doeg deleted the sarabee-vtadmin-web-schema branch November 1, 2021 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component: VTAdmin VTadmin interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants