[ECS] PipeCD failed to recognize last success deployment in PlanPreview
What happened:
- During the first deployment of a service, that deployment failed so the next PR for fixing that service will always lead to the below error
Error:
Reason: failed while calculating diff, cannot get the old manifests without the last successful deployment
What you expected to happen:
- If the first deployment of a service failed, the next Plan Preview for that service should consider it as a new deployment instead of finding last successful deployment.
How to reproduce it:
- Create PipeCD
app.pipecd.yamlconfig file. - Create an app on the Web UI.
- Let that first deployment fail.
- Create another PR to fix that first deployment.
Environment:
pipedversion:v0.51.0control-planeversion:v0.51.0- Others:
actions-plan-preview: v1.7.6
@t-kikuc hey, can i work on this?
@ani1609 Thank you. Please leave investigation note here before submitting a PR
@vuongvm812 You mean it failed while PlanPreview, not while deployment, right?
@vuongvm812 I changed the title to avoid misunderstanding. If my title is wrong, please tell me 👍
@vuongvm812 You mean it failed while PlanPreview, not while deployment, right?
Sorry for missing your replies. Yes this is when we ran Plan Preview, not deployment.
@t-kikuc Hi, I've noticed that this issue have stayed idle for a while
I have my quick investigation here:
- The error breakdown into 2 parts: "failed while calculating diff" and "cannot get the old manifests without the last successful"
- The first part belong to line 269
pkg/app/piped/planpreview/builder.go, which just only wrap the error when calculating the diff between old and new manifest. - The second part belong to line 49 - line 52
pkg/app/piped/planpreview/ecsdiff.go
if lastCommit == "" {
fmt.Fprintf(buf, "failed to find the commit of the last successful deployment")
return nil, fmt.Errorf("cannot get the old manifests without the last successful deployment")
}
lastCommit will be empty since the first deployment was failed.
The simplest way solution maybe follow how kubernetesdiff.go handles calculating diff.
var oldManifests, newManifests []provider.Manifest
...
if lastSuccessfulCommit != "" {
runningDSP := deploysource.NewProvider(
b.workingDir,
deploysource.NewGitSourceCloner(b.gitClient, b.repoCfg, "running", lastSuccessfulCommit),
*app.GitPath,
b.secretDecrypter,
)
oldManifests, err = loadKubernetesManifests(ctx, *app, runningDSP, b.appManifestsCache, b.gitClient, b.logger)
if err != nil {
fmt.Fprintf(buf, "failed to load kubernetes manifests at the running commit (%v)\n", err)
return nil, err
}
}
This mean if lastCommit is empty, oldManifest will be empty and provider.DiffList will result in empty change, which also mean this will trigger
if result.NoChange() {
fmt.Fprintln(buf, "No changes were detected")
return &diffResult{
summary: "No changes were detected",
noChange: true,
}, nil
}
I want to ask you some questions before futher investigation
- The code checking
lastCommit != ""is also applied for cloud run and lambda, why there was no other similar report/issue - If I resolve this issue, should I record video or capture screen as a proof
And can you also assign this issue for me.
Hi @t-kikuc, I just wanted to check whether this bug is low priority, since PlanPreview might be moved to a separate repository and everyone is focusing on the PipeCD v1 release. If PipeCD v1 is nearly released, let me know where I can help with