-
Notifications
You must be signed in to change notification settings - Fork 113
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
feat: add API for pipeline status check. Fixes #407. #599
Changes from 4 commits
62f5295
dbe23a5
558a346
0cb57b0
b8aa572
417db28
a6e0307
e304de2
7dfd2fa
f6773c2
ff5c66f
2b0e07a
db04a38
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,12 @@ message VertexMetrics { | |
map<string, int64> pendings = 4; | ||
} | ||
|
||
// PipelineStatus | ||
message PipelineStatus { | ||
required bool health = 1; | ||
required string message = 2; | ||
} | ||
|
||
message ListBuffersRequest { | ||
required string pipeline = 1; | ||
} | ||
|
@@ -64,6 +70,14 @@ message GetBufferResponse { | |
required BufferInfo buffer = 1; | ||
} | ||
|
||
message GetPipelineStatusRequest { | ||
required string pipeline = 1; | ||
} | ||
|
||
message GetPipelineStatusResponse { | ||
required PipelineStatus status = 1; | ||
} | ||
|
||
message GetVertexMetricsRequest { | ||
required string pipeline = 2; | ||
required string vertex = 3; | ||
|
@@ -110,4 +124,9 @@ service DaemonService { | |
rpc GetPipelineWatermarks (GetPipelineWatermarksRequest) returns (GetPipelineWatermarksResponse) { | ||
option (google.api.http).get = "/api/v1/pipelines/{pipeline}/watermarks"; | ||
}; | ||
|
||
// GetPipelineStatus () returns (PipelineStatus) // status: bool and string | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comment is not up to date. |
||
rpc GetPipelineStatus (GetPipelineStatusRequest) returns (GetPipelineStatusResponse) { | ||
option (google.api.http).get = "/api/v1/pipelines/{pipeline}/status"; | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -233,6 +233,40 @@ func (ps *pipelineMetadataQuery) GetVertexMetrics(ctx context.Context, req *daem | |
return resp, nil | ||
} | ||
|
||
func (ps *pipelineMetadataQuery) GetPipelineStatus(ctx context.Context, req *daemon.GetPipelineStatusRequest) (*daemon.GetPipelineStatusResponse, error) { | ||
|
||
resp := new(daemon.GetPipelineStatusResponse) | ||
|
||
// get all vertices of pipeline | ||
vertices := ps.pipeline.Spec.Vertices | ||
|
||
// loop over vertices and get metrics to check pending messages vs processing rate | ||
for _, vertex := range vertices { | ||
vertexReq := new(daemon.GetVertexMetricsRequest) | ||
vertexReq.Pipeline = req.Pipeline | ||
vertexReq.Vertex = &vertex.Name | ||
vertexResp, err := ps.GetVertexMetrics(ctx, vertexReq) | ||
if err != nil { | ||
return nil, err | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If err is not nil, should not return an error, it probably just because autoscaling down to 0 and then metrics are not available. In this case, we could just return the status as |
||
} | ||
// check default pending msg and processing rates | ||
if vertexResp.VertexMetrics[0].Pendings["default"] > 0 && vertexResp.VertexMetrics[0].ProcessingRates["default"] == 0 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should not only check [0], reduce vertex has more items in the array. Based on the |
||
resp.Status = &daemon.PipelineStatus{ | ||
Health: pointer.Bool(false), | ||
Message: pointer.String("Pipeline may have issue."), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. More information in the message, such as which vertex has what issue. |
||
} | ||
return resp, nil | ||
} | ||
} | ||
|
||
resp.Status = &daemon.PipelineStatus{ | ||
Health: pointer.Bool(true), | ||
Message: pointer.String("Pipeline has no issue."), | ||
} | ||
return resp, nil | ||
|
||
} | ||
|
||
func getBufferLimits(pl *v1alpha1.Pipeline, edge v1alpha1.Edge) (bufferLength int64, bufferUsageLimit float64) { | ||
plLimits := pl.GetPipelineLimits() | ||
bufferLength = int64(*plLimits.BufferMaxLength) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably should go with a string type status, which has more meanings other than only true/false. For example,
OK/Unknown/Error/...