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

Check service existence before creation #5141

Merged
merged 10 commits into from
Jul 28, 2022
Merged
Show file tree
Hide file tree
Changes from 7 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
4 changes: 4 additions & 0 deletions src/spring/HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Release History
===============
1.1.5
---
* Add service instance existance check before service creation

1.1.4
---
* Add warning that `az spring app-insights` don't support Enterprise tier.
Expand Down
7 changes: 7 additions & 0 deletions src/spring/azext_spring/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ def _update_application_insights_asc_create(cmd,
monitoring_setting_resource=monitoring_setting_resource)


def _check_spring_instance_existed(cmd, client, resource_group, name, location, **_):
qingc marked this conversation as resolved.
Show resolved Hide resolved
availability_parameters = models.NameAvailabilityParameters(type="Microsoft.AppPlatform/Spring", name=name)
name_availability = client.services.check_name_availability(location, availability_parameters)
if not name_availability.name_available and name_availability.reason == "AlreadyExists":
raise ClientRequestError("Service instance '{}' under resource group '{}' is already existed in region '{}', cannot create again.".format(name, resource_group, location))
qingc marked this conversation as resolved.
Show resolved Hide resolved


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,
enable_log_stream_public_endpoint=None, ingress_read_timeout=None, no_wait=False):
Expand Down
15 changes: 13 additions & 2 deletions src/spring/azext_spring/spring_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +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_05_01_preview import models
from .custom import (_warn_enable_java_agent, _update_application_insights_asc_create)
from .custom import (_warn_enable_java_agent, _update_application_insights_asc_create, _check_spring_instance_existed)
from ._build_service import _update_default_build_agent_pool
from .buildpack_binding import create_default_buildpack_binding_for_application_insights
from ._tanzu_component import (create_application_configuration_service,
Expand Down Expand Up @@ -38,6 +38,12 @@ def create(self, **kwargs):

def before_create(self, **kwargs):
_warn_enable_java_agent(**kwargs)
_check_spring_instance_existed(self.cmd,
self.client,
self.resource_group,
self.name,
self.location,
**kwargs)

def after_create(self, **kwargs):
_update_application_insights_asc_create(self.cmd,
Expand Down Expand Up @@ -95,7 +101,12 @@ def create_service(self,

class EnterpriseSpringCloud(DefaultSpringCloud):
def before_create(self, **_):
pass
_check_spring_instance_existed(self.cmd,
self.client,
self.resource_group,
self.name,
self.location,
**_)

def after_create(self, no_wait=None, **kwargs):
pollers = [
Expand Down

Large diffs are not rendered by default.

496 changes: 274 additions & 222 deletions src/spring/azext_spring/tests/latest/recordings/test_az_asc_create.yaml

Large diffs are not rendered by default.

8,566 changes: 7,496 additions & 1,070 deletions src/spring/azext_spring/tests/latest/recordings/test_create_asc_heavy_cases.yaml

Large diffs are not rendered by default.

Loading