crossplane-contrib / provider-upjet-azure

Official Azure Provider for Crossplane by Upbound.
Apache License 2.0
61 stars 75 forks source link

Unable to change the Nodepool size with error, Resource azurerm_kubernetes_cluster_node_pool.* has lifecycle.prevent_destroy set, but the plan calls for this resource to be destroyed. #734

Closed santhoshbhandari3008 closed 5 months ago

santhoshbhandari3008 commented 5 months ago

What problem are you facing?

I am unable to change the nodepool size, as it shows the below error, managed/containerservice.azure.upbound.io/v1beta1, kind=kubernetesclusternodepool cannot run plan: plan failed: Instance cannot be destroyed: Resource azurerm_kubernetes_cluster_node_pool.* has lifecycle.prevent_destroy set, but the plan calls for this resource to be destroyed. To avoid this error and continue with the plan, either disable lifecycle.prevent_destroy or reduce the scope of the plan using the -target flag.

The first time deployment file,

apiVersion: containerservice.azure.upbound.io/v1beta1
kind: KubernetesClusterNodePool
metadata:
  labels:
    testing.upbound.io/example-name: example
  name: example
spec:
  forProvider:
    kubernetesClusterIdSelector:
      matchLabels:
        testing.upbound.io/example-name: example
    nodeCount: 1
    minCount: 1
    maxCount: 5
    osSku: Ubuntu
    tags:
      Environment: Production
    **vmSize: Standard_DS2_v2**

Revised deployment file,

apiVersion: containerservice.azure.upbound.io/v1beta1
kind: KubernetesClusterNodePool
metadata:
  labels:
    testing.upbound.io/example-name: example
  name: example
spec:
  forProvider:
    kubernetesClusterIdSelector:
      matchLabels:
        testing.upbound.io/example-name: example
    nodeCount: 1
    minCount: 1
    maxCount: 5
    osSku: Ubuntu
    tags:
      Environment: Production
    **vmSize: Standard_D8s_v5**

This creates nodepool with the size Standard_DS2_v2. When i try to change the vmSize to any other, it throws error,

managed/containerservice.azure.upbound.io/v1beta1, kind=kubernetesclusternodepool cannot run plan: plan failed: Instance cannot be destroyed: Resource azurerm_kubernetes_cluster_node_pool.example has lifecycle.prevent_destroy set, but the plan calls for this resource to be destroyed. To avoid this error and continue with the plan, either disable lifecycle.prevent_destroy or reduce the scope of the plan using the -target flag.

Expected Output

The nodepool created successfully.

How could Official Azure Provider help solve your problem?

I checked the source code from the repository, it misses the prevent_destroy option to declare.

turkenf commented 5 months ago

Hi @santhoshbhandari3008, thank you for the issue.

The field vmSize is immutable: Changing this forces a new resource to be created.

Changing this field will cause the resource to be deleted and created again, according to the Crossplane Resource Model, this is something we do not allow.

Similar: https://github.com/crossplane-contrib/provider-upjet-aws/issues/1061#issuecomment-1880979041

Since this is to be expected, I am closing this issue. Upstream issue with rejecting change requests for immutable fields.

santhoshbhandari3008 commented 5 months ago

Makes sense