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

Add CLI wait 1.0.6 #7528

Merged
merged 24 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from 18 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/vm-repair/HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@

Release History
===============
1.0.6
++++++
Add while loop for ASG to check if the operation is done as the async 2rd operation will cancel the 1st call.


1.0.5
++++++
Bug fix ASG is not added properly when reset the nic
Expand Down
23 changes: 19 additions & 4 deletions src/vm-repair/azext_vm_repair/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,9 +618,11 @@ def reset_nic(cmd, vm_name, resource_group_name, yes=False):
for item in ip_config_object[applicationSecurityGroups]:
application_id_tokens = item['id'].split('/')
if application_id_tokens[-1] is not None:

application_names+=application_id_tokens[-1]+ " "
logger.info('applicationSecurityGroups {application_names}...\n')


logger.info('applicationSecurityGroups {application_names}...\n')


# Dynamic | Static
orig_ip_allocation_method = ip_config_object['privateIPAllocationMethod']
Expand All @@ -644,7 +646,20 @@ def reset_nic(cmd, vm_name, resource_group_name, yes=False):
update_ip_command = 'az network nic ip-config update -g {g} --nic-name {nic} -n {config} --private-ip-address {ip}' \
.format(g=resource_group_name, nic=primary_nic_name, config=ipconfig_name, ip=swap_ip_address)
_call_az_command(update_ip_command)

# Check if IP is updated
while True:
get_current_ip_command = 'az network nic ip-config wait --updatede -g {g} --nic-name {nic} -n ' \
.format(g=resource_group_name, nic=primary_nic_name)

current_ip_address = _call_az_command(get_current_ip_command)
if current_ip_address == swap_ip_address:
logger.info('IP address updated successfully to {ip}\n'.format(ip=swap_ip_address))
break
else:
logger.info('IP address not updated yet. Waiting for a few minutes before retrying...\n')
time.sleep(300)
# Sleep for 5 minutes
Copy link
Contributor

@zhoxing-ms zhoxing-ms Jul 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure the time.sleep(300) needs to sleep for such a long time? I'm not sure if the customer has the patience to wait for 5 minutes

Copy link
Contributor Author

@qwuae1 qwuae1 Jul 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zhoxing-ms thx, yeah 5 min will not work
pr now fully updated

the new method is the cli wait update, not 5 mins wait

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


# 4) Change things back. This will also invoke and wait for a VM restart.
logger.info('NIC reset is complete. Now reverting back to your original configuration...\n')
# If user had dynamic config, change back to dynamic
Expand Down Expand Up @@ -785,4 +800,4 @@ def repair_and_restore(cmd, vm_name, resource_group_name, repair_password=None,

logger.info('\n%s\n', command.message)

return return_dict
return return_dict
2 changes: 1 addition & 1 deletion src/vm-repair/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from codecs import open
from setuptools import setup, find_packages

VERSION = "1.0.5"
VERSION = "1.0.6"

CLASSIFIERS = [
'Development Status :: 4 - Beta',
Expand Down
Loading