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

[BUG] Create multiple node pool with same vnet subnet ID, it throws SetVNetOwnershipFailed #4522

Closed
ms-henglu opened this issue Sep 5, 2024 · 2 comments
Assignees

Comments

@ms-henglu
Copy link
Member

Describe the bug

Create multiple node pool with same vnet subnet ID, it throws SetVNetOwnershipFailed

Error: creating Agent Pool (Subscription: "312d56f6-697b-4377-9a9a-83257ce33066"
        Resource Group Name: "acctestRG-aks-240506121623880995"
        Managed Cluster Name: "acctestaks240506121623880995"
        Agent Pool Name: "internal3"): polling after CreateOrUpdate: polling failed: the Azure API returned the following error:

        Status: "SetVNetOwnershipFailed"
        Code: ""
        Message: "Set virtual network ownership failed. Subscription: 312d56f6-697b-4377-9a9a-83257ce33066; resource group: acctestRG-aks-240506121623880995; virtual network name: acctestvirtnet240506121623880995. autorest/azure: Service returned an error. Status=400 Code=\"VirtualNetworkNotInSucceededState\" Message=\"Virtual network /subscriptions/312d56f6-697b-4377-9a9a-83257ce33066/resourceGroups/acctestRG-aks-240506121623880995/providers/Microsoft.Network/virtualNetworks/acctestvirtnet240506121623880995 is in Updating state. It needs to be in Succeeded state in order to set resource ownership.\" Details=[]\nVirtual network /subscriptions/312d56f6-697b-4377-9a9a-83257ce33066/resourceGroups/acctestRG-aks-240506121623880995/providers/Microsoft.Network/virtualNetworks/acctestvirtnet240506121623880995 is in Updating state. It needs to be in Succeeded state in order to set resource ownership."
        Activity Id: ""

        ---

        API Response:

        ----[start]----
        {
          "name": "da6f9f40-6f18-4380-b252-d516cd3659f0",
          "status": "Failed",
          "startTime": "2024-05-06T16:21:01.6132767Z",
          "endTime": "2024-05-06T16:21:09.0898922Z",
          "error": {
           "code": "SetVNetOwnershipFailed",
           "message": "Set virtual network ownership failed. Subscription: 312d56f6-697b-4377-9a9a-83257ce33066; resource group: acctestRG-aks-240506121623880995; virtual network name: acctestvirtnet240506121623880995. autorest/azure: Service returned an error. Status=400 Code=\"VirtualNetworkNotInSucceededState\" Message=\"Virtual network /subscriptions/312d56f6-697b-4377-9a9a-83257ce33066/resourceGroups/acctestRG-aks-240506121623880995/providers/Microsoft.Network/virtualNetworks/acctestvirtnet240506121623880995 is in Updating state. It needs to be in Succeeded state in order to set resource ownership.\" Details=[]",
           "details": [
            {
             "code": "",
             "message": "Virtual network /subscriptions/312d56f6-697b-4377-9a9a-83257ce33066/resourceGroups/acctestRG-aks-240506121623880995/providers/Microsoft.Network/virtualNetworks/acctestvirtnet240506121623880995 is in Updating state. It needs to be in Succeeded state in order to set resource ownership."
            }
           ]
          }
         }
        -----[end]-----


          with azurerm_kubernetes_cluster_node_pool.test3,
          on terraform_plugin_test.tf line 97, in resource "azurerm_kubernetes_cluster_node_pool" "test3":
          97: resource "azurerm_kubernetes_cluster_node_pool" "test3" {

To Reproduce
Steps to reproduce the behavior:

  1. It could be reproduced with this terraform config: https://gist.github.com/ms-henglu/b7532f48005415aa3a89b57ffdded326 with azurerm version less than v3.1.04.0 because in v3.104.0 a client-side fix is introduced (a client-side lock is added to prevent multiple node pool creating at the same time)

Expected behavior

The error should not happen even without the client-side fix.

Screenshots
If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

  • CLI Version [e.g. 3.22]
  • Kubernetes version [e.g. 1.24.3]
  • CLI Extension version [e.g. 1.7.5] if applicable
  • Browser [e.g. chrome, safari] is applicable

Additional context

hashicorp/terraform-provider-azurerm#25888

@zioproto
Copy link
Contributor

zioproto commented Oct 7, 2024

@ms-henglu should be fixed in AKS Release 2024-09-18

From the release notes:

Bug fix causing cluster creation to fail when creating a new cluster with multiple agent pools using the Dynamic Pod IP Allocation feature (podsubnet)

Can you confirm if you can still reproduce the problem or not with your sample terraform code ? thanks

@ms-henglu
Copy link
Member Author

ms-henglu commented Oct 8, 2024

Hi @zioproto , thanks for sharing this! I've confirmed that the issue is fixed now, and I opened this PR to remove the client side lock: hashicorp/terraform-provider-azurerm#27583

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

6 participants