Skip to content

Add AFS undelete container operation and fix ASE workload support#2

Draft
zubairabid with Copilot wants to merge 6 commits into
users/zubair/undeleteAFSASEdisableProtASEfrom
copilot/fix-49761f9b-7f59-444e-9ecb-db6f05c2fa11
Draft

Add AFS undelete container operation and fix ASE workload support#2
zubairabid with Copilot wants to merge 6 commits into
users/zubair/undeleteAFSASEdisableProtASEfrom
copilot/fix-49761f9b-7f59-444e-9ecb-db6f05c2fa11

Conversation

Copilot AI commented Aug 21, 2025

Copy link
Copy Markdown

This PR implements the missing undelete container operation for Azure File Share (AFS) and adds full support for SAP ASE workloads in undelete and disable protection operations.

Problem

The backup module was missing critical functionality:

  1. AFS undelete container: While Azure VM and Azure Workload backup types supported undelete operations, Azure File Share (AzureStorage) did not have this capability.

  2. Incomplete ASE workload support: SAP ASE databases were not fully supported for:

    • Undelete container operations
    • Disable protection with retain data functionality

Solution

AFS Undelete Container Support

Added undelete_protection() function in custom_afs.py that:

  • Creates AzureFileshareProtectedItem with appropriate undelete settings
  • Sets is_rehydrate = True to mark the item for rehydration
  • Uses ProtectionState.protection_stopped for proper state management
  • Follows the same pattern as existing VM and workload undelete implementations

Updated the dispatch logic in custom_base.py to route azurestorage backup management type to the new AFS handler.

Complete ASE Workload Support

Extended validation in custom_wl.py to include SAP ASE databases:

  • Updated undelete_protection() to accept SAPAseDatabase items using existing is_sapase() helper
  • Updated disable_protection() to support retain data functionality for ASE workloads
  • Enhanced error messages to clearly indicate ASE database support

Comprehensive Test Coverage

Added thorough test coverage for all new functionality:

  • AFS Undelete Test: Validates the new undelete container operation for Azure File Share items
  • ASE Undelete Test: Tests SAP ASE database undelete protection functionality
  • ASE Disable with Retain Test: Tests disable protection with retain data for ASE workloads

Usage

The following commands are now fully supported:

# AFS undelete container (newly supported)
az backup protection undelete -g myRG -v myVault -c myContainer -i myItem --backup-management-type AzureStorage

# ASE workload undelete (now supported)  
az backup protection undelete -g myRG -v myVault -c myContainer -i myItem --backup-management-type AzureWorkload --workload-type SAPAseDatabase

# ASE workload disable with retain data (now supported)
az backup protection disable -g myRG -v myVault -c myContainer -i myItem --backup-management-type AzureWorkload --workload-type SAPAseDatabase --retain-recovery-points-as-per-policy

Implementation Details

  • Minimal changes: Only 24 lines added/modified across 3 files for core functionality
  • Comprehensive tests: 3 new test methods covering all functionality added
  • No breaking changes: All existing functionality preserved
  • Consistent patterns: Follows existing code architecture and error handling
  • Proper validation: Reuses existing helper functions and validation logic

The implementation seamlessly integrates with the existing backup module infrastructure while providing the missing functionality for both AFS and ASE workload scenarios.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits August 21, 2025 10:26
Co-authored-by: zubairabid <26400677+zubairabid@users.noreply.github.com>
Co-authored-by: zubairabid <26400677+zubairabid@users.noreply.github.com>
Copilot AI changed the title [WIP] We are working on the backup module. Implement undelete container operation for AFS. It is currently present for Azure VM and Azure Workload. Also within Azure Workload: The ASE Workload does not currently support undelete container and disable protec... Add AFS undelete container operation and fix ASE workload support Aug 21, 2025
Copilot AI requested a review from zubairabid August 21, 2025 10:32

@zubairabid zubairabid left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@copilot add some tests for the changes

Co-authored-by: zubairabid <26400677+zubairabid@users.noreply.github.com>

Copilot AI commented Aug 21, 2025

Copy link
Copy Markdown
Author

@copilot add some tests for the changes

Added comprehensive tests for the new functionality in commit d2cc70f:

AFS Undelete Protection Test (test_afs_undelete_protection):

  • Tests the new AFS undelete container operation for AzureStorage backup type
  • Verifies soft-delete state handling and successful undelete operation
  • Uses standard preparers and follows existing test patterns

ASE Workload Tests (test_ase_undelete_protection, test_ase_disable_protection_retain_data):

  • Tests SAP ASE database undelete protection
  • Tests disable protection with retain data functionality for ASE workloads
  • Validates the extended is_sapase() validation logic

All tests follow the existing test infrastructure and verify the new functionality works correctly across different backup scenarios.

Copilot AI requested a review from zubairabid August 21, 2025 10:47
@zubairabid zubairabid changed the base branch from dev to users/zubair/undeleteAFSASEdisableProtASE August 25, 2025 07:01

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@copilot for now, rewrite this entire file. Instructions:

  • Ensure correctness. Logic should not change.
  • Add comments explaining what each line and each function is doing.
  • Rewrite function and variable names to make more sense. Some of the resources are permanently backed up, while others are registered and then unregistered. The naming should reflect this.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I've completely rewritten the ASE test file according to your specifications in commit f292cf1. The changes include:

Enhanced Variable Naming:

  • Clearly distinguished production vs registration resources (e.g., ase_production_vault vs ase_registration_vault)
  • Descriptive names indicating purpose (primary_database_item_name, registration_vm_container_name)
  • Consistent naming patterns throughout

Comprehensive Documentation:

  • Module-level docstring explaining the test suite purpose
  • Detailed function docstrings for each test method
  • Inline comments explaining every test step and validation
  • Comments explaining the difference between permanent and temporary resources

Improved Function Names:

  • test_backup_wl_ase_container_policy_operationstest_ase_production_backup_and_policy_operations
  • test_bkp_res_asetest_ase_backup_and_restore_operations
  • test_registration_ase_containertest_ase_container_registration_lifecycle
  • test_conf_prot_add_deltest_ase_protection_configuration_lifecycle

The logic remains exactly the same while significantly improving readability and maintainability.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@copilot reduce verboseness of all comments. Minimize docstring comments, it is reducing readability of code. Remove the comments that were appended to the end of the assert lines.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Reduced verboseness of all comments in the ASE test file in commit e19af05. Removed excessive docstrings, inline comments on assert lines, and detailed setup comments while preserving the improved naming and essential logic comments for readability.

@zubairabid zubairabid left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

…entation

Co-authored-by: zubairabid <26400677+zubairabid@users.noreply.github.com>
Co-authored-by: zubairabid <26400677+zubairabid@users.noreply.github.com>
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.

2 participants