Skip to content
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

Set-AzureRmAks : A new agent pool was introduced. Adding agent pools to an existing cluster is not allowed at this time. #8934

Closed
SriHarsha001 opened this issue Apr 3, 2019 · 8 comments
Assignees

Comments

@SriHarsha001
Copy link

SriHarsha001 commented Apr 3, 2019

Description

Scale up/down an AKS cluster with the command Set-AzAks -NodeCount as documented here

Error

PS Azure:\\> Get-AzureRmAks -ResourceGroupName $rs.ResourceGroupName -Name $rs.Name | Set-AzureRmAks -NodeCount 1
Set-AzureRmAks : A new agent pool was introduced. Adding agent pools to an existing cluster is not allowed at this time.
At line:1 char:74
+ ... me $rs.ResourceGroupName -Name $rs.Name | Set-AzureRmAks -NodeCount 1
+ CategoryInfo          : CloseError: (:)
 [Set-AzAks], PSInvalidOperationException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Aks.SetAzureRmAks

Steps to reproduce

Get-AzureRmAks -ResourceGroupName AKSRG -Name AKSName
Set-AzureRmAks -ResourceGroupName AKSRG -Name AKSName -NodeCount Int

Environment data

PS Azure:\> $PSVersionTable
Name                           Value
PSVersion                      6.1.3
PSEdition                      Core
GitCommitId                    6.1.3
OS                             Linux 4.15.0-1040-azure #44-Ubuntu SMP Thu Feb 21 14:24:01 UTC 2019
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Module versions

PS Azure:\> Get-Module -Name Az.aks -ListAvailable
    Directory: /usr/local/share/powershell/Modules
ModuleType Version    Name                                PSEdition ExportedCommands
Script     1.0.1      Az.Aks                              Core,Desk {Get-AzAks, New-AzAks, Remove-AzAks, Import-AzAksCredential...}

Error output

PS Azure:\> Resolve-AzureRmError
   HistoryId: 4
Message        : A new agent pool was introduced. Adding agent pools to an existing cluster is not allowed at this time.
StackTrace     :    at Microsoft.Azure.Commands.Aks.KubeCmdletBase.RunCmdLet(Action action)
                    at Microsoft.Azure.Commands.Aks.SetAzureRmAks.ExecuteCmdlet()
                    at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()
Exception      : System.Management.Automation.PSInvalidOperationException
InvocationInfo : {Set-AzAks}
Line           : Set-AzureRmAks -ResourceGroupName aksharshatest -Name aksharshatest -NodeCount 1
Position       : At line:1 char:1
                 + Set-AzureRmAks -ResourceGroupName aksharshatest -Name aksharshatest -
HistoryId      : 4

RequestId      : 27eabda7-1751-4918-93eb-959e03a26de3
Message        : A new agent pool was introduced. Adding agent pools to an existing cluster is not allowed at this time.
ServerMessage  : BadRequest: A new agent pool was introduced. Adding agent pools to an existing cluster is not allowed at this time. (System.Collections.Generic.List`1[Microsoft.Rest.Azure.CloudError])
ServerResponse : {BadRequest}
RequestMessage : {PUT https://management.azure.com/subscriptions/b46812f2-e71b-4f85-8ed3-f24b7c0bded9/resourceGroups/aksharshatest/providers/Microsoft.ContainerService/managedClusters/aksharshatest?api-version=2017-08-31}
InvocationInfo : {Set-AzAks}
Line           : Set-AzureRmAks -ResourceGroupName aksharshatest -Name aksharshatest -NodeCount 1
Position       : At line:1 char:1
                 + Set-AzureRmAks -ResourceGroupName aksharshatest -Name aksharshatest - ...
StackTrace     :    at Microsoft.Azure.Commands.Aks.Generated.Version2017_08_31.ManagedClustersOperations.BeginCreateOrUpdateWithHttpMessagesAsync(String resourceGroupName, String resourceName, ManagedCluster parameters, Dictionary`2
                 customHeaders, CancellationToken cancellationToken)
                    at Microsoft.Azure.Commands.Aks.Generated.Version2017_08_31.ManagedClustersOperations.CreateOrUpdateWithHttpMessagesAsync(String resourceGroupName, String resourceName, ManagedCluster parameters, Dictionary`2
                 customHeaders, CancellationToken cancellationToken)
                    at Microsoft.Azure.Commands.Aks.Generated.Version2017_08_31.ManagedClustersOperationsExtensions.CreateOrUpdateAsync(IManagedClustersOperations operations, String resourceGroupName, String resourceName,
                 ManagedCluster parameters, CancellationToken cancellationToken)
                    at Microsoft.Azure.Commands.Aks.Generated.Version2017_08_31.ManagedClustersOperationsExtensions.CreateOrUpdate(IManagedClustersOperations operations, String resourceGroupName, String resourceName, ManagedCluster
                 parameters)
                    at Microsoft.Azure.Commands.Aks.SetAzureRmAks.<>c__DisplayClass10_0.<ExecuteCmdlet>b__0()
                    at Microsoft.Azure.Commands.Aks.KubeCmdletBase.RunCmdLet(Action action)
HistoryId      : 4
@cormacpayne cormacpayne added AKS Service Attention This issue is responsible by Azure service team. labels Apr 3, 2019
@cormacpayne
Copy link
Member

@mboersma Hey Matt, would you mind taking a look at this issue?

@SychevIgor
Copy link

The same issue with AZ module.
Get-AzAks -ResourceGroupName $ResourceGroup.ResourceGroupName -Name $aks.Name | Set-AzAks -NodeCount $NodeCount

@rcarboneras
Copy link

Hello, a colleague and me openned the case.
capturing the data, we saw that the Set-Aks is PUTting to azure RM two agent profiles, the one that already exists and the "default" one:

  "agentPoolProfiles": [
    {
      "name": "agentpool",
      "count": 2,
      "vmSize": "Standard_D2_v2",
      "osDiskSizeGB": 30,
      "ports": [],
      "storageProfile": "ManagedDisks",
      "osType": "Linux"
    },
    {
      "name": "default",
      "count": 3,
      "vmSize": "Standard_D2_v2",
      "osDiskSizeGB": 0,
      "dnsPrefix": "devsecops1-DevSecOpsLab-9b262f"
    }
  ],

Below is the piece of code that seems to do that:

https://github.com/Azure/azure-powershell/blob/master/src/Aks/Aks/Commands/SetAzureRmAks.cs

                    ContainerServiceAgentPoolProfile defaultAgentPoolProfile;
                    if (cluster.AgentPoolProfiles.Any(x => x.Name == "default"))
                    {
                        defaultAgentPoolProfile = cluster.AgentPoolProfiles.First(x => x.Name == "default");
                    }
                    else
                    {
                        defaultAgentPoolProfile = new ContainerServiceAgentPoolProfile(
                            "default",
                            NodeVmSize,
                            NodeCount,
                            NodeOsDiskSize,
                            DnsNamePrefix ?? DefaultDnsPrefix());
                        cluster.AgentPoolProfiles.Add(defaultAgentPoolProfile);
                    }

Doing the same with AZ cli works without any issues:
az aks scale --resource-group Resourcegroupname--name aksclustername--node-count number

@SychevIgor
Copy link

Interesting, that this code was last time edited a year ago based on git blame
image

@mohatb
Copy link

mohatb commented Apr 17, 2019

Hello Team - any update on this ?

@jakelima18
Copy link

I have tha same issue

@mboersma mboersma removed their assignment Jul 12, 2019
@CharlesToniolo
Copy link

I have the same problem too

@dingmeng-xue dingmeng-xue added Azure PS Team and removed Service Attention This issue is responsible by Azure service team. labels Feb 21, 2020
@dingmeng-xue dingmeng-xue assigned erich-wang and unassigned palma21 Jun 9, 2020
@erich-wang
Copy link
Member

erich-wang commented Jun 30, 2020

Please try latest version Az.Aks 1.1.2, it works well using following script:

New-AzAks -ResourceGroupName myres -Name myaks  | Set-AzAks -NodeCount 2

Close the issue as we can not reproduce in latest Az.Aks, please open another issue if having any concern, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests