-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Conversation
@@ -2131,6 +2131,10 @@ def _configure_security_policy_storage_params(arg_ctx): | |||
############################################### | |||
# sql managed db # | |||
############################################### | |||
class ContainerIdentityType(Enum): |
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.
branched out of here #24105 to avoid conflicts, since we're both working with new sql sdk, similar commands
az sql midb log-replay stop
: adjust error handling for new API versionaz sql midb log-replay stop
: Adjust error handling for new API version
SQL |
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) | ||
|
||
# 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) | ||
# Type must be LRSRestore in order to proceed with stop-log-replay | ||
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) | ||
else: | ||
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.') | ||
except Exception as ex: | ||
# | ||
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 |
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.
this is the actual diff (once we merge #24105)
/azp run |
Azure Pipelines successfully started running 2 pipeline(s). |
can we proceed with merging @wangzelin007 @evelyn-ys |
az sql midb log-replay stop
: Adjust error handling for new API versionaz sql midb log-replay stop
: Adjust error handling for new API version
…I version (Azure#24121) * bump version * add new parameter * record failing tests * more tests rec * simplify checks and adjust err handling for new version of midb restore details API * more fixing * put corrrect mask * one more * zone tests recorded on eastus * fix style errs * fix style issues Co-authored-by: Milan Brkic <[email protected]>
Related command
az sql log-replay stop
az sql log-replay show
Description
We've got new version of managed database restore details API which we use to determine whether
log-replay stop
cmd should drop the db or not (#22939).As the API now returns an error for dbs with no restore details, we'd ideally want to map it to a more meaningful exception in the context of this command.
Also new properties in API response can be used to simplify checking logic.
az sql log-replay show
is a simple pass-through command, so new fields from API response are automatically passed back to the userTesting Guide
History Notes
[Component Name 1] BREAKING CHANGE:
az command a
: Make some customer-facing breaking change[Component Name 2]
az command b
: Add some customer-facing featureThis checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.