Skip to content

Commit

Permalink
mysql ha validation added
Browse files Browse the repository at this point in the history
  • Loading branch information
DaeunYim committed Jun 24, 2021
1 parent f172ea3 commit 656af4b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
DEFAULT_LOCATION_MySQL, generate_password, parse_maintenance_window, get_mysql_list_skus_info
from .flexible_server_custom_common import user_confirmation, create_firewall_rule
from .flexible_server_virtual_network import prepare_private_network
from .validators import mysql_arguments_validator, validate_server_name, validate_auto_grow_update
from .validators import mysql_arguments_validator, validate_server_name, validate_auto_grow_update, validate_mysql_ha_enabled

logger = get_logger(__name__)
DEFAULT_DB_NAME = 'flexibleserverdb'
Expand Down Expand Up @@ -177,6 +177,7 @@ def flexible_server_update_custom_func(cmd, instance,
assign_identity=False,
replication_role=None,
maintenance_window=None,
ha_enabled=None,
iops=None):
# validator
location = ''.join(instance.location.lower().split())
Expand Down Expand Up @@ -210,6 +211,9 @@ def flexible_server_update_custom_func(cmd, instance,
if backup_retention:
instance.storage_profile.backup_retention_days = backup_retention

if ha_enabled:
validate_mysql_ha_enabled(instance)

if auto_grow:
validate_auto_grow_update(instance, auto_grow)
instance.storage_profile.storage_autogrow = auto_grow
Expand Down Expand Up @@ -249,6 +253,7 @@ def flexible_server_update_custom_func(cmd, instance,
ssl_enforcement=ssl_enforcement,
delegated_subnet_arguments=instance.delegated_subnet_arguments,
tags=tags,
ha_enabled=ha_enabled,
replication_role=replication_role)

if assign_identity:
Expand Down Expand Up @@ -538,7 +543,7 @@ def _determine_iops(storage_gb, iops_info, iops_input, tier, sku_name):
if iops_input and iops_input > free_iops:
iops = min(iops_input, max_supported_iops)

logger.warning("IOPS is set to %d which is either your input or free/maximum IOPS supported for your storage size and SKU.", iops)
logger.warning("IOPS is %d which is either your input or free(maximum) IOPS supported for your storage size and SKU.", iops)
return iops


Expand Down
5 changes: 5 additions & 0 deletions src/azure-cli/azure/cli/command_modules/rdbms/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,3 +315,8 @@ def validate_private_dns_zone(cmd, server_name, private_dns_zone):
postgresql_server_endpoint = cmd.cli_ctx.cloud.suffixes.postgresql_server_endpoint
if private_dns_zone == server_name + postgresql_server_endpoint:
raise ValidationError("private dns zone name cannot be same as the server's fully qualified domain name")


def validate_mysql_ha_enabled(server):
if server.storage_profile.storage_autogrow == "Disabled":
raise ValidationError("You need to enable auto grow first to enable high availability.")

0 comments on commit 656af4b

Please sign in to comment.