Skip to content
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
9 changes: 9 additions & 0 deletions src/azure-cli/azure/cli/command_modules/acs/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -1635,6 +1635,9 @@
- name: --node-soak-duration
type: int
short-summary: The amount of time (in minutes) to wait after draining a node and before reimaging it and moving on to next node.
- name: --undrainable-node-behavior
type: string
short-summary: Define the behavior for undrainable nodes during upgrade. The value should be "Cordon" or "Schedule". The default value is "Schedule".
- name: --enable-encryption-at-host
type: bool
short-summary: Enable EncryptionAtHost, default value is false.
Expand Down Expand Up @@ -1793,6 +1796,9 @@
- name: --node-soak-duration
type: int
short-summary: The amount of time (in minutes) to wait after draining a node and before reimaging it and moving on to next node.
- name: --undrainable-node-behavior
type: string
short-summary: Define the behavior for undrainable nodes during upgrade. The value should be "Cordon" or "Schedule". The default value is "Schedule".
- name: --node-taints
type: string
short-summary: The node taints for the node pool. You can update the existing node taint of a nodepool or create a new node taint for a nodepool. Pass the empty string `""` to remove all taints.
Expand Down Expand Up @@ -1865,6 +1871,9 @@
- name: --node-soak-duration
type: int
short-summary: The amount of time (in minutes) to wait after draining a node and before reimaging it and moving on to next node.
- name: --undrainable-node-behavior
type: string
short-summary: Define the behavior for undrainable nodes during upgrade. The value should be "Cordon" or "Schedule". The default value is "Schedule".
- name: --snapshot-id
type: string
short-summary: The source snapshot id used to upgrade this nodepool.
Expand Down
3 changes: 3 additions & 0 deletions src/azure-cli/azure/cli/command_modules/acs/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,7 @@ def load_arguments(self, _):
c.argument('max_surge', validator=validate_max_surge)
c.argument('drain_timeout', type=int)
c.argument('node_soak_duration', type=int)
c.argument("undrainable_node_behavior", default='Schedule')
c.argument('mode', get_enum_type(node_mode_types))
c.argument('scale_down_mode', arg_type=get_enum_type(scale_down_modes))
c.argument('max_pods', type=int, options_list=['--max-pods', '-m'])
Expand Down Expand Up @@ -873,6 +874,7 @@ def load_arguments(self, _):
c.argument('max_surge', validator=validate_max_surge)
c.argument('drain_timeout', type=int)
c.argument('node_soak_duration', type=int)
c.argument("undrainable_node_behavior")
c.argument('mode', get_enum_type(node_mode_types))
c.argument('scale_down_mode', arg_type=get_enum_type(scale_down_modes))
c.argument('allowed_host_ports', nargs='+', validator=validate_allowed_host_ports)
Expand All @@ -891,6 +893,7 @@ def load_arguments(self, _):
c.argument('max_surge', validator=validate_max_surge)
c.argument('drain_timeout', type=int)
c.argument('node_soak_duration', type=int)
c.argument("undrainable_node_behavior")
c.argument('snapshot_id', validator=validate_snapshot_id)
c.argument('yes', options_list=['--yes', '-y'], help='Do not prompt for confirmation.', action='store_true')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1143,6 +1143,26 @@ def get_node_soak_duration(self):
# this parameter does not need validation
return node_soak_duration

def get_undrainable_node_behavior(self) -> str:
"""Obtain the value of undrainable_node_behavior.

:return: string
"""
# read the original value passed by the command
undrainable_node_behavior = self.raw_param.get("undrainable_node_behavior")
# In create mode, try to read the property value corresponding to the parameter from the `agentpool` object
if self.decorator_mode == DecoratorMode.CREATE:
if (
self.agentpool and
self.agentpool.upgrade_settings and
self.agentpool.upgrade_settings.undrainable_node_behavior is not None
):
undrainable_node_behavior = self.agentpool.upgrade_settings.undrainable_node_behavior

# this parameter does not need dynamic completion
# this parameter does not need validation
return undrainable_node_behavior

def get_vm_set_type(self) -> str:
"""Obtain the value of vm_set_type, default value is CONST_VIRTUAL_MACHINE_SCALE_SETS.

Expand Down Expand Up @@ -1821,6 +1841,10 @@ def set_up_upgrade_settings(self, agentpool: AgentPool) -> AgentPool:
if node_soak_duration:
upgrade_settings.node_soak_duration_in_minutes = node_soak_duration

undrainable_node_behavior = self.context.get_undrainable_node_behavior()
if undrainable_node_behavior:
upgrade_settings.undrainable_node_behavior = undrainable_node_behavior

agentpool.upgrade_settings = upgrade_settings
return agentpool

Expand Down Expand Up @@ -2210,6 +2234,11 @@ def update_upgrade_settings(self, agentpool: AgentPool) -> AgentPool:
upgrade_settings.node_soak_duration_in_minutes = node_soak_duration
agentpool.upgrade_settings = upgrade_settings

undrainable_node_behavior = self.context.get_undrainable_node_behavior()
if undrainable_node_behavior:
upgrade_settings.undrainable_node_behavior = undrainable_node_behavior
agentpool.upgrade_settings = upgrade_settings

return agentpool

def update_vm_properties(self, agentpool: AgentPool) -> AgentPool:
Expand Down
7 changes: 6 additions & 1 deletion src/azure-cli/azure/cli/command_modules/acs/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -2410,6 +2410,7 @@ def aks_agentpool_add(
max_surge=None,
drain_timeout=None,
node_soak_duration=None,
undrainable_node_behavior=None,
mode=CONST_NODEPOOL_MODE_USER,
scale_down_mode=CONST_SCALE_DOWN_MODE_DELETE,
max_pods=None,
Expand Down Expand Up @@ -2478,6 +2479,7 @@ def aks_agentpool_update(
max_surge=None,
drain_timeout=None,
node_soak_duration=None,
undrainable_node_behavior=None,
mode=None,
scale_down_mode=None,
no_wait=False,
Expand Down Expand Up @@ -2530,6 +2532,7 @@ def aks_agentpool_upgrade(cmd, client, resource_group_name, cluster_name,
max_surge=None,
drain_timeout=None,
node_soak_duration=None,
undrainable_node_behavior=None,
snapshot_id=None,
no_wait=False,
aks_custom_headers=None,
Expand All @@ -2549,7 +2552,7 @@ def aks_agentpool_upgrade(cmd, client, resource_group_name, cluster_name,
)

# Note: we exclude this option because node image upgrade can't accept nodepool put fields like max surge
if (max_surge or drain_timeout or node_soak_duration) and node_image_only:
if (max_surge or drain_timeout or node_soak_duration or undrainable_node_behavior) and node_image_only:
raise MutuallyExclusiveArgumentError(
'Conflicting flags. Unable to specify max-surge/drain-timeout/node-soak-duration with node-image-only.'
'If you want to use max-surge/drain-timeout/node-soak-duration with a node image upgrade, please first '
Expand Down Expand Up @@ -2604,6 +2607,8 @@ def aks_agentpool_upgrade(cmd, client, resource_group_name, cluster_name,
instance.upgrade_settings.drain_timeout_in_minutes = drain_timeout
if isinstance(node_soak_duration, int) and node_soak_duration >= 0:
instance.upgrade_settings.node_soak_duration_in_minutes = node_soak_duration
if undrainable_node_behavior:
instance.upgrade_settings.undrainable_node_behavior = undrainable_node_behavior

# custom headers
aks_custom_headers = extract_comma_separated_string(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,4 +200,17 @@ aks nodepool add:
disable_windows_outbound_nat:
rule_exclusions:
- option_length_too_long
undrainable_node_behavior:
rule_exclusions:
- option_length_too_long
aks nodepool update:
parameters:
undrainable_node_behavior:
rule_exclusions:
- option_length_too_long
aks nodepool upgrade:
parameters:
undrainable_node_behavior:
rule_exclusions:
- option_length_too_long
...
Loading