Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 22 additions & 8 deletions pkg/app/api/grpcapi/piped_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1156,15 +1156,29 @@ func (a *PipedAPI) InChainDeploymentPlannable(ctx context.Context, req *pipedser
}

prevBlock := dc.Blocks[req.DeploymentChainBlockIndex-1]
plannable := true
deploymentIds := make([]string, 0, len(prevBlock.Nodes))
for _, node := range prevBlock.Nodes {
// TODO: Consider add deployment status to the deployment ref in the deployment chain model
// instead of fetching deployment model here.
dp, err := a.deploymentStore.GetDeployment(ctx, node.DeploymentRef.DeploymentId)
if err != nil {
return nil, status.Error(codes.Internal, "unable to process previous block nodes in deployment chain")
}
if model.IsSuccessfullyCompletedDeployment(dp.Status) {
deploymentIds = append(deploymentIds, node.DeploymentRef.DeploymentId)
}

// TODO: Consider add deployment status to the deployment ref in the deployment chain model
// instead of fetching deployment model here.
blockDeployments, _, err := a.deploymentStore.ListDeployments(ctx, datastore.ListOptions{
Filters: []datastore.ListFilter{
{
Field: "Id",
Operator: datastore.OperatorIn,
Value: deploymentIds,
},
},
})
if err != nil {
return nil, status.Error(codes.Internal, "unable to process previous block nodes in deployment chain")
}

plannable := true
for _, dp := range blockDeployments {
if !model.IsSuccessfullyCompletedDeployment(dp.Status) {
Comment on lines +1161 to +1181
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you tell me what was wrong with determining logic?
Or we just changed from using Get to List with the In operator.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition is flipped, previously it was

if model.IsSuccessfullyCompletedDeployment(dp.Status) {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it!

Copy link
Member Author

@khanhtc1202 khanhtc1202 Nov 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And as you said, I changed the implementation to use In operator to reduce database read, but the TODO note has remained. I will address the issue of adding deployment status to the node.DeploymentRef later, currently just want to focus on the deployment chain flow works 🙏

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you 🙆‍♀️

plannable = false
break
}
Expand Down