Skip to content

Commit d60e9d2

Browse files
[Container] az container create: Remove default values for container group to support standby pool reuse scenario (#31824)
1 parent 581cb90 commit d60e9d2

File tree

4 files changed

+796
-4
lines changed

4 files changed

+796
-4
lines changed

src/azure-cli/azure/cli/command_modules/container/custom.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def delete_container(client, resource_group_name, name, **kwargs):
7171
return client.begin_delete(resource_group_name, name)
7272

7373

74-
# pylint: disable=too-many-statements
74+
# pylint: disable=too-many-statements,too-many-branches
7575
def create_container(cmd,
7676
resource_group_name,
7777
name=None,
@@ -142,8 +142,13 @@ def create_container(cmd,
142142

143143
standby_pool_profile_reference = _create_standby_pool_profile_reference(standby_pool_profile_id=standby_pool_profile_id, fail_container_group_create_on_reuse_failure=fail_container_group_create_on_reuse_failure)
144144

145-
ports = ports or [80]
146-
protocol = protocol or ContainerGroupNetworkProtocol.tcp
145+
# No default values need to be set for the standbypool reuse scenario
146+
if standby_pool_profile_id is not None:
147+
vnet_address_prefix = None
148+
subnet_address_prefix = None
149+
else:
150+
ports = ports or [80]
151+
protocol = protocol or ContainerGroupNetworkProtocol.tcp
147152

148153
config_map = _create_config_map(config_map)
149154

@@ -221,7 +226,9 @@ def create_container(cmd,
221226
subnet_id = _get_subnet_id(cmd, location, resource_group_name, vnet, vnet_address_prefix, subnet, subnet_address_prefix)
222227
cgroup_subnet = [ContainerGroupSubnetId(id=subnet_id)]
223228

224-
cgroup_ip_address = _create_ip_address(ip_address, ports, protocol, dns_name_label, subnet_id)
229+
cgroup_ip_address = None
230+
if standby_pool_profile_id is None:
231+
cgroup_ip_address = _create_ip_address(ip_address, ports, protocol, dns_name_label, subnet_id)
225232

226233
# Setup zones, validation done in control plane so check is not needed here
227234
zones = None

0 commit comments

Comments
 (0)