aksd: fix: return full cluster list for AKS cluster registration#296
aksd: fix: return full cluster list for AKS cluster registration#296illume merged 1 commit intoAzure:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request fixes a bug where the "Register AKS Cluster" feature only returned the first 100 AKS clusters (alphabetically) when a subscription contained more than 100 clusters. The root cause was that the Azure Resource Graph query didn't specify the --first flag (which defaults to 100) and didn't handle pagination using --skip-token.
Changes:
- Created a new
fetchGraphPagehelper function that executes Azure Resource Graph queries with pagination support (using--first 1000and--skip-token) - Refactored
getClustersViaGraphto use the new helper function and loop through all pages to fetch the complete list of clusters - Added proper error handling for authentication and query failures in the pagination logic
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
illume
left a comment
There was a problem hiding this comment.
Nice fix.
Can you please address the copilot comments?
d436b13 to
fd06a4a
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
fd06a4a to
2eab1f9
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
2eab1f9 to
f03a99d
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
illume
left a comment
There was a problem hiding this comment.
Thanks. Nice improvement.
I left a note and a couple of questions.
f03a99d to
4e4a09c
Compare
illume
left a comment
There was a problem hiding this comment.
Thanks for those changes. Looking good.
Could you please update the commit message to be something like this?
plugins/aks-desktop: az-cli: Return full cluster list for AKS cluster registration
When using the "Register AKS Cluster" feature, subscriptions with more than
100 AKS clusters would return only the first 100 clusters (alphabetically).
Any cluster that alphabetically proceeded these isn't returned or searchable.The root of issue is that getClustersViaGraph called az graph query without
specifying the --first flag, which defaults to 100 results & also didn't paginate
excess results with the skip-tokens.Created a fetchGraphPage helper that calls az graph query with --first
1000 (max) and returns the result data and the skip_token pagination cursor.Updated getClustersViaGraph to paginate through all results using
skip_token, so all clusters are successfully fetched.
4e4a09c to
19b36c2
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
illume
left a comment
There was a problem hiding this comment.
At least one of the review comments open looks worth considering. Can you please have a look?
Please look at any new review comments made after you push?
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
19b36c2 to
d728d4f
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Also needs npm run i18n. |
d728d4f to
4769004
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| | mv-expand agentPools | ||
| | extend poolNodeCount = toint(agentPools['count']) |
There was a problem hiding this comment.
The query uses mv-expand agentPools (inner expand), which will drop clusters where properties.agentPoolProfiles is null/empty (e.g., partially-provisioned or failed clusters). In that case the Resource Graph path would silently omit clusters that the az aks list fallback would still return (with nodeCount=0). Consider using mv-expand kind=outer agentPools (or otherwise guarding/coalescing) so clusters with no pools remain in the result set.
| | mv-expand agentPools | |
| | extend poolNodeCount = toint(agentPools['count']) | |
| | mv-expand kind=outer agentPools | |
| | extend poolNodeCount = toint(coalesce(agentPools['count'], 0)) |
Description
When using the "Register AKS Cluster" feature, subscriptions with more than 100 AKS clusters would return only the first 100 clusters (alphabetically). Any cluster that alphabetically proceeded these isn't returned or searchable.
The root of issue is that
getClustersViaGraphcalled az graph query without specifying the --first flag, which defaults to 100 results & also didn't paginate excess results with theskip-tokens.Type of Change
Related Issues
Closes #295
Related to #274
Changes Made
Created a
fetchGraphPagehelper that calls az graph query with--first1000 (max) and returns the result data and the skip_token pagination cursor.Updated
getClustersViaGraphto paginate through all results using skip_token, so all clusters are successfully fetched.Testing
Since my largest subscriptions were in the hundreds but not thousands, pagination was validated by temporarily lowering the page size to 100 to confirm multi-page fetching works correctly. Verified all clusters appear when cluster amount exceeds page amount, which indicates pagination works.
Notes:
This is related to the umbrella issue of pagination for az-cli commands throughout. Currently looking into implementing this logic for other resource types so we can share utility.