Skip to content
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

Fix wrong condition on determine deployment plannable #2860

Merged
merged 1 commit into from
Nov 29, 2021

Conversation

khanhtc1202
Copy link
Member

What this PR does / why we need it:

Which issue(s) this PR fixes:

Follow PR #2832

Does this PR introduce a user-facing change?:

NONE

@pipecd-bot
Copy link
Collaborator

TODO

The following ISSUES will be created once got merged. If you want me to skip creating the issue, you can use /todo skip command.

Details

1. Consider add deployment status to the deployment ref in the deployment chain model

https://github.com/pipe-cd/pipe/blob/73aec2ec7e61cec702deab9c34f8ba296e6ea6f0/pkg/app/api/grpcapi/piped_api.go#L1164-L1167

This was created by todo plugin since "TODO:" was found in 73aec2e when #2860 was merged. cc: @khanhtc1202.

@khanhtc1202
Copy link
Member Author

/todo skip

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 31.70%. This pull request decreases coverage by -0.01%.

File Function Base Head Diff
pkg/app/api/grpcapi/piped_api.go PipedAPI.InChainDeploymentPlannable 0.00% 0.00% +0.00%

Comment on lines +1161 to +1181
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) {
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

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 🙆‍♀️

@nghialv
Copy link
Member

nghialv commented Nov 29, 2021

/lgtm

@nakabonne
Copy link
Member

Good catch
/approve

@pipecd-bot
Copy link
Collaborator

APPROVE

This pull request is APPROVED by nakabonne.

Approvers can cancel the approval by writing /approve cancel in a comment. Any additional commits also will change this pull request to be not-approved.

@pipecd-bot pipecd-bot merged commit 0056370 into master Nov 29, 2021
@pipecd-bot pipecd-bot deleted the fix-wrong-plannable-cond branch November 29, 2021 05:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants