-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[AKS Preview] Add backup enablement support via dataprotection extension #9615
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -23,6 +23,21 @@ | |||||
| validate_nat_gateway_idle_timeout, | ||||||
| validate_nat_gateway_managed_outbound_ip_count, | ||||||
| ) | ||||||
|
|
||||||
| # Import backup strategy constants from dataprotection extension | ||||||
| from azure.cli.core.extension.operations import add_extension_to_path | ||||||
| add_extension_to_path("dataprotection") | ||||||
| from azext_dataprotection.manual._consts import ( | ||||||
| CONST_AKS_BACKUP_STRATEGIES, | ||||||
| CONST_BACKUP_STRATEGY_WEEK, | ||||||
| CONST_BACKUP_STRATEGY_MONTH, | ||||||
| CONST_BACKUP_STRATEGY_IMMUTABLE, | ||||||
| CONST_BACKUP_STRATEGY_DISASTER_RECOVERY, | ||||||
| CONST_BACKUP_STRATEGY_CUSTOM, | ||||||
| ) | ||||||
|
|
||||||
| backup_presets = CONST_AKS_BACKUP_STRATEGIES | ||||||
|
|
||||||
| from azure.cli.core.commands.parameters import ( | ||||||
| edge_zone_type, | ||||||
| file_type, | ||||||
|
|
@@ -163,6 +178,7 @@ | |||||
| CONST_UPGRADE_STRATEGY_ROLLING, | ||||||
| CONST_UPGRADE_STRATEGY_BLUE_GREEN | ||||||
| ) | ||||||
| from azure.cli.core.commands.validators import validate_file_or_dict | ||||||
|
|
||||||
| from azext_aks_preview._validators import ( | ||||||
| validate_acr, | ||||||
|
|
@@ -1740,6 +1756,13 @@ def load_arguments(self, _): | |||||
| 'by that action.' | ||||||
| ) | ||||||
| ) | ||||||
| c.argument("enable_backup", help="Enable backup for the cluster", is_preview=True, action="store_true") | ||||||
| c.argument("backup_strategy", arg_type=get_enum_type(backup_presets), help="Backup strategy for the cluster. Defaults to Week.", is_preview=True) | ||||||
| c.argument("backup_configuration_file", type=validate_file_or_dict, | ||||||
| options_list=['--backup-configuration-file', '-f'], | ||||||
| help="Path to backup configuration file (JSON) or inline JSON string.", is_preview=True) | ||||||
| # In update scenario, use emtpy str as default. | ||||||
|
||||||
| # In update scenario, use emtpy str as default. | |
| # In update scenario, use empty str as default. |
Copilot
AI
Feb 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Poor code organization: The backup-related parameters (lines 1759-1763) are inserted between unrelated parameters, with a comment on line 1764 that applies to the ssh_access parameter on line 1765, not to the backup parameters. This makes the code harder to read and maintain. Consider grouping related parameters together and ensuring comments are adjacent to the parameters they describe.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -1394,6 +1394,10 @@ def aks_update( | |||||
| # IMDS restriction | ||||||
| enable_imds_restriction=False, | ||||||
| disable_imds_restriction=False, | ||||||
| # Backup | ||||||
| enable_backup=False, | ||||||
| backup_strategy=None, | ||||||
| backup_configuration_parameters=None, | ||||||
|
||||||
| backup_configuration_parameters=None, | |
| backup_configuration_file=None, |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |||||
| # pylint: disable=too-many-lines | ||||||
| import copy | ||||||
| import datetime | ||||||
| import json | ||||||
|
||||||
| import json |
Copilot
AI
Feb 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary type conversion: The cluster_resource_id is already a string (f-string concatenation), so wrapping it with str() on line 7407 is redundant. Remove the str() call for cleaner code.
| dataprotection_enable_backup_helper(self.cmd, str(cluster_resource_id), backup_strategy, backup_configuration_file) | |
| dataprotection_enable_backup_helper(self.cmd, cluster_resource_id, backup_strategy, backup_configuration_file) |
Copilot
AI
Feb 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing test coverage: The new set_up_backup method lacks test coverage. The codebase has comprehensive tests for similar set_up methods in managed_cluster_decorator.py (see test_managed_cluster_decorator.py). Add unit tests that verify the method's behavior including successful backup enablement, handling missing dataprotection extension, and correct parameter passing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The dataprotection extension is imported at module load time (lines 28-37), which means the extension must be installed even when users are not using the backup functionality. This will cause import errors for users who don't have the dataprotection extension installed. Consider wrapping these imports in a try-except block similar to how it's done in managed_cluster_decorator.py (lines 7387-7395), or move the imports into a function that's only called when backup functionality is needed. See _helpers.py:414-427 for the pattern used with k8s-extension.