pipecd icon indicating copy to clipboard operation
pipecd copied to clipboard

[ECS] PipeCD failed to recognize last success deployment in PlanPreview

Open vuongvm812 opened this issue 6 months ago • 7 comments

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.yaml config file.
  • Create an app on the Web UI.
  • Let that first deployment fail.
  • Create another PR to fix that first deployment.

Environment:

  • piped version: v0.51.0
  • control-plane version: v0.51.0
  • Others:
    • actions-plan-preview: v1.7.6

vuongvm812 avatar Jun 23 '25 02:06 vuongvm812

@t-kikuc hey, can i work on this?

ani1609 avatar Jun 23 '25 09:06 ani1609

@ani1609 Thank you. Please leave investigation note here before submitting a PR

t-kikuc avatar Jun 23 '25 23:06 t-kikuc

@vuongvm812 You mean it failed while PlanPreview, not while deployment, right?

t-kikuc avatar Jun 27 '25 03:06 t-kikuc

@vuongvm812 I changed the title to avoid misunderstanding. If my title is wrong, please tell me 👍

t-kikuc avatar Jun 27 '25 10:06 t-kikuc

@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.

vuongvm812 avatar Jul 01 '25 01:07 vuongvm812

@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

  1. The code checking lastCommit != "" is also applied for cloud run and lambda, why there was no other similar report/issue
  2. If I resolve this issue, should I record video or capture screen as a proof

And can you also assign this issue for me.

armistcxy avatar Aug 05 '25 10:08 armistcxy

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

armistcxy avatar Aug 08 '25 10:08 armistcxy