{vm-repair} Migrate commands calling Compute module to aaz-based implementation and add handling for extension version is null case#10106
Open
william051200 wants to merge 6 commits into
Conversation
️✔️Azure CLI Extensions Breaking Change Test
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the vm-repair extension to use AAZ-based VM retrieval helpers (instead of Compute SDK objects) and adds defensive handling in extension-version checking to avoid crashes when version metadata is missing.
Changes:
- Bump
vm-repairextension version to2.2.1and update release notes. - Migrate VM object access patterns across
custom.py,_validators.py, andrepair_utils.pyfrom SDK object attributes to AAZ JSON/dict access. - Add handling in
check_extension_versionto avoid'str' > 'NoneType'crashes when extension version is null.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/vm-repair/setup.py | Version bump to 2.2.1. |
| src/vm-repair/HISTORY.rst | Add 2.2.1 release notes describing the migration and crash fix. |
| src/vm-repair/azext_vm_repair/repair_utils.py | Switch VM parsing to dict access; add null-safe extension version check. |
| src/vm-repair/azext_vm_repair/custom.py | Switch command implementation to AAZ VM retrieval and dict-based VM field access. |
| src/vm-repair/azext_vm_repair/_validators.py | Switch validation logic to AAZ VM retrieval and dict-based access. |
Comment on lines
+510
to
512
| os_image_ref = source_vm.get('storageProfile', {}).get('imageReference', {}) | ||
| if os_image_ref and os_image_ref.get('version') in urns[0]: | ||
| if len(urns) < 2: |
Comment on lines
+522
to
+526
| repair_vm = get_vm_by_aaz(cmd, repair_vm_id['resource_group'], repair_vm_id['name']) | ||
| data_disks = repair_vm.get('storageProfile', {}).get('dataDisks') | ||
|
|
||
| # The params went through validator so no need for existence checks | ||
| disk_uri = [disk.vhd.uri for disk in data_disks if disk.name == disk_name][0] | ||
| disk_uri = [disk.get('vhd', {}).get('uri') for disk in data_disks if disk.get('name') == disk_name][0] |
Collaborator
|
vm-repair |
Member
Author
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
Member
Author
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Migrate code from Azure SDK to AAZ based commands for compute operations
Replace deprecated pkgutil loader with importlib.import_module
After running some tests for version compatibility, here are the results I got,
az extension add vm-repair 2.2.1 package generated from azdev 0.2.12 & 0.2.13 will show version = null
Those successfully installed (with no null version) also runs properly, with no error.
This confirms the migration has no issue & the issue raised by user is caused by version incompatibility.
This checklist is used to make sure that common guidelines for a pull request are followed.
Related command
General Guidelines
azdev style <YOUR_EXT>locally? (pip install azdevrequired)python scripts/ci/test_index.py -qlocally? (pip install azdevrequired)For new extensions:
About Extension Publish
There is a pipeline to automatically build, upload and publish extension wheels.
Once your pull request is merged into main branch, a new pull request will be created to update
src/index.jsonautomatically.You only need to update the version information in file setup.py and historical information in file HISTORY.rst in your PR but do not modify
src/index.json.