Skip to content

Commit

Permalink
fix: don't uncordon and enable cluster-autoscaler after node is delet…
Browse files Browse the repository at this point in the history
…ed (#42)
  • Loading branch information
jackfrancis authored Jan 26, 2021
1 parent e587c0f commit 3221f4a
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions vmss-prototype/vmss-prototype
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,7 @@ def vmss_prototype_update(sub_args):
'--overwrite'
], retries=3, retry_func=not_found_no_retry)

nodeDeleted = False
try:
# Gracefully stop workloads on this VM.
run(['kubectl', 'cordon',
Expand Down Expand Up @@ -729,26 +730,29 @@ def vmss_prototype_update(sub_args):

# Delete the instance to prevent idns side-effects from future VMs coming online based on its prototype
# See https://github.com/jackfrancis/kamino/issues/26
run(az(['vmss', 'delete-instances'], subscription) + [
stdout, stderr, exit_code = run(az(['vmss', 'delete-instances'], subscription) + [
'--resource-group', resource_group,
'--name', vmss,
'--instance-ids', instance_id,
'--no-wait'
], retries=3, check=False, retry_func=not_found_no_retry)
if exit_code == 0:
nodeDeleted = True

finally:
# Let it be a productive member of the cluster again
# We ignore errors here since the VM may no longer exist
# We best-effort uncordon it.
run(['kubectl', 'uncordon',
target_node
], retries=3, check=False, retry_func=not_found_no_retry)
if not nodeDeleted:
# Let it be a productive member of the cluster again
# We ignore errors here since the VM may no longer exist
# We best-effort uncordon it.
run(['kubectl', 'uncordon',
target_node
], retries=3, check=False, retry_func=not_found_no_retry)

# Allow the cluster from scaling away the node...
run(['kubectl', 'annotate', 'node',
target_node,
'cluster-autoscaler.kubernetes.io/scale-down-disabled-'
], retries=3, check=False, retry_func=not_found_no_retry)
# Allow the cluster from scaling away the node...
run(['kubectl', 'annotate', 'node',
target_node,
'cluster-autoscaler.kubernetes.io/scale-down-disabled-'
], retries=3, check=False, retry_func=not_found_no_retry)

# Build the image version from the snapshow we have
output = vmss_build_sig_image(subscription, resource_group, sig_name, image_definition, version, snapshot)
Expand Down

0 comments on commit 3221f4a

Please sign in to comment.