Skip to content

Commit 81ed314

Browse files
authored
VTAdmin: Workflow status endpoint (#16587)
Signed-off-by: Noble Mittal <noblemittal@outlook.com>
1 parent 78a54ce commit 81ed314

File tree

10 files changed

+1943
-1075
lines changed

10 files changed

+1943
-1075
lines changed

go/vt/proto/vtadmin/vtadmin.pb.go

Lines changed: 1162 additions & 1070 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go/vt/proto/vtadmin/vtadmin_grpc.pb.go

Lines changed: 38 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go/vt/proto/vtadmin/vtadmin_vtproto.pb.go

Lines changed: 243 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go/vt/vtadmin/api.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,7 @@ func (api *API) Handler() http.Handler {
417417
router.HandleFunc("/vtexplain", httpAPI.Adapt(vtadminhttp.VTExplain)).Name("API.VTExplain")
418418
router.HandleFunc("/workflow/{cluster_id}/{keyspace}/{name}", httpAPI.Adapt(vtadminhttp.GetWorkflow)).Name("API.GetWorkflow")
419419
router.HandleFunc("/workflows", httpAPI.Adapt(vtadminhttp.GetWorkflows)).Name("API.GetWorkflows")
420+
router.HandleFunc("/workflow/{cluster_id}/{keyspace}/{name}/status", httpAPI.Adapt(vtadminhttp.GetWorkflowStatus)).Name("API.GetWorkflowStatus")
420421

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

1666+
// GetWorkflowStatus is part of the vtadminpb.VTAdminServer interface.
1667+
func (api *API) GetWorkflowStatus(ctx context.Context, req *vtadminpb.GetWorkflowStatusRequest) (*vtctldatapb.WorkflowStatusResponse, error) {
1668+
span, ctx := trace.NewSpan(ctx, "API.GetWorkflowStatus")
1669+
defer span.Finish()
1670+
1671+
c, err := api.getClusterForRequest(req.ClusterId)
1672+
if err != nil {
1673+
return nil, err
1674+
}
1675+
1676+
cluster.AnnotateSpan(c, span)
1677+
span.Annotate("keyspace", req.Keyspace)
1678+
span.Annotate("workflow_name", req.Name)
1679+
1680+
if !api.authz.IsAuthorized(ctx, c.ID, rbac.WorkflowResource, rbac.GetAction) {
1681+
return nil, nil
1682+
}
1683+
1684+
return c.Vtctld.WorkflowStatus(ctx, &vtctldatapb.WorkflowStatusRequest{
1685+
Keyspace: req.Keyspace,
1686+
Workflow: req.Name,
1687+
})
1688+
}
1689+
16651690
// GetWorkflows is part of the vtadminpb.VTAdminServer interface.
16661691
func (api *API) GetWorkflows(ctx context.Context, req *vtadminpb.GetWorkflowsRequest) (*vtadminpb.GetWorkflowsResponse, error) {
16671692
span, ctx := trace.NewSpan(ctx, "API.GetWorkflows")

0 commit comments

Comments
 (0)