Skip to content

Conversation

@EronWright
Copy link
Contributor

@EronWright EronWright commented Oct 20, 2025

Fixes #751

Summary

When a Stack with destroyOnFinalize=true is being deleted, skip prerequisite validation to allow deletion to proceed even if prerequisite Stacks are missing or have already been deleted.

This is important for GitOps workflows with tools like Flux and ArgoCD where resources may be deleted in any order.

Changes

  • Stack Controller: Skip prerequisite checks during Stack deletion when the Stack is marked for deletion
  • Test: Added test case in the Prerequisites section verifying that a Stack with missing prerequisites can be successfully deleted

Rationale

Prerequisites are only relevant during creation/updates for dependency ordering and output references. During deletion, these dependencies are not relevant (except if --run-program were used, but a missing prerequisite would block deletion forever).

The implementation uses an early continue in the prerequisite loop, allowing for future enhancements where individual prerequisites could be configured as deletion blockers.

Test Plan

  • All existing tests pass (91/91 specs)
  • New test added: "Prerequisites > when the stack is being deleted > when the prerequisite is missing > proceeds with deletion despite missing prerequisite"
  • Verified that destroy Update is created even when prerequisite is missing
  • Verified that Stack is not marked as failed due to missing prerequisite

🤖 Generated with Claude Code

@EronWright EronWright self-assigned this Oct 20, 2025
@EronWright EronWright requested review from a team and Copilot October 20, 2025 23:20
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes an issue where Stack deletion would be blocked if prerequisite Stacks were missing or already deleted. The fix allows Stacks with destroyOnFinalize=true to proceed with deletion regardless of prerequisite status, which is essential for GitOps workflows where resources may be deleted in any order.

Key Changes:

  • Skip prerequisite validation checks when a Stack is marked for deletion
  • Add test coverage for deletion with missing prerequisites

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
operator/internal/controller/pulumi/stack_controller.go Added logic to skip prerequisite checks during Stack deletion
operator/internal/controller/pulumi/stack_controller_test.go Added test case verifying deletion proceeds despite missing prerequisites
CHANGELOG.md Added entry documenting the fix

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@EronWright
Copy link
Contributor Author

Verification Complete

I've verified that the fix works correctly by commenting out the continue block and running the test suite.

Test Results

Without the fix (continue block commented out):

  • The new test case FAILED as expected
  • Error: Expected <v1alpha1.UpdateType>: to equal <v1alpha1.UpdateType>: destroy
  • Root cause: Controller stopped at prerequisite check and set condition to PrerequisiteNotSatisfied with message "unable to fetch prerequisite \"prereq-vnchc7zq\": stacks.pulumi.com \"prereq-vnchc7zq\" not found"
  • This confirms the bug described in Stack will not be deleted when prerequisite stack is missing #751 - deletion was blocked by the missing prerequisite

With the fix (continue block active):

  • All 91 tests PASSED
  • The new test case successfully verifies that:
    • A destroy Update is created even when prerequisite is missing
    • Stack is not marked as failed due to missing prerequisite
    • Deletion proceeds correctly

This demonstrates that the fix correctly allows Stack deletion to proceed even when prerequisites are missing, which is essential for GitOps workflows where resources may be deleted in any order.

EronWright and others added 3 commits October 20, 2025 17:04
Fixes #751

When a Stack with destroyOnFinalize=true is being deleted, skip
prerequisite validation to allow deletion to proceed even if
prerequisite Stacks are missing or have already been deleted.

This is important for GitOps workflows with tools like Flux and
ArgoCD where resources may be deleted in any order.

Prerequisites are only relevant during creation/updates for dependency
ordering and output references. During deletion, these dependencies
are not relevant (except if --run-program were used, but a missing
prerequisite would block deletion forever).

The implementation uses an early continue in the prerequisite loop,
allowing for future enhancements where individual prerequisites
could be configured as deletion blockers.

Changes:
- Skip prerequisite checks during Stack deletion
- Add test case for deletion with missing prerequisites
- Update CHANGELOG

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@EronWright EronWright force-pushed the eronwright/fix-751-prerequisite-deletion branch from 3b3eff0 to 5bb6abf Compare October 21, 2025 00:06
@EronWright EronWright enabled auto-merge (squash) October 21, 2025 15:59
@codecov
Copy link

codecov bot commented Oct 21, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 53.32%. Comparing base (f2a3513) to head (5bb6abf).
⚠️ Report is 44 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1034      +/-   ##
==========================================
+ Coverage   53.03%   53.32%   +0.29%     
==========================================
  Files          34       34              
  Lines        4646     5016     +370     
==========================================
+ Hits         2464     2675     +211     
- Misses       1987     2134     +147     
- Partials      195      207      +12     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@EronWright EronWright merged commit 195d32a into master Oct 21, 2025
12 of 24 checks passed
@EronWright EronWright deleted the eronwright/fix-751-prerequisite-deletion branch October 21, 2025 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stack will not be deleted when prerequisite stack is missing

2 participants