Reboot Vm if CSE timesout so logs are collected (#3097)

This commit is contained in:
maddieford 2024-03-19 13:53:53 -07:00 коммит произвёл GitHub
Родитель 5d40813bf1
Коммит d98580381e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
1 изменённых файлов: 9 добавлений и 1 удалений

Просмотреть файл

@ -103,7 +103,15 @@ class RecoverNetworkInterface(AgentVmTest):
log.info("")
log.info("Using CSE to bring the primary network interface down and call the OSUtil to bring the interface back up. Command to execute: {0}".format(script))
custom_script = VirtualMachineExtensionClient(self._context.vm, VmExtensionIds.CustomScript, resource_name="CustomScript")
custom_script.enable(protected_settings={'commandToExecute': script}, settings={})
try:
custom_script.enable(protected_settings={'commandToExecute': script}, settings={})
except TimeoutError:
# Custom script may timeout if attempt to recover the network interface was not successful. The agent won't
# be able to report status for the extension if network is down. Reboot the VM to bring the network back up
# so logs can be collected.
log.info("Custom script did not complete within the timeout. Rebooting the VM in attempt to bring the network interface back up...")
self._context.vm.restart(wait_for_boot=True, ssh_client=self._ssh_client)
fail("Custom script did not complete within the timoeut, which indicates the agent may be unable to report status due to network issues.")
# Check that the interface was down and brought back up in instance view
log.info("")