You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement the core destroy command functionality in the DDD Application Layer. This epic focuses on the internal business logic for tearing down deployed environments, without the user-facing CLI interface.
This follows an inside-outside approach: build the core application logic first, validate it with E2E tests, then add the UI layer in a separate epic.
🎯 Goals
Add DestroyCommand in the DDD Application Layer
Implement resource cleanup logic for all infrastructure components
Update E2E test infrastructure to use the new destroy command
Ensure clean teardown of OpenTofu and Ansible-managed resources
Issue #11: Add DestroyCommand in Application Layer
Description: Create the DestroyCommand struct and implementation in src/application/commands/destroy/ with complete infrastructure teardown functionality.
Scope:
Create command structure following existing command patterns (ProvisionCommand, ConfigCommand)
Implement complete destroy execution logic using existing infrastructure services
Add command error types with proper error handling
Leverage existing OpenTofu client (already used in manual cleanup)
Leverage existing Ansible services (if needed for cleanup)
Integrate destroy command into src/bin/e2e_tests_full.rs for immediate testing
Rationale: We already have the infrastructure teardown logic in src/testing/e2e/tasks/virtual_machine/cleanup_infrastructure.rs that calls OpenTofu client and other services. This subtask combines command creation with infrastructure teardown because they're closely coupled and we need the full functionality to test it properly.
Acceptance Criteria:
DestroyCommand exists in src/application/commands/destroy/
Issue #12: Update E2E Provision Tests to Include Destroy
Description: Modify src/bin/e2e_provision_tests.rs binary to use the new destroy command instead of manual cleanup, ensuring CI can run complete provision+destroy cycles.
Scope:
Replace manual cleanup in e2e_provision_tests.rs with DestroyCommand
Keep manual cleanup as fallback for destroy command failures
Ensure the binary works in GitHub Actions environment
Update binary name to reflect new functionality (optional: rename to e2e_provision_and_destroy_tests.rs)
Rationale: This ensures we have automated testing of the destroy functionality in CI, preventing regressions. The provision tests are already running real OpenTofu infrastructure, so adding destroy testing here gives us confidence the feature works end-to-end.
Acceptance Criteria:
e2e_provision_tests.rs uses DestroyCommand for cleanup
Manual cleanup preserved as fallback for destroy failures
Binary works correctly in GitHub Actions
Proper error handling and logging for destroy operations
Epic Type: Child Epic #9 (Phase 1 of Task 1.2)
Parent Epic: #8 (
epic-destroy-command.md)Related Roadmap: Section 1.2
Parent Issue: #2 (Scaffolding for main app)
Roadmap Section: 1.2 - Create command
torrust-tracker-deployer destroyType: Epic
Priority: High
📋 Epic Overview
Implement the core destroy command functionality in the DDD Application Layer. This epic focuses on the internal business logic for tearing down deployed environments, without the user-facing CLI interface.
This follows an inside-outside approach: build the core application logic first, validate it with E2E tests, then add the UI layer in a separate epic.
🎯 Goals
DestroyCommandin the DDD Application Layer🚫 Non-Goals
📦 Sub-Issues
Issue #11: Add DestroyCommand in Application Layer
Description: Create the
DestroyCommandstruct and implementation insrc/application/commands/destroy/with complete infrastructure teardown functionality.Scope:
ProvisionCommand,ConfigCommand)src/bin/e2e_tests_full.rsfor immediate testingRationale: We already have the infrastructure teardown logic in
src/testing/e2e/tasks/virtual_machine/cleanup_infrastructure.rsthat calls OpenTofu client and other services. This subtask combines command creation with infrastructure teardown because they're closely coupled and we need the full functionality to test it properly.Acceptance Criteria:
DestroyCommandexists insrc/application/commands/destroy/thiserrorsrc/bin/e2e_tests_full.rsto test the feature locallyEstimated Effort: 6-8 hours
Issue #12: Update E2E Provision Tests to Include Destroy
Description: Modify
src/bin/e2e_provision_tests.rsbinary to use the new destroy command instead of manual cleanup, ensuring CI can run complete provision+destroy cycles.Scope:
e2e_provision_tests.rswithDestroyCommande2e_provision_and_destroy_tests.rs)Rationale: This ensures we have automated testing of the destroy functionality in CI, preventing regressions. The provision tests are already running real OpenTofu infrastructure, so adding destroy testing here gives us confidence the feature works end-to-end.
Acceptance Criteria:
e2e_provision_tests.rsusesDestroyCommandfor cleanupEstimated Effort: 3-4 hours
Issue #13: Add Developer Documentation
Description: Document the destroy command implementation for developers.
Scope:
docs/contributing/about destroy commandDestroyCommandin codeAcceptance Criteria:
docs/contributing/DestroyCommandEstimated Effort: 2-3 hours
📊 Epic Summary
Total Estimated Effort: 11-15 hours
Sub-Issues:
🔗 Dependencies
📝 Technical Notes
Design Considerations
Open Questions
Testing Strategy
e2e_tests_full.rs): Complete lifecycle including destroy (implemented in subtask 1)e2e_provision_tests.rs): Provision + destroy cycle on real infrastructure (updated in subtask 2)e2e_config_tests.rs): Configuration only (no destroy needed)🚀 Next Steps After Completion
After completing this epic:
📋 Related Documentation
Epic Document: docs/issues/9-epic-app-layer-destroy-command.md