Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 14, 2026

  • Analyze the issue and codebase to understand the problem
  • Identify all begin_update calls that need retry mechanism
  • Add retry decorator to begin_update calls in the resize method
  • Add retry decorator to begin_update calls in the attach_nics method
  • Add retry decorator to begin_update calls in the remove_extra_nics method
  • Remove test file as requested by reviewer
  • Implementation complete and ready for final review

Summary

Added retry mechanism to handle Azure ResourceExistsError (Conflict) errors when concurrent requests are made to VM update APIs. Created helper methods with @retry decorator (5 tries, 2s delay, 1.5x backoff) for:

  • Resize._update_vm_size() - VM resize operations
  • NetworkInterface._update_vm_nics() - Network interface attach/remove operations

All changes follow existing codebase patterns and are minimal in scope.

Original prompt

This section details on the original issue you should resolve

<issue_title>add retry mechanism when invoke azure api</issue_title>
<issue_description>Please refer below call stack to fix the issue

2026-01-14 05:23:30.899[7624][ERROR] lisa.case[verify_vm_hot_resize_decrease][lisa_0_55] case failed
Traceback (most recent call last):
  File "C:\app\lsg-lisa\lisa\lisa\testsuite.py", line 867, in __run_case
    _call_with_timeout(
  File "C:\app\lsg-lisa\lisa\lisa\testsuite.py", line 60, in _call_with_timeout
    func_timeout(
  File "C:\Python\Lib\site-packages\func_timeout\dafunc.py", line 108, in func_timeout
    raise_exception(exception)
  File "C:\Python\Lib\site-packages\func_timeout\py3_raise.py", line 7, in raise_exception
    raise exception[0] from None
  File "C:\app\lsg-lisa\lisa\lisa\testsuite.py", line 609, in wrapper
    func(*args, **parameters)
  File "C:\app\lsg-lisa\lisa\lisa\microsoft\testsuites\core\vm_resize.py", line 68, in verify_vm_hot_resize_decrease
    self._verify_vm_resize(
  File "C:\app\lsg-lisa\lisa\lisa\microsoft\testsuites\core\vm_resize.py", line 154, in _verify_vm_resize
    raise e
  File "C:\app\lsg-lisa\lisa\lisa\microsoft\testsuites\core\vm_resize.py", line 133, in _verify_vm_resize
    expected_vm_capability, origin_vm_size, final_vm_size = resize.resize(
                                                            ^^^^^^^^^^^^^^
  File "C:\app\lsg-lisa\lisa\lisa\sut_orchestrator\azure\features.py", line 2273, in resize
    lro_poller = compute_client.virtual_machines.begin_update(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python\Lib\site-packages\azure\core\tracing\decorator.py", line 119, in wrapper_use_tracer
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python\Lib\site-packages\azure\mgmt\compute\v2023_09_01\operations\_operations.py", line 16862, in begin_update
    raw_result = self._update_initial(
                 ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python\Lib\site-packages\azure\mgmt\compute\v2023_09_01\operations\_operations.py", line 16704, in _update_initial
    map_error(status_code=response.status_code, response=response, error_map=error_map)
  File "C:\Python\Lib\site-packages\azure\core\exceptions.py", line 163, in map_error
    raise error
azure.core.exceptions.ResourceExistsError: (Conflict) The request failed due to conflict with a concurrent request. To resolve it, please refer to https://aka.ms/activitylog to get more details on the conflicting requests.
Code: Conflict
Message: The request failed due to conflict with a concurrent request. To resolve it, please refer to https://aka.ms/activitylog to get more details on the conflicting requests.

```</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits January 14, 2026 07:22
Co-authored-by: LiliDeng <10083705+LiliDeng@users.noreply.github.com>
Co-authored-by: LiliDeng <10083705+LiliDeng@users.noreply.github.com>
Copilot AI changed the title [WIP] Add retry mechanism when invoking Azure API Add retry mechanism for Azure VM update API concurrent request conflicts Jan 14, 2026
Copilot AI requested a review from LiliDeng January 14, 2026 07:26
@LiliDeng
Copy link
Collaborator

Co-authored-by: LiliDeng <10083705+LiliDeng@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 14, 2026

@LiliDeng LiliDeng marked this pull request as ready for review January 14, 2026 07:52
@LiliDeng LiliDeng merged commit 6ed6c52 into main Jan 14, 2026
58 checks passed
@LiliDeng LiliDeng deleted the copilot/add-retry-mechanism-azure-api branch January 14, 2026 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add retry mechanism when invoke azure api

2 participants