From 2858dffecb93a47f949fdec63e2437138f2f1fb4 Mon Sep 17 00:00:00 2001 From: Christina Kang Date: Fri, 27 Sep 2019 16:12:11 -0700 Subject: [PATCH 1/3] add min instance for stateless service --- src/sfctl/custom_service.py | 68 ++++++++++++++++++++++++++++++++----- 1 file changed, 60 insertions(+), 8 deletions(-) diff --git a/src/sfctl/custom_service.py b/src/sfctl/custom_service.py index 356e6929..0d086c75 100644 --- a/src/sfctl/custom_service.py +++ b/src/sfctl/custom_service.py @@ -156,7 +156,8 @@ def service_update_flags( # pylint: disable=too-many-arguments def validate_service_create_params(stateful, stateless, singleton_scheme, # pylint: disable=too-many-arguments int_scheme, named_scheme, instance_count, - target_rep_set_size, min_rep_set_size): + target_rep_set_size, min_rep_set_size, + min_instance_count, min_instance_percentage): """Validate service creation arguments""" if sum([stateful, stateless]) != 1: raise CLIError( @@ -177,6 +178,8 @@ def validate_service_create_params(stateful, stateless, singleton_scheme, # pyl raise CLIError( 'Cannot specify replica set sizes for stateless services' ) + if stateful and (min_instance_count is not None or min_instance_percentage is not None): + raise CLIError('Cannot specify min instance count or min instance percentage for stateful services') def parse_partition_policy(named_scheme, named_scheme_list, int_scheme, # pylint: disable=too-many-arguments @@ -321,7 +324,8 @@ def create( # pylint: disable=too-many-arguments, too-many-locals target_replica_set_size=None, min_replica_set_size=None, replica_restart_wait=None, quorum_loss_wait=None, stand_by_replica_keep=None, no_persisted_state=False, - instance_count=None, timeout=60, scaling_policies=None): + instance_count=None, timeout=60, scaling_policies=None, + min_instance_count=None, min_instance_percentage=None): """ Creates the specified Service Fabric service. :param str app_id: The identity of the application. This is @@ -392,13 +396,33 @@ def create( # pylint: disable=too-many-arguments, too-many-locals :param int instance_count: The instance count. This applies to stateless services only. :param str scaling_policies: JSON encoded list of scaling policies for this service. + :param int min_instance_count: Stateless service only. + MinInstanceCount is the minimum number of + instances that must be up to meet the EnsureAvailability safety check + during operations like upgrade or deactivate node. + The actual number that is used is max( MinInstanceCount, ceil( + MinInstancePercentage/100.0 * InstanceCount) ). + Note, if InstanceCount is set to -1, during MinInstanceCount computation + -1 is first converted into the number of nodes on which the instances are + allowed to be placed according to the placement constraints on the + service. + :param int min_instance_percentage: Stateless service only. + MinInstancePercentage is the minimum + percentage of InstanceCount that must be up to meet the EnsureAvailability + safety check during operations like upgrade or deactivate node. + The actual number that is used is max( MinInstanceCount, ceil( + MinInstancePercentage/100.0 * InstanceCount) ). + Note, if InstanceCount is set to -1, during MinInstancePercentage + computation, -1 is first converted into the number of nodes on which the + instances are allowed to be placed according to the placement constraints + on the service. """ from azure.servicefabric.models import StatelessServiceDescription, StatefulServiceDescription validate_service_create_params(stateful, stateless, singleton_scheme, int_scheme, named_scheme, instance_count, target_replica_set_size, - min_replica_set_size) + min_replica_set_size, min_instance_count, min_instance_percentage) partition_desc = parse_partition_policy(named_scheme, named_scheme_list, int_scheme, int_scheme_low, int_scheme_high, int_scheme_count, @@ -425,7 +449,9 @@ def create( # pylint: disable=too-many-arguments, too-many-locals is_default_move_cost_specified=bool(move_cost), service_package_activation_mode=activation_mode, service_dns_name=dns_name, - scaling_policies=scaling_policy_description) + scaling_policies=scaling_policy_description, + min_instance_count=min_instance_count, + min_instance_percentage=min_instance_percentage) if stateful: flags = stateful_flags(replica_restart_wait, quorum_loss_wait, @@ -459,7 +485,7 @@ def create( # pylint: disable=too-many-arguments, too-many-locals def validate_update_service_params(stateless, stateful, target_rep_set_size, # pylint: disable=too-many-arguments min_rep_set_size, rep_restart_wait, quorum_loss_wait, stand_by_replica_keep, - instance_count): + instance_count, min_instance_count, min_instance_percentage): """Validate update service parameters""" if sum([stateless, stateful]) != 1: @@ -486,13 +512,17 @@ def validate_update_service_params(stateless, stateful, target_rep_set_size, # raise CLIError('Cannot specify an instance count for a stateful ' 'service') + if min_instance_count is not None or min_instance_percentage is not None: + raise CLIError('Cannot specify min instance count or min instance percentage for stateful services') + def update(client, service_id, stateless=False, stateful=False, # pylint: disable=too-many-locals,too-many-arguments constraints=None, correlation=None, correlated_service=None, load_metrics=None, placement_policy_list=None, move_cost=None, instance_count=None, target_replica_set_size=None, min_replica_set_size=None, replica_restart_wait=None, - quorum_loss_wait=None, stand_by_replica_keep=None, timeout=60, scaling_policies=None): + quorum_loss_wait=None, stand_by_replica_keep=None, timeout=60, scaling_policies=None, + min_instance_count=None, min_instance_percentage=None): """ Updates the specified service using the given update description. :param str service_id: The identity of the service. This is typically the @@ -537,6 +567,26 @@ def update(client, service_id, stateless=False, stateful=False, # pylint: disab which StandBy replicas will be maintained before being removed. This applies to stateful services only. :param str scaling_policies: JSON encoded list of scaling policies for this service. + :param int min_instance_count: Stateless service only. + MinInstanceCount is the minimum number of + instances that must be up to meet the EnsureAvailability safety check + during operations like upgrade or deactivate node. + The actual number that is used is max( MinInstanceCount, ceil( + MinInstancePercentage/100.0 * InstanceCount) ). + Note, if InstanceCount is set to -1, during MinInstanceCount computation + -1 is first converted into the number of nodes on which the instances are + allowed to be placed according to the placement constraints on the + service. + :param int min_instance_percentage: Stateless service only. + MinInstancePercentage is the minimum + percentage of InstanceCount that must be up to meet the EnsureAvailability + safety check during operations like upgrade or deactivate node. + The actual number that is used is max( MinInstanceCount, ceil( + MinInstancePercentage/100.0 * InstanceCount) ). + Note, if InstanceCount is set to -1, during MinInstancePercentage + computation, -1 is first converted into the number of nodes on which the + instances are allowed to be placed according to the placement constraints + on the service. """ from azure.servicefabric.models import (StatefulServiceUpdateDescription, StatelessServiceUpdateDescription) @@ -545,7 +595,7 @@ def update(client, service_id, stateless=False, stateful=False, # pylint: disab target_replica_set_size, min_replica_set_size, replica_restart_wait, quorum_loss_wait, stand_by_replica_keep, - instance_count) + instance_count, min_instance_count, min_instance_percentage) cor_desc = correlation_desc(correlated_service, correlation) metric_desc = parse_load_metrics(load_metrics) @@ -583,7 +633,9 @@ def update(client, service_id, stateless=False, stateful=False, # pylint: disab service_placement_policies=place_desc, default_move_cost=move_cost, scaling_policies=scaling_policy_description, - instance_count=instance_count) + instance_count=instance_count, + min_instance_count=min_instance_count, + min_instance_percentage=min_instance_percentage) client.update_service(service_id, update_desc, timeout) From b9311104140a03159974170fe96b8dc4e38db50e Mon Sep 17 00:00:00 2001 From: Christina Kang Date: Fri, 27 Sep 2019 16:45:00 -0700 Subject: [PATCH 2/3] add release notes --- src/README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/README.rst b/src/README.rst index 3c724629..e978a843 100644 --- a/src/README.rst +++ b/src/README.rst @@ -18,7 +18,7 @@ Change Log Unreleased ---------- -- Placeholder text +- Add min instance count/percentage configurations for stateless service update and create (#201) 8.0.0 ---------- From 4379d43af5dbea62f81dfed1d5b9dd70b039bc96 Mon Sep 17 00:00:00 2001 From: Christina Kang - MSFT Date: Tue, 12 Nov 2019 11:58:38 -0800 Subject: [PATCH 3/3] Update README.rst --- src/README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/README.rst b/src/README.rst index eb3cd123..6bb5af40 100644 --- a/src/README.rst +++ b/src/README.rst @@ -21,7 +21,7 @@ Unreleased - Added configuration overrides node commands. These commands will be available in the Service fabric runtime 7.0 version (#206) - Provide option to compress packages on application upload. By default, the newly generated compressed package is deleted after successful upload. (#191) - Update Create and Update service with new parameter, ServicePlacementTimeLimit (#200) -- Add min instance count/percentage configurations for stateless service update and create (#201) +- Add min instance count/percentage configurations for stateless service update and service create APIs (#201) - Update knack version (#207) 8.0.0