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-api] Add HTTP endpoints for /api/srvvschemas and /api/srvvschema/{cluster}/{cell} #8226

Merged

Conversation

doeg
Copy link
Contributor

@doeg doeg commented Jun 1, 2021

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

Description

This adds two new endpoints to vtadmin-api:

  • /api/srvvschemas[?cluster=...&cell=...], which returns the SrvVSchema for all clusters and all cells, optionally filtered by a subset of clusters/cells
  • /api/srvvschema/{cluster}/{cell}, which returns the SrvVSchema for a particular cell.
curl -s "http://localhost:14200/api/srvvschemas" | jq .
{
  "result": {
    "srv_v_schemas": [
      {
        "cell": "zone1",
        "cluster": {
          "id": "local",
          "name": "local"
        },
        "srv_v_schema": {
          "keyspaces": {
            "commerce": {
              "tables": {
                "customer_seq": {
                  "type": "sequence"
                },
                "order_seq": {
                  "type": "sequence"
                },
                "product": {}
              }
            },
            "customer": {
              "sharded": true,
              "vindexes": {
                "hash": {
                  "type": "hash"
                }
              },
              "tables": {
                "corder": {
                  "column_vindexes": [
                    {
                      "column": "customer_id",
                      "name": "hash"
                    }
                  ],
                  "auto_increment": {
                    "column": "order_id",
                    "sequence": "order_seq"
                  }
                },
                "customer": {
                  "column_vindexes": [
                    {
                      "column": "customer_id",
                      "name": "hash"
                    }
                  ],
                  "auto_increment": {
                    "column": "customer_id",
                    "sequence": "customer_seq"
                  }
                }
              }
            }
          },
          "routing_rules": {}
        }
      }
    ]
  },
  "ok": true
}
curl -s "http://localhost:14200/api/srvvschemas?cluster=nope" | jq .
{
  "result": {},
  "ok": true
}
curl -s "http://localhost:14200/api/srvvschemas?cell=nope" | jq .
{
  "result": {},
  "ok": true
}
curl -s "http://localhost:14200/api/srvvschema/local/zone1" | jq .
{
  "result": {
    "cell": "zone1",
    "cluster": {
      "id": "local",
      "name": "local"
    },
    "srv_v_schema": {
      "keyspaces": {
        "commerce": {
          "tables": {
            "customer_seq": {
              "type": "sequence"
            },
            "order_seq": {
              "type": "sequence"
            },
            "product": {}
          }
        },
        "customer": {
          "sharded": true,
          "vindexes": {
            "hash": {
              "type": "hash"
            }
          },
          "tables": {
            "corder": {
              "column_vindexes": [
                {
                  "column": "customer_id",
                  "name": "hash"
                }
              ],
              "auto_increment": {
                "column": "order_id",
                "sequence": "order_seq"
              }
            },
            "customer": {
              "column_vindexes": [
                {
                  "column": "customer_id",
                  "name": "hash"
                }
              ],
              "auto_increment": {
                "column": "customer_id",
                "sequence": "customer_seq"
              }
            }
          }
        }
      },
      "routing_rules": {}
    }
  },
  "ok": true
}
curl -s "http://localhost:14200/api/srvvschema/no/nope" | jq .
{
  "error": {
    "message": "unsupported cluster(s): no",
    "code": "unknown"
  },
  "ok": false
}
curl -s "http://localhost:14200/api/srvvschema/local/nope" | jq .
{
  "error": {
    "message": "rpc error: code = Unknown desc = node doesn't exist: /vitess/global/cells/nope/CellInfo",
    "code": "unknown"
  },
  "ok": false
}

Related Issue(s)

This is second half of #8221. 🐈

Checklist

  • Tests were added or are not required
  • Documentation was added or is not required

Deployment Notes

N/A

@doeg doeg added Component: VTAdmin VTadmin interface Type: Enhancement Logical improvement (somewhere between a bug and feature) labels Jun 1, 2021
@doeg doeg marked this pull request as ready for review June 1, 2021 11:15
@doeg doeg requested a review from rafael June 1, 2021 11:15
…hema/{cluster}/{cell}

Signed-off-by: Sara Bee <855595+doeg@users.noreply.github.com>
@doeg doeg force-pushed the sarabee-vtadmin-srvvschema-endpoints branch from 3520741 to aed2349 Compare June 1, 2021 11:16
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.

lgtm

@ajm188 ajm188 merged commit 532d272 into vitessio:master Jun 1, 2021
@ajm188 ajm188 deleted the sarabee-vtadmin-srvvschema-endpoints branch June 1, 2021 12:18
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.

2 participants