azure-powershell icon indicating copy to clipboard operation
azure-powershell copied to clipboard

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

Open SriHarsha001 opened this issue 7 years ago • 8 comments

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

SriHarsha001 avatar Apr 03 '19 18:04 SriHarsha001

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

cormacpayne avatar Apr 03 '19 21:04 cormacpayne

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

SychevIgor avatar Apr 08 '19 08:04 SychevIgor

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

rcarboneras avatar Apr 08 '19 16:04 rcarboneras

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

SychevIgor avatar Apr 08 '19 18:04 SychevIgor

Hello Team - any update on this ?

mohatb avatar Apr 17 '19 14:04 mohatb

I have tha same issue

jakelima18 avatar Jul 12 '19 20:07 jakelima18

I have the same problem too

CharlesToniolo avatar Jul 31 '19 11:07 CharlesToniolo

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.

erich-wang avatar Jun 30 '20 09:06 erich-wang