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

support ingress read timeout for azure spring app #4853

Merged
merged 8 commits into from
May 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions src/spring/HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
Release History
===============
1.1.0
---
* New command `az spring create` has new argument "--ingress-read-timeout" to set ingress read timeout when create Azure Spring App.
* New command `az spring update` has new argument "--ingress-read-timeout" to update ingress read timeout for Azure Spring App.

1.0.0
---
* Initialize extension "Spring" to manage Azure Spring Apps resources.
7 changes: 7 additions & 0 deletions src/spring/azext_spring/_client_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
from .vendored_sdks.appplatform.v2022_03_01_preview import (
AppPlatformManagementClient as AppPlatformManagementClient_20220301preview
)
from .vendored_sdks.appplatform.v2022_05_01_preview import (
AppPlatformManagementClient as AppPlatformManagementClient_20220501preview
)
from .vendored_sdks.appplatform.v2021_06_01_preview import (
AppPlatformManagementClient as AppPlatformManagementClient_20210601preview
)
Expand All @@ -22,6 +25,10 @@
)


def cf_spring_20220501preview(cli_ctx, *_):
return get_mgmt_service_client(cli_ctx, AppPlatformManagementClient_20220501preview)


def cf_spring_20220301preview(cli_ctx, *_):
return get_mgmt_service_client(cli_ctx, AppPlatformManagementClient_20220301preview)

Expand Down
10 changes: 9 additions & 1 deletion src/spring/azext_spring/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
validate_vnet, validate_vnet_required_parameters, validate_node_resource_group,
validate_tracing_parameters_asc_create, validate_tracing_parameters_asc_update,
validate_app_insights_parameters, validate_instance_count, validate_java_agent_parameters,
validate_jar)
validate_ingress_timeout, validate_jar)
from ._validators_enterprise import (only_support_enterprise, validate_builder_resource, validate_builder_create,
validate_builder_update, validate_build_pool_size,
validate_git_uri, validate_acs_patterns, validate_config_file_patterns,
Expand Down Expand Up @@ -107,6 +107,10 @@ def load_arguments(self, _):
help="Create your Azure Spring Apps service in an Azure availability zone or not, "
"this could only be supported in several regions at the moment.",
default=False, is_preview=True)
c.argument('ingress_read_timeout',
type=int,
help='Ingress read timeout value in seconds. Default 300, Minimum is 1, maximum is 1800.',
validator=validate_ingress_timeout)
c.argument('build_pool_size',
arg_type=get_enum_type(['S1', 'S2', 'S3', 'S4', 'S5']),
validator=validate_build_pool_size,
Expand Down Expand Up @@ -148,6 +152,10 @@ def load_arguments(self, _):

with self.argument_context('spring update') as c:
c.argument('sku', arg_type=sku_type, validator=normalize_sku)
c.argument('ingress_read_timeout',
type=int,
help='Ingress read timeout value in seconds. Minimum is 1, maximum is 1800.',
validator=validate_ingress_timeout)
c.argument('app_insights_key',
help="Connection string (recommended) or Instrumentation key of the existing Application Insights.",
validator=validate_tracing_parameters_asc_update,
Expand Down
6 changes: 6 additions & 0 deletions src/spring/azext_spring/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,12 @@ def validate_jvm_options(namespace):
namespace.jvm_options = namespace.jvm_options.strip('\'')


def validate_ingress_timeout(namespace):
if namespace.ingress_read_timeout is not None and (namespace.ingress_read_timeout < 1 or
namespace.ingress_read_timeout > 1800):
raise InvalidArgumentValueError("Invalid value: Ingress read timeout must be in the range [1,1800].")


def validate_tracing_parameters_asc_create(namespace):
if (namespace.app_insights or namespace.app_insights_key or namespace.sampling_rate is not None) \
and namespace.disable_app_insights:
Expand Down
7 changes: 4 additions & 3 deletions src/spring/azext_spring/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
from azure.cli.core.commands import CliCommandType
from azext_spring._utils import handle_asc_exception

from ._client_factory import (cf_spring_20220301preview,
from ._client_factory import (cf_spring_20220501preview,
cf_spring_20220301preview,
cf_spring_20220101preview,
cf_spring_20201101preview,
cf_config_servers)
Expand All @@ -29,7 +30,7 @@
def load_command_table(self, _):
spring_routing_util = CliCommandType(
operations_tmpl='azext_spring.spring_instance#{}',
client_factory=cf_spring_20220101preview
client_factory=cf_spring_20220501preview
)

app_command = CliCommandType(
Expand Down Expand Up @@ -91,7 +92,7 @@ def load_command_table(self, _):
exception_handler=handle_asc_exception) as g:
g.custom_command('create', 'spring_create', supports_no_wait=True)

with self.command_group('spring', client_factory=cf_spring_20220101preview,
with self.command_group('spring', client_factory=cf_spring_20220501preview,
exception_handler=handle_asc_exception) as g:
g.custom_command('update', 'spring_update', supports_no_wait=True)
g.custom_command('delete', 'spring_delete', supports_no_wait=True)
Expand Down
19 changes: 15 additions & 4 deletions src/spring/azext_spring/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from .vendored_sdks.appplatform.v2020_07_01 import models
from .vendored_sdks.appplatform.v2020_11_01_preview import models as models_20201101preview
from .vendored_sdks.appplatform.v2022_01_01_preview import models as models_20220101preview
from .vendored_sdks.appplatform.v2022_05_01_preview import models as models_20220501preview
from .vendored_sdks.appplatform.v2020_07_01.models import _app_platform_management_client_enums as AppPlatformEnums
from .vendored_sdks.appplatform.v2020_11_01_preview import (
AppPlatformManagementClient as AppPlatformManagementClient_20201101preview
Expand Down Expand Up @@ -85,13 +86,14 @@ def _update_application_insights_asc_create(cmd,


def spring_update(cmd, client, resource_group, name, app_insights_key=None, app_insights=None,
disable_app_insights=None, sku=None, tags=None, build_pool_size=None, no_wait=False):
disable_app_insights=None, sku=None, tags=None, build_pool_size=None,
ingress_read_timeout=None, no_wait=False):
"""
TODO (jiec) app_insights_key, app_insights and disable_app_insights are marked as deprecated.
Will be decommissioned in future releases.
:param app_insights_key: Connection string or Instrumentation key
"""
updated_resource = models_20220101preview.ServiceResource()
updated_resource = models_20220501preview.ServiceResource()
update_service_tags = False
update_service_sku = False

Expand All @@ -102,7 +104,7 @@ def spring_update(cmd, client, resource_group, name, app_insights_key=None, app_

resource = client.services.get(resource_group, name)
location = resource.location
updated_resource_properties = models_20220101preview.ClusterResourceProperties()
updated_resource_properties = models_20220501preview.ClusterResourceProperties()
updated_resource_properties.zone_redundant = None

_update_application_insights_asc_update(cmd, resource_group, name, location,
Expand All @@ -111,19 +113,28 @@ def spring_update(cmd, client, resource_group, name, app_insights_key=None, app_
_update_default_build_agent_pool(
cmd, client, resource_group, name, build_pool_size)

_update_ingress_config(updated_resource_properties, ingress_read_timeout)

# update service tags
if tags is not None:
updated_resource.tags = tags
update_service_tags = True

if update_service_tags is False and update_service_sku is False:
if update_service_tags is False and update_service_sku is False and (ingress_read_timeout is None):
return resource

updated_resource.properties = updated_resource_properties
return sdk_no_wait(no_wait, client.services.begin_update,
resource_group_name=resource_group, service_name=name, resource=updated_resource)


def _update_ingress_config(updated_resource_properties, ingress_read_timeout=None):
if ingress_read_timeout:
ingress_configuration = models_20220501preview.IngressConfig(read_timeout_in_seconds=ingress_read_timeout)
updated_resource_properties.network_profile = models_20220501preview.NetworkProfile(
ingress_config=ingress_configuration)


def _update_application_insights_asc_update(cmd, resource_group, name, location,
app_insights_key, app_insights, disable_app_insights, no_wait):
"""If app_insights_key, app_insights and disable_app_insights are all None, do nothing here
Expand Down
11 changes: 11 additions & 0 deletions src/spring/azext_spring/spring_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# pylint: disable=unused-argument, logging-format-interpolation, protected-access, wrong-import-order, too-many-lines
from ._utils import (wait_till_end, _get_rg_location)
from .vendored_sdks.appplatform.v2022_01_01_preview import models
from .vendored_sdks.appplatform.v2022_05_01_preview import models
from knack.log import get_logger
from .custom import (_warn_enable_java_agent, _update_application_insights_asc_create)
from ._build_service import _update_default_build_agent_pool
Expand Down Expand Up @@ -56,6 +57,7 @@ def create_service(self,
zone_redundant=False,
sku=None,
tags=None,
ingress_read_timeout=None,
**_):
properties = models.ClusterResourceProperties(
zone_redundant=zone_redundant
Expand All @@ -70,6 +72,13 @@ def create_service(self,
service_runtime_network_resource_group=service_runtime_network_resource_group
)

if ingress_read_timeout:
ingress_configuration = models.IngressConfig(read_timeout_in_seconds=ingress_read_timeout)
if properties.network_profile:
properties.network_profile.ingress_config = ingress_configuration
else:
properties.network_profile = models.NetworkProfile(ingress_config=ingress_configuration)

resource = models.ServiceResource(location=self.location, sku=sku, properties=properties, tags=tags)
poller = self.client.services.begin_create_or_update(
self.resource_group, self.name, resource)
Expand Down Expand Up @@ -127,6 +136,7 @@ def spring_create(cmd, client, resource_group, name,
gateway_instance_count=None,
enable_api_portal=False,
api_portal_instance_count=None,
ingress_read_timeout=None,
no_wait=False):
"""
Because Standard/Basic tier vs. Enterprise tier creation are very different. Here routes the command to different
Expand All @@ -144,6 +154,7 @@ def spring_create(cmd, client, resource_group, name,
'sampling_rate': sampling_rate,
'disable_app_insights': disable_app_insights,
'enable_java_agent': enable_java_agent,
'ingress_read_timeout': ingress_read_timeout,
'sku': sku,
'tags': tags,
'zone_redundant': zone_redundant,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ interactions:
User-Agent:
- AZURECLI/2.27.1 azsdk-python-mgmt-appplatform/6.1.0 Python/3.9.5 (Windows-10-10.0.19043-SP0)
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli/providers/Microsoft.AppPlatform/Spring/cli-unittest10?api-version=2022-01-01-preview
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli/providers/Microsoft.AppPlatform/Spring/cli-unittest10?api-version=2022-05-01-preview
response:
body:
string: '{"properties":{"provisioningState":"Succeeded","version":3,"serviceId":"e2c3dcb4663b49d891a84af0d6fa556f","networkProfile":{"outboundIPs":{"publicIPs":["52.186.105.180"]}}},"type":"Microsoft.AppPlatform/Spring","sku":{"name":"B0","tier":"Basic"},"location":"eastus","tags":{},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli/providers/Microsoft.AppPlatform/Spring/cli-unittest10","name":"cli-unittest10"}'
Expand Down Expand Up @@ -272,7 +272,7 @@ interactions:
User-Agent:
- AZURECLI/2.27.1 azsdk-python-mgmt-appplatform/6.1.0 Python/3.9.5 (Windows-10-10.0.19043-SP0)
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli/providers/Microsoft.AppPlatform/Spring/cli-unittest10?api-version=2022-01-01-preview
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli/providers/Microsoft.AppPlatform/Spring/cli-unittest10?api-version=2022-05-01-preview
response:
body:
string: '{"properties":{"provisioningState":"Succeeded","version":3,"serviceId":"e2c3dcb4663b49d891a84af0d6fa556f","networkProfile":{"outboundIPs":{"publicIPs":["52.186.105.180"]}}},"type":"Microsoft.AppPlatform/Spring","sku":{"name":"B0","tier":"Basic"},"location":"eastus","tags":{},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli/providers/Microsoft.AppPlatform/Spring/cli-unittest10","name":"cli-unittest10"}'
Expand Down Expand Up @@ -684,7 +684,7 @@ interactions:
User-Agent:
- AZURECLI/2.27.1 azsdk-python-mgmt-appplatform/6.1.0 Python/3.9.5 (Windows-10-10.0.19043-SP0)
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli/providers/Microsoft.AppPlatform/Spring/cli-unittest10?api-version=2022-01-01-preview
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli/providers/Microsoft.AppPlatform/Spring/cli-unittest10?api-version=2022-05-01-preview
response:
body:
string: '{"properties":{"provisioningState":"Succeeded","version":3,"serviceId":"e2c3dcb4663b49d891a84af0d6fa556f","networkProfile":{"outboundIPs":{"publicIPs":["52.186.105.180"]}}},"type":"Microsoft.AppPlatform/Spring","sku":{"name":"B0","tier":"Basic"},"location":"eastus","tags":{},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli/providers/Microsoft.AppPlatform/Spring/cli-unittest10","name":"cli-unittest10"}'
Expand Down Expand Up @@ -1042,7 +1042,7 @@ interactions:
User-Agent:
- AZURECLI/2.27.1 azsdk-python-mgmt-appplatform/6.1.0 Python/3.9.5 (Windows-10-10.0.19043-SP0)
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli/providers/Microsoft.AppPlatform/Spring/cli-unittest10?api-version=2022-01-01-preview
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli/providers/Microsoft.AppPlatform/Spring/cli-unittest10?api-version=2022-05-01-preview
response:
body:
string: '{"properties":{"provisioningState":"Succeeded","version":3,"serviceId":"e2c3dcb4663b49d891a84af0d6fa556f","networkProfile":{"outboundIPs":{"publicIPs":["52.186.105.180"]}}},"type":"Microsoft.AppPlatform/Spring","sku":{"name":"B0","tier":"Basic"},"location":"eastus","tags":{},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli/providers/Microsoft.AppPlatform/Spring/cli-unittest10","name":"cli-unittest10"}'
Expand Down Expand Up @@ -1454,7 +1454,7 @@ interactions:
User-Agent:
- AZURECLI/2.27.1 azsdk-python-mgmt-appplatform/6.1.0 Python/3.9.5 (Windows-10-10.0.19043-SP0)
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli/providers/Microsoft.AppPlatform/Spring/cli-unittest10?api-version=2022-01-01-preview
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli/providers/Microsoft.AppPlatform/Spring/cli-unittest10?api-version=2022-05-01-preview
response:
body:
string: '{"properties":{"provisioningState":"Succeeded","version":3,"serviceId":"e2c3dcb4663b49d891a84af0d6fa556f","networkProfile":{"outboundIPs":{"publicIPs":["52.186.105.180"]}}},"type":"Microsoft.AppPlatform/Spring","sku":{"name":"B0","tier":"Basic"},"location":"eastus","tags":{},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli/providers/Microsoft.AppPlatform/Spring/cli-unittest10","name":"cli-unittest10"}'
Expand Down Expand Up @@ -1812,7 +1812,7 @@ interactions:
User-Agent:
- AZURECLI/2.27.1 azsdk-python-mgmt-appplatform/6.1.0 Python/3.9.5 (Windows-10-10.0.19043-SP0)
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli/providers/Microsoft.AppPlatform/Spring/cli-unittest10?api-version=2022-01-01-preview
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli/providers/Microsoft.AppPlatform/Spring/cli-unittest10?api-version=2022-05-01-preview
response:
body:
string: '{"properties":{"provisioningState":"Succeeded","version":3,"serviceId":"e2c3dcb4663b49d891a84af0d6fa556f","networkProfile":{"outboundIPs":{"publicIPs":["52.186.105.180"]}}},"type":"Microsoft.AppPlatform/Spring","sku":{"name":"B0","tier":"Basic"},"location":"eastus","tags":{},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli/providers/Microsoft.AppPlatform/Spring/cli-unittest10","name":"cli-unittest10"}'
Expand Down Expand Up @@ -2171,7 +2171,7 @@ interactions:
User-Agent:
- AZURECLI/2.27.1 azsdk-python-mgmt-appplatform/6.1.0 Python/3.9.5 (Windows-10-10.0.19043-SP0)
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli/providers/Microsoft.AppPlatform/Spring/cli-unittest10?api-version=2022-01-01-preview
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli/providers/Microsoft.AppPlatform/Spring/cli-unittest10?api-version=2022-05-01-preview
response:
body:
string: '{"properties":{"provisioningState":"Succeeded","version":3,"serviceId":"e2c3dcb4663b49d891a84af0d6fa556f","networkProfile":{"outboundIPs":{"publicIPs":["52.186.105.180"]}}},"type":"Microsoft.AppPlatform/Spring","sku":{"name":"B0","tier":"Basic"},"location":"eastus","tags":{},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli/providers/Microsoft.AppPlatform/Spring/cli-unittest10","name":"cli-unittest10"}'
Expand Down Expand Up @@ -2529,7 +2529,7 @@ interactions:
User-Agent:
- AZURECLI/2.27.1 azsdk-python-mgmt-appplatform/6.1.0 Python/3.9.5 (Windows-10-10.0.19043-SP0)
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli/providers/Microsoft.AppPlatform/Spring/cli-unittest10?api-version=2022-01-01-preview
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli/providers/Microsoft.AppPlatform/Spring/cli-unittest10?api-version=2022-05-01-preview
response:
body:
string: '{"properties":{"provisioningState":"Succeeded","version":3,"serviceId":"e2c3dcb4663b49d891a84af0d6fa556f","networkProfile":{"outboundIPs":{"publicIPs":["52.186.105.180"]}}},"type":"Microsoft.AppPlatform/Spring","sku":{"name":"B0","tier":"Basic"},"location":"eastus","tags":{},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli/providers/Microsoft.AppPlatform/Spring/cli-unittest10","name":"cli-unittest10"}'
Expand Down
Loading