def upgrade( # pylint: disable=too-many-arguments,too-many-locals,missing-docstring client, application_id, application_version, parameters, mode="UnmonitoredAuto", replica_set_check_timeout=None, force_restart=None, failure_action=None, health_check_wait_duration="0", health_check_stable_duration="PT0H2M0S", health_check_retry_timeout="PT0H10M0S", upgrade_timeout="P10675199DT02H48M05.4775807S", upgrade_domain_timeout="P10675199DT02H48M05.4775807S", warning_as_error=False, max_unhealthy_apps=0, default_service_health_policy=None, service_health_policy=None, timeout=60): from azure.servicefabric.models import (ApplicationUpgradeDescription, MonitoringPolicyDescription, ApplicationHealthPolicy) from sfctl.custom_health import (parse_service_health_policy_map, parse_service_health_policy) monitoring_policy = MonitoringPolicyDescription( failure_action=failure_action, health_check_wait_duration_in_milliseconds=health_check_wait_duration, health_check_stable_duration_in_milliseconds=health_check_stable_duration, health_check_retry_timeout_in_milliseconds=health_check_retry_timeout, upgrade_timeout_in_milliseconds=upgrade_timeout, upgrade_domain_timeout_in_milliseconds=upgrade_domain_timeout ) # Must always have empty list app_params = parse_app_params(parameters) if app_params is None: app_params = [] def_shp = parse_service_health_policy(default_service_health_policy) map_shp = parse_service_health_policy_map(service_health_policy) app_health_policy = ApplicationHealthPolicy( consider_warning_as_error=warning_as_error, max_percent_unhealthy_deployed_applications=max_unhealthy_apps, default_service_type_health_policy=def_shp, service_type_health_policy_map=map_shp) desc = ApplicationUpgradeDescription( name='fabric:/' + application_id, target_application_type_version=application_version, parameters=app_params, upgrade_kind='Rolling', rolling_upgrade_mode=mode, upgrade_replica_set_check_timeout_in_seconds=replica_set_check_timeout, force_restart=force_restart, monitoring_policy=monitoring_policy, application_health_policy=app_health_policy) client.start_application_upgrade(application_id, desc, timeout)
def upgrade( # pylint: disable=too-many-arguments,too-many-locals,missing-docstring client, application_name, application_version, parameters, mode="UnmonitoredAuto", replica_set_check_timeout=None, force_restart=None, failure_action=None, health_check_wait_duration="0", health_check_stable_duration="PT0H2M0S", health_check_retry_timeout="PT0H10M0S", upgrade_timeout="P10675199DT02H48M05.4775807S", upgrade_domain_timeout="P10675199DT02H48M05.4775807S", warning_as_error=False, max_unhealthy_apps=0, default_service_health_policy=None, service_health_policy=None, timeout=60): from azure.servicefabric.models.application_upgrade_description import ( ApplicationUpgradeDescription) from azure.servicefabric.models.monitoring_policy_description import ( MonitoringPolicyDescription) from azure.servicefabric.models.application_health_policy import ( ApplicationHealthPolicy) from sfctl.custom_health import (parse_service_health_policy_map, parse_service_health_policy) monitoring_policy = MonitoringPolicyDescription( failure_action, health_check_wait_duration, health_check_stable_duration, health_check_retry_timeout, upgrade_timeout, upgrade_domain_timeout) # Must always have empty list app_params = parse_app_params(parameters) if app_params is None: app_params = [] def_shp = parse_service_health_policy(default_service_health_policy) map_shp = parse_service_health_policy_map(service_health_policy) app_health_policy = ApplicationHealthPolicy(warning_as_error, max_unhealthy_apps, def_shp, map_shp) desc = ApplicationUpgradeDescription(application_name, application_version, app_params, "Rolling", mode, replica_set_check_timeout, force_restart, monitoring_policy, app_health_policy) client.start_application_upgrade(application_name, desc, timeout)
def create_app_health_policy(warning_as_error, unhealthy_app, default_svc_health_map, svc_type_health_map): """Create an application health policy description""" from sfctl.custom_health import (parse_service_health_policy, parse_service_health_policy_map) from azure.servicefabric.models import ApplicationHealthPolicy default_svc_type_policy = parse_service_health_policy( default_svc_health_map) svc_type_policy = parse_service_health_policy_map(svc_type_health_map) return ApplicationHealthPolicy( consider_warning_as_error=warning_as_error, max_percent_unhealthy_deployed_applications=unhealthy_app, default_service_type_health_policy=default_svc_type_policy, service_type_health_policy_map=svc_type_policy)
def test_parse_single_svc_health_policy(self): """Parse single health policy item""" from azure.servicefabric.models import ServiceTypeHealthPolicy res = sf_c.parse_service_health_policy({ 'max_percent_unhealthy_partitions_per_service': 10, 'max_percent_unhealthy_replicas_per_partition': 20, 'max_percent_unhealthy_services': 25 }) self.assertIsInstance(res, ServiceTypeHealthPolicy) self.assertEqual(res.max_percent_unhealthy_partitions_per_service, 10) self.assertEqual(res.max_percent_unhealthy_replicas_per_partition, 20) self.assertEqual(res.max_percent_unhealthy_services, 25)
def upgrade( # pylint: disable=too-many-arguments,too-many-locals client, app_id, app_version, parameters, mode="UnmonitoredAuto", replica_set_check_timeout=None, force_restart=None, failure_action=None, health_check_wait_duration="0", health_check_stable_duration="PT0H2M0S", health_check_retry_timeout="PT0H10M0S", upgrade_timeout="P10675199DT02H48M05.4775807S", upgrade_domain_timeout="P10675199DT02H48M05.4775807S", warning_as_error=False, max_unhealthy_apps=0, default_service_health_policy=None, service_health_policy=None, timeout=60): """ Starts upgrading an application in the Service Fabric cluster. Validates the supplied application upgrade parameters and starts upgrading the application if the parameters are valid. Please note that upgrade description replaces the existing application description. This means that if the parameters are not specified, the existing parameters on the applications will be overwritten with the empty parameters list. This would results in application using the default value of the parameters from the application manifest. :param str app_id: The identity of the application. This is typically the full name of the application without the 'fabric:' URI scheme. :param str app_version: The target application type version (found in the application manifest) for the application upgrade. :param str parameters: A JSON encoded list of application parameter overrides to be applied when upgrading the application. :param str mode: The mode used to monitor health during a rolling upgrade. :param int replica_set_check_timeout: The maximum amount of time to block processing of an upgrade domain and prevent loss of availability when there are unexpected issues. Measured in seconds. :param bool force_restart: Forcefully restart processes during upgrade even when the code version has not changed. :param str failure_action: The action to perform when a Monitored upgrade encounters monitoring policy or health policy violations. :param str health_check_wait_duration: The amount of time to wait after completing an upgrade domain before applying health policies. Measured in milliseconds. :param str health_check_stable_duration: The amount of time that the application or cluster must remain healthy before the upgrade proceeds to the next upgrade domain. Measured in milliseconds. :param str health_check_retry_timeout: The amount of time to retry health evaluations when the application or cluster is unhealthy before the failure action is executed. Measured in milliseconds. :param str upgrade_timeout: The amount of time the overall upgrade has to complete before FailureAction is executed. Measured in milliseconds. :param str upgrade_domain_timeout: The amount of time each upgrade domain has to complete before FailureAction is executed. Measured in milliseconds. :param bool warning_as_error: Treat health evaluation warnings with the same severity as errors. :param int max_unhealthy_apps: The maximum allowed percentage of unhealthy deployed applications. Represented as a number between 0 and 100. :param str default_service_health_policy: JSON encoded specification of the health policy used by default to evaluate the health of a service type. :param str service_health_policy: JSON encoded map with service type health policy per service type name. The map is empty be default. """ from azure.servicefabric.models.application_upgrade_description import ( ApplicationUpgradeDescription) from azure.servicefabric.models.monitoring_policy_description import ( MonitoringPolicyDescription) from azure.servicefabric.models.application_health_policy import ( ApplicationHealthPolicy) from sfctl.custom_health import (parse_service_health_policy_map, parse_service_health_policy) monitoring_policy = MonitoringPolicyDescription( failure_action, health_check_wait_duration, health_check_stable_duration, health_check_retry_timeout, upgrade_timeout, upgrade_domain_timeout) # Must always have empty list app_params = parse_app_params(parameters) if app_params is None: app_params = [] def_shp = parse_service_health_policy(default_service_health_policy) map_shp = parse_service_health_policy_map(service_health_policy) app_health_policy = ApplicationHealthPolicy(warning_as_error, max_unhealthy_apps, def_shp, map_shp) desc = ApplicationUpgradeDescription(app_id, app_version, app_params, "Rolling", mode, replica_set_check_timeout, force_restart, monitoring_policy, app_health_policy) client.start_application_upgrade(app_id, desc, timeout)
def parse_none_svc_health_policy_test(self): """Parsing None service health policy returns None""" res = sf_c.parse_service_health_policy(None) self.assertIs(res, None)