Skip to content

Commit bf7afa3

Browse files
Improve Azure VMSS error handling and logging (kevoreilly#2853)
* Improve Azure VMSS error handling and logging Adds handling for ResourceNotFoundError when listing VMSS VMs and NICs, preventing exceptions when VMSS capacity is zero. Improves logging for VMSS deletion conditions and corrects log formatting in reimage and delete threads. Also wraps VMSS creation logic in a broader exception handler for robustness. ✦ Here is the summary of changes specifically for the Azure machinery module (`modules/machinery/az.py`): Azure Machinery (`az.py`) Enhancements * Zero-Scale Compatibility: * Added handling for ResourceNotFoundError in _add_machines_to_db and _delete_machines_from_db_if_missing. This prevents the module from crashing when a Virtual Machine Scale Set (VMSS) has a capacity of 0, enabling the "scale from zero" cost-saving feature. * External Management Support: * Updated _process_pre_existing_vmsss to honor the just_start parameter. This prevents CAPE from automatically deleting VMSSs that don't match its internal tags/names if they are managed by external tools like Terraform or Ansible. * Robust Connection Logic: * Refactored _thr_wait_for_ready_machine to use an explicit socket creation and getaddrinfo iteration loop. This fixes potential thread hangs, improves reliability on busy systems, and adds full support for DNS hostnames and IPv6 addresses. * Thread Stability & Error Handling: * Wrapped the _thr_create_vmss background thread in a top-level exception handler to ensure that failures during VMSS creation (e.g., subnet issues or API errors) are logged instead of failing silently. * Bug Fixes & Logging: * Fixed malformed logging strings in the batch reimage and delete list readers (previously using incorrect set literal syntax and missing format arguments). * Added detailed debug logging for VMSS deletion and zero-capacity scenarios to improve troubleshooting. * Ensured proper import of ResourceNotFoundError from azure.core.exceptions. * Update modules/machinery/az.py Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> * Update modules/machinery/az.py Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent 90f67ce commit bf7afa3

File tree

1 file changed

+178
-161
lines changed

1 file changed

+178
-161
lines changed

0 commit comments

Comments
 (0)