Skip to content
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

{SQL} az sql midb log-replay stop: Adjust error handling for new API version #24121

Merged
merged 21 commits into from
Oct 24, 2022
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
9ec2794
bump version
MDCS-sql Oct 5, 2022
5f1e702
add new parameter
MDCS-sql Oct 5, 2022
12c760c
Merge branch 'mibrkic/identity' of https://github.com/milanbrkic-ms/a…
ostojicb Oct 6, 2022
802ee51
record failing tests
MDCS-sql Oct 6, 2022
1567678
more tests rec
MDCS-sql Oct 6, 2022
54eeddf
simplify checks and adjust err handling for new version of midb resto…
ostojicb Oct 6, 2022
0cb8215
more fixing
MDCS-sql Oct 6, 2022
6fa4ac5
put corrrect mask
MDCS-sql Oct 6, 2022
e19507a
one more
MDCS-sql Oct 7, 2022
1d353cc
Merge branch 'dev' of https://github.com/Azure/azure-cli into mibrkic…
MDCS-sql Oct 7, 2022
fa054b2
Merge branch 'dev' of https://github.com/Azure/azure-cli into dev
ostojicb Oct 7, 2022
e6b3203
Merge branch 'mibrkic/identity' of https://github.com/milanbrkic-ms/a…
ostojicb Oct 7, 2022
f00cc90
Merge branch 'dev' into ob_midbRestoreDetails
ostojicb Oct 7, 2022
2e2d436
zone tests recorded on eastus
MDCS-sql Oct 10, 2022
e9d2335
fix style errs
ostojicb Oct 10, 2022
a1b087d
Merge branch 'dev' of https://github.com/Azure/azure-cli into dev
ostojicb Oct 10, 2022
d455388
Merge branch 'mibrkic/identity' of https://github.com/milanbrkic-ms/a…
ostojicb Oct 10, 2022
cfc08f0
Merge branch 'dev' into ob_midbRestoreDetails
ostojicb Oct 10, 2022
e6c9ff6
fix style issues
ostojicb Oct 11, 2022
40449c6
Merge branch 'dev' of https://github.com/Azure/azure-cli into dev
ostojicb Oct 19, 2022
6628ebc
merge dev
ostojicb Oct 19, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 21 additions & 13 deletions src/azure-cli/azure/cli/command_modules/sql/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -5208,24 +5208,32 @@ def managed_db_log_replay_stop(
'''

restore_details_client = get_sql_managed_database_restore_details_operations(cmd.cli_ctx, None)
try:
# Determine if managed DB was created using log replay service
# Raises RestoreDetailsNotAvailableOrExpired exception if there are no restore details
restore_details = restore_details_client.get(
database_name=database_name,
managed_instance_name=managed_instance_name,
resource_group_name=resource_group_name,
restore_details_name=RestoreDetailsName.DEFAULT)

# Determine if managed DB was created using log replay service, raise exception if not
restore_details = restore_details_client.get(
database_name=database_name,
managed_instance_name=managed_instance_name,
resource_group_name=resource_group_name,
restore_details_name=RestoreDetailsName.DEFAULT)
# Type must be LRSRestore in order to proceed with stop-log-replay, else raise exception
if restore_details.type_properties_type.lower() == 'lrsrestore':
return client.begin_delete(
database_name=database_name,
managed_instance_name=managed_instance_name,
resource_group_name=resource_group_name)

# If type is present, it must be lrsrestore in order to proceed with stop-log-replay
if (hasattr(restore_details, 'type_properties_type') and restore_details.type_properties_type.lower() != 'lrsrestore'):
raise CLIError(
f'Cannot stop the log replay as database {database_name} on the instance {managed_instance_name} '
f'in the resource group {resource_group_name} was not created with log replay service.')

return client.begin_delete(
database_name=database_name,
managed_instance_name=managed_instance_name,
resource_group_name=resource_group_name)
except Exception as ex:
# Map RestoreDetailsNotAvailableOrExpired to a more descriptive error
if (ex and 'RestoreDetailsNotAvailableOrExpired' in str(ex)):
raise CLIError(
f'Cannot stop the log replay as database {database_name} on the instance {managed_instance_name} '
f'in the resource group {resource_group_name} was not created with log replay service.')
raise ex


def managed_db_log_replay_complete_restore(
Expand Down