Skip to content

Commit

Permalink
VTAdmin: Workflow status endpoint (#16587)
Browse files Browse the repository at this point in the history
Signed-off-by: Noble Mittal <[email protected]>
  • Loading branch information
beingnoble03 authored Aug 23, 2024
1 parent 78a54ce commit 81ed314
Show file tree
Hide file tree
Showing 10 changed files with 1,943 additions and 1,075 deletions.
2,232 changes: 1,162 additions & 1,070 deletions go/vt/proto/vtadmin/vtadmin.pb.go

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions go/vt/proto/vtadmin/vtadmin_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

243 changes: 243 additions & 0 deletions go/vt/proto/vtadmin/vtadmin_vtproto.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions go/vt/vtadmin/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ func (api *API) Handler() http.Handler {
router.HandleFunc("/vtexplain", httpAPI.Adapt(vtadminhttp.VTExplain)).Name("API.VTExplain")
router.HandleFunc("/workflow/{cluster_id}/{keyspace}/{name}", httpAPI.Adapt(vtadminhttp.GetWorkflow)).Name("API.GetWorkflow")
router.HandleFunc("/workflows", httpAPI.Adapt(vtadminhttp.GetWorkflows)).Name("API.GetWorkflows")
router.HandleFunc("/workflow/{cluster_id}/{keyspace}/{name}/status", httpAPI.Adapt(vtadminhttp.GetWorkflowStatus)).Name("API.GetWorkflowStatus")

experimentalRouter := router.PathPrefix("/experimental").Subrouter()
experimentalRouter.HandleFunc("/tablet/{tablet}/debug/vars", httpAPI.Adapt(experimental.TabletDebugVarsPassthrough)).Name("API.TabletDebugVarsPassthrough")
Expand Down Expand Up @@ -1662,6 +1663,30 @@ func (api *API) GetWorkflow(ctx context.Context, req *vtadminpb.GetWorkflowReque
})
}

// GetWorkflowStatus is part of the vtadminpb.VTAdminServer interface.
func (api *API) GetWorkflowStatus(ctx context.Context, req *vtadminpb.GetWorkflowStatusRequest) (*vtctldatapb.WorkflowStatusResponse, error) {
span, ctx := trace.NewSpan(ctx, "API.GetWorkflowStatus")
defer span.Finish()

c, err := api.getClusterForRequest(req.ClusterId)
if err != nil {
return nil, err
}

cluster.AnnotateSpan(c, span)
span.Annotate("keyspace", req.Keyspace)
span.Annotate("workflow_name", req.Name)

if !api.authz.IsAuthorized(ctx, c.ID, rbac.WorkflowResource, rbac.GetAction) {
return nil, nil
}

return c.Vtctld.WorkflowStatus(ctx, &vtctldatapb.WorkflowStatusRequest{
Keyspace: req.Keyspace,
Workflow: req.Name,
})
}

// GetWorkflows is part of the vtadminpb.VTAdminServer interface.
func (api *API) GetWorkflows(ctx context.Context, req *vtadminpb.GetWorkflowsRequest) (*vtadminpb.GetWorkflowsResponse, error) {
span, ctx := trace.NewSpan(ctx, "API.GetWorkflows")
Expand Down
Loading

0 comments on commit 81ed314

Please sign in to comment.