Skip to content

aksd: fix: return full cluster list for AKS cluster registration#296

Merged
illume merged 1 commit intoAzure:mainfrom
tejhan:fix/paginate-aks-clusters
Mar 12, 2026
Merged

aksd: fix: return full cluster list for AKS cluster registration#296
illume merged 1 commit intoAzure:mainfrom
tejhan:fix/paginate-aks-clusters

Conversation

@tejhan
Copy link
Copy Markdown
Collaborator

@tejhan tejhan commented Feb 24, 2026

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 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.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • Code refactoring

Related Issues

Closes #295
Related to #274

Changes Made

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.

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.

@tejhan tejhan self-assigned this Feb 24, 2026
Copilot AI review requested due to automatic review settings February 24, 2026 13:48
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 fetchGraphPage helper function that executes Azure Resource Graph queries with pagination support (using --first 1000 and --skip-token)
  • Refactored getClustersViaGraph to 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.

Comment thread plugins/aks-desktop/src/utils/azure/az-cli.ts Outdated
Comment thread plugins/aks-desktop/src/utils/azure/az-cli.ts Outdated
Comment thread plugins/aks-desktop/src/utils/azure/az-cli.ts
Copy link
Copy Markdown
Collaborator

@illume illume left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fix.

Can you please address the copilot comments?

@illume illume marked this pull request as draft February 25, 2026 10:40
@tejhan tejhan force-pushed the fix/paginate-aks-clusters branch 2 times, most recently from d436b13 to fd06a4a Compare February 26, 2026 19:01
@tejhan tejhan marked this pull request as ready for review February 26, 2026 19:03
Copilot AI review requested due to automatic review settings February 26, 2026 19:03
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread plugins/aks-desktop/src/utils/azure/az-cli.ts Outdated
Comment thread plugins/aks-desktop/src/utils/azure/az-cli.ts
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread plugins/aks-desktop/src/utils/azure/az-cli.ts
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread plugins/aks-desktop/src/utils/azure/az-cli.ts
Copy link
Copy Markdown
Collaborator

@illume illume left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Nice improvement.

I left a note and a couple of questions.

Comment thread plugins/aks-desktop/src/utils/azure/az-cli.ts
Comment thread plugins/aks-desktop/src/utils/azure/az-cli.ts
Comment thread plugins/aks-desktop/src/utils/azure/az-cli.ts
@illume illume added p-none No priority was assigned bug Something isn't working labels Feb 27, 2026
@tejhan tejhan force-pushed the fix/paginate-aks-clusters branch from f03a99d to 4e4a09c Compare February 28, 2026 16:22
Copy link
Copy Markdown
Collaborator

@illume illume left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread plugins/aks-desktop/src/utils/azure/az-cli.ts
Comment thread plugins/aks-desktop/src/utils/azure/az-cli.ts
@illume illume marked this pull request as draft March 2, 2026 16:17
@tejhan tejhan force-pushed the fix/paginate-aks-clusters branch from 4e4a09c to 19b36c2 Compare March 7, 2026 02:00
@tejhan tejhan marked this pull request as ready for review March 7, 2026 02:01
Copilot AI review requested due to automatic review settings March 7, 2026 02:01
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread plugins/aks-desktop/src/utils/azure/az-cli.ts Outdated
Comment thread plugins/aks-desktop/src/utils/azure/az-cli.ts Outdated
Copy link
Copy Markdown
Collaborator

@illume illume left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@illume illume marked this pull request as draft March 11, 2026 18:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread plugins/aks-desktop/src/utils/azure/az-cli.ts Outdated
@illume illume added p2 priority and removed p-none No priority was assigned labels Mar 11, 2026
@tejhan tejhan force-pushed the fix/paginate-aks-clusters branch from 19b36c2 to d728d4f Compare March 12, 2026 05:38
@tejhan tejhan marked this pull request as ready for review March 12, 2026 10:15
Copilot AI review requested due to automatic review settings March 12, 2026 10:15
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@illume
Copy link
Copy Markdown
Collaborator

illume commented Mar 12, 2026

Also needs npm run i18n.

@illume illume marked this pull request as draft March 12, 2026 11:14
@tejhan tejhan force-pushed the fix/paginate-aks-clusters branch from d728d4f to 4769004 Compare March 12, 2026 12:13
@illume illume marked this pull request as ready for review March 12, 2026 12:39
Copilot AI review requested due to automatic review settings March 12, 2026 12:39
Copy link
Copy Markdown
Collaborator

@illume illume left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 thanks!

@illume illume merged commit 22887e7 into Azure:main Mar 12, 2026
10 checks passed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +1691 to +1692
| mv-expand agentPools
| extend poolNodeCount = toint(agentPools['count'])
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
| mv-expand agentPools
| extend poolNodeCount = toint(agentPools['count'])
| mv-expand kind=outer agentPools
| extend poolNodeCount = toint(coalesce(agentPools['count'], 0))

Copilot uses AI. Check for mistakes.
@illume illume mentioned this pull request Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working p2 priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Register AKS Cluster feature truncates cluster list at 100 in large subscriptions

3 participants