Skip to content

Report deployment failure when pipedv1 planner cannot prepare deploy source - #7649

Open
vikash7485 wants to merge 3 commits into
pipe-cd:masterfrom
vikash7485:fix-pipedv1-planner-deploy-source-failure
Open

vikash7485 wants to merge 3 commits into
pipe-cd:masterfrom
vikash7485:fix-pipedv1-planner-deploy-source-failure

Conversation

@vikash7485

Copy link
Copy Markdown
Contributor

What this PR does:

In pipedv1, when the planner fails to prepare the target or running deploy source (for example the commit doesn't exist, the repository can't be cloned, or a secret can't be decrypted), it only logged the error and returned. This PR reports the deployment as DEPLOYMENT_FAILURE and sends the failure notification, the same way the existing buildPlan error path already does.

If piped is shutting down (the context is cancelled), the deployment is left PENDING so it is planned again after restarting, instead of being marked as failed.

In piped v0 the deploy source is prepared inside planner.Plan, so these errors were already reported as failures there. pipedv1 prepares it before buildPlan, which skipped that reporting.

Why we need it:

The deployment stayed PENDING forever, the application stayed marked as deploying, and no failure was shown or notified. The controller then retried the same deployment after plannerStaleDuration (1 hour) and failed again.

Which issue(s) this PR fixes:

Fixes #7641

Does this PR introduce a user-facing change?:

  • How are users affected by this change: Deployments whose deploy source can't be prepared now fail with a clear reason ("Unable to prepare the target/running deploy source (...)") and a failure notification, instead of staying PENDING.
  • Is this breaking change: No
  • How to migrate (if breaking change): N/A

Tests:

  • Target deploy source fails → deployment reported as failed, failure notification sent.
  • Running deploy source fails → same.
  • Context cancelled (piped shutting down) → nothing reported, deployment stays PENDING.

The two failure tests fail without this change.

…source

When the planner failed to prepare the target or running deploy source,
for example because the commit does not exist or the repository could
not be cloned, it only logged the error. The deployment stayed PENDING
and the application stayed marked as deploying, and the planner retried
it again after an hour.

Report the deployment as failed and send the failure notification, as
already done when building the plan fails. If piped is shutting down,
keep the deployment PENDING so it is planned again after restarting.

Fixes pipe-cd#7641

Signed-off-by: vikash7485 <vikkiraj073@gmail.com>
@vikash7485
vikash7485 requested review from a team as code owners November 18, 2026 19:30
@vikash7485
vikash7485 requested review from Warashi, mohammedfirdouss and t-kikuc and a balanced review from Copilot November 18, 2026 19:30
@netlify

netlify Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

👷 Deploy request for pipecd-site pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit c3abe3e

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Cancellation queued during source preparation can be ignored if preparation fails, incorrectly reporting FAILURE and sending a failure notification instead of reporting CANCELLED and acknowledging the command.

1 open issue
What changed in this PR

Fixes #7641 by routing pipedv1 deploy-source preparation errors through deployment failure reporting, rather than leaving deployments stuck in PENDING.

Changes:

  • Reports target and running source preparation failures with a reason and failure notification.
  • Preserves PENDING when the planner context is cancelled during shutdown.
  • Adds regression tests for both failure paths and shutdown cancellation.
File Description
pkg/​app/​pipedv1/​controller/​planner.go Adds shared source-failure reporting with a shutdown guard.
pkg/​app/​pipedv1/​controller/​planner_deploysource_test.go Tests failure status, notifications, and shutdown behavior.

Review effort: Balanced

Comment thread pkg/app/pipedv1/controller/planner.go Resolved
…oy source

If a deployment was cancelled while its deploy source was being prepared
and the preparation then failed, it was reported as failed and the
cancel command was never marked as handled. Check for the cancel command
before reporting the failure, reusing the same handling as after
building the plan.

Signed-off-by: vikash7485 <vikkiraj073@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues were identified that would block approval.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@harshitghagre

Copy link
Copy Markdown
Member

cc: @mohammedfirdouss

@vikash7485

Copy link
Copy Markdown
Contributor Author

Thanks @harshitghagre

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.

pipedv1: deployment remains stuck in PENDING when deploy source preparation fails in planner

3 participants