Improve performance of AzureContainerInstanceHook.exists using direct container lookup#63567
Conversation
7c49e52 to
7520c69
Compare
|
Hey @SameerMesiah97, this looks good — replacing the list-and-scan with a direct One thing worth calling out that the PR description doesn't mention: the old A couple of small things:
Otherwise this is clean and ready to go from my perspective. |
7520c69 to
e2666f5
Compare
container_groups.get(resource_group, name) call. This avoids listing and pagination when checking whether a container group exists. Update tests to mock container_groups.get and cover success, not found, and error cases.
e2666f5 to
2a1b214
Compare
Description
This change improves the performance of
AzureContainerInstanceHook.existsby replacing the current scan of all container groups in a resource group with a direct lookup usingcontainer_groups.get(resource_group, name). Instead of listing and iterating over all container groups, the hook now performs a single API call to determine whether the container group exists.Rationale
Listing container groups can require pagination and multiple API calls as the number of resources in a resource group grows. Using the Azure SDK’s direct lookup endpoint avoids this overhead and aligns with the intended API usage.
Tests
Added/modified unit tests that verify that:
Truewhencontainer_groups.getsucceeds for an existing container groupFalsewhencontainer_groups.getraisesResourceNotFoundErrorcontainer_groups.getare propagated rather than being swallowedBackwards Compatibility
No change in external behavior. The method still returns
Truewhen the container group exists andFalsewhen it does not.