-
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 10 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 |
---|---|---|
|
@@ -51,6 +51,12 @@ type pipelineMetadataQuery struct { | |
watermarkFetchers map[string][]fetch.Fetcher | ||
} | ||
|
||
const ( | ||
PipelineStatusOK = "OK" | ||
PipelineStatusError = "Error" | ||
PipelineStatusUnknown = "Unknown" | ||
) | ||
|
||
// NewPipelineMetadataQuery returns a new instance of pipelineMetadataQuery | ||
func NewPipelineMetadataQuery(isbSvcClient isbsvc.ISBService, pipeline *v1alpha1.Pipeline, wmFetchers map[string][]fetch.Fetcher) (*pipelineMetadataQuery, error) { | ||
var err error | ||
|
@@ -233,6 +239,57 @@ 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.Vertex = &vertex.Name | ||
vertexResp, err := ps.GetVertexMetrics(ctx, vertexReq) | ||
// if err is not nil, more than likely autoscaling is down to 0 and metrics are not available | ||
if err != nil { | ||
resp.Status = &daemon.PipelineStatus{ | ||
Status: pointer.String(PipelineStatusUnknown), | ||
Message: pointer.String("Pipeline status is unknown."), | ||
} | ||
return resp, nil | ||
} | ||
|
||
// may need to revisit later, another concern could be that the processing rate is too slow instead of just 0 | ||
for _, vertexMetrics := range vertexResp.VertexMetrics { | ||
if pending, ok := vertexMetrics.GetPendings()["default"]; ok { | ||
if processingRate, ok := vertexMetrics.GetProcessingRates()["default"]; ok { | ||
if pending > 0 && processingRate == 0 { | ||
resp.Status = &daemon.PipelineStatus{ | ||
Status: pointer.String(PipelineStatusError), | ||
Message: pointer.String(fmt.Sprintf("Pipeline has an error. Vertex %s is not processing pending messages.", vertex.Name)), | ||
} | ||
return resp, nil | ||
} | ||
} | ||
} else { | ||
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. We don't need this It is expected sometimes there's no
For these cases, we should consider it's ok. |
||
resp.Status = &daemon.PipelineStatus{ | ||
Status: pointer.String(PipelineStatusError), | ||
Message: pointer.String(fmt.Sprintf("Pipeline has an error. Vertex %s is not processing pending messages.", vertex.Name)), | ||
} | ||
return resp, nil | ||
} | ||
} | ||
} | ||
|
||
resp.Status = &daemon.PipelineStatus{ | ||
Status: pointer.String(PipelineStatusOK), | ||
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.
Can you add some comments, that we need to revisit it later, it might also be caused by the processing is very slow, that the rate is 0.