-
Notifications
You must be signed in to change notification settings - Fork 352
Fix inventory plugin broken with AzureStackHCI vms and also fix ScaleSets network interfaces #2077
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
base: dev
Are you sure you want to change the base?
Conversation
Everything is already available in self._instanceview Note: changes os_compute_name to computer_name
to reproduce issue:
az rest --url "/subscriptions/<subscription_id>/resourceGroups/<rgName>/providers/Microsoft.Compute/virtualMachineScaleSets/<scaleSetName>/virtualMachines/777/networkInterfaces/priva5b52Nic?api-version=2025-04-01"
returns:
Bad Request({"error":{"code":"NoRegisteredProviderFound","message":"No registered resource provider found for location 'westeurope' and API version '2025-05-01' for type 'virtualMachineScaleSets/virtualMachines/networkInterfaces'. The supported api-versions are '2015-05-01-preview, 2015-06-15, 2016-03-30, 2016-04-30-preview, 2016-06-01, 2016-07-01, 2016-08-01, 2016-09-01, 2017-03-30, 2017-12-01, 2018-04-01, 2018-06-01, 2018-10-01, 2019-03-01, 2019-07-01, 2019-12-01, 2020-06-01, 2020-12-01, 2021-03-01, 2021-04-01, 2021-07-01, 2021-11-01, 2022-03-01, 2022-08-01, 2022-11-01, 2023-03-01, 2023-07-01, 2023-09-01, 2024-03-01, 2024-07-01, 2024-11-01, 2025-04-01'. The supported locations are 'eastus, eastus2, westus, centralus, northcentralus, southcentralus, northeurope, westeurope, eastasia, southeastasia, japaneast, japanwest, australiaeast, australiasoutheast, australiacentral, brazilsouth, southindia, centralindia, westindia, canadacentral, canadaeast, westus2, westcentralus, uksouth, ukwest, koreacentral, koreasouth, francecentral, southafricanorth, uaenorth, switzerlandnorth, germanywestcentral, norwayeast, jioindiawest, westus3, swedencentral, qatarcentral, polandcentral, italynorth, israelcentral, spaincentral, mexicocentral, malaysiawest, newzealandnorth, indonesiacentral, austriaeast, chilecentral'."}})
Basically a revert of PR ansible-collections#2055 now that proper api_version is specific
plugins/inventory/azure_rm.py
Outdated
| location=self._arcvm['location'] if self._arcvm else self._vm_model['location'], | ||
| name=self._arcvm['name'] if self._arcvm else self._vm_model['name'], | ||
| computer_name=self._vm_model['properties'].get('osProfile', {}).get('computerName'), | ||
| computer_name=self._instanceview['computerName'] if self._instanceview.get('computerName') else self._vm_model['properties'].get('osProfile', {}).get('computerName'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (178 > 160 characters)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed :)
plus i've added some logging :) :) :) check out with -vvvv or debug=true in your ansible.cfg
Also display urls called with -vvvv And all raw responses if debug=true in ansible.cfg
|
i have another small patch ready to fix another 'bug' in azure stack hci inventory, but it's unrelated so i'll wait for this to be merged as some lines are common and would it would create a conflict |
|
any update @Fred-sun ? |
|
@TiTi Thank you very much for your update. Could you resolve the conflict first? Am I giving it a try? Thank you! |
|
The normal VM and Uniform VMSS instance vm work fine. I will create a Azure Stack HCI VM for test! Thank you very much! |
|
|
||
|
|
||
| display = Display() | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected 2 blank lines, found 1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's fixed
|
any progress? |
|
Hello, is there a reason my PR is not approved? |
|
Hi @TiTi, sorry for the slow progress on this PR. As I currently still do not have access to a pre-deployed Azure Stack HCI VM that is registered via Azure Arc, I couldn't validate this PR, hope for your understanding. If you are able, please provide HCI validation results or any sample inventory output from an HCI environment. This would help confirm the changes and ensure the fix works as intended. Let me discuss with the team and see how we can proceed further. Thanks! |
Ok i understand. Indeed having an HCI is a complex requirement. |
|
This also fixes #2125 but it does condense os_computer_name and computer_name into one thing. Not sure if that is wanted behavior. From my understanding: so the first one is the "creation" input, the 2nd one is the actual runtime hostname as reported by walinuxagent |
I can confirm it works for arc machines :) |
Hello and thank you. Indeed i didn't say it but it also solves the perf. issue, because removing (potentially lots of) uneeded requests. Regarding |
# Conflicts: # plugins/inventory/azure_rm.py
|
This is getting more and more challenging to handle conflicts as other PR are merged (and as i have other changes planned), but i managed. Note: for hci this PR is unsufficient and a micro pr is needed to avoid errors in output if you fetch both HCI vms and others arc objects (code is ready on my machine). Error would typically be confusing: However i prefer to keep this PR as simple as possible for readability as we have already multiple changes:
@Klaas- you're right after review i'm changing behavior of |
|
Fix i'm talking about is mostly replacing this: by this but i also want to rename 'arcvm' objects and properties to 'archcivm' because it's more explicit and differs from real ArcHost(arcvm, ...) which is non-hci |
|
so general answer, os_computer_name / computer_name I personally don't care too much about them because I am not using them from inventory :D from a compatibility perspective I would say don't break existing behavior unless the MSFT people here are up for a major version increase. Now if you ask me what should happen with the inventory generally speaking, I think what we do here should not be done here :) We should not be making up our own names for variables and completely rely on the azure python sdk, I've opened a "big issue" for that #2130 . Having said all that, this is not going to be short term solution because I guess I have to first convince msft of actually documenting the batch endpoint, then getting it into the sdk, then we can start using it :) For shortterm changes, the smaller you can make your PRs the easier it is to merge them for the MSFT people, stuff like HCI and/or ARC is a problem because they don't have this in their test environment apparently... |




SUMMARY
Fix of #2074
=> will provide scale set private ip under private_ipv4_addresses host var
ISSUE TYPE
COMPONENT NAME
inventory plugin
ADDITIONAL INFORMATION
The original issue was :
_on_nic_responsewas never called for scale sets nics, despite call toinventory_client._enqueue_get(url=nic['id'],being madeTo reproduce issue:
az rest --url "/subscriptions/<subscription_id>/resourceGroups/<rgName>/providers/Microsoft.Compute/virtualMachineScaleSets/<scaleSetName>/virtualMachines/<vmId>/networkInterfaces/<NicName>?api-version=2024-05-01"Which returns:
Bad Request({"error":{"code":"NoRegisteredProviderFound","message":"No registered resource provider found for location 'westeurope' and API version '2024-05-01' for type 'virtualMachineScaleSets/virtualMachines/networkInterfaces'. The supported api-versions are '2015-05-01-preview, 2015-06-15, 2016-03-30, 2016-04-30-preview, 2016-06-01, 2016-07-01, 2016-08-01, 2016-09-01, 2017-03-30, 2017-12-01, 2018-04-01, 2018-06-01, 2018-10-01, 2019-03-01, 2019-07-01, 2019-12-01, 2020-06-01, 2020-12-01, 2021-03-01, 2021-04-01, 2021-07-01, 2021-11-01, 2022-03-01, 2022-08-01, 2022-11-01, 2023-03-01, 2023-07-01, 2023-09-01, 2024-03-01, 2024-07-01, 2024-11-01, 2025-04-01'. The supported locations are 'eastus, eastus2, westus, centralus, northcentralus, southcentralus, northeurope, westeurope, eastasia, southeastasia, japaneast, japanwest, australiaeast, australiasoutheast, australiacentral, brazilsouth, southindia, centralindia, westindia, canadacentral, canadaeast, westus2, westcentralus, uksouth, ukwest, koreacentral, koreasouth, francecentral, southafricanorth, uaenorth, switzerlandnorth, germanywestcentral, norwayeast, jioindiawest, westus3, swedencentral, qatarcentral, polandcentral, italynorth, israelcentral, spaincentral, mexicocentral, malaysiawest, newzealandnorth, indonesiacentral, austriaeast, chilecentral'."}})