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

Objects have changed outside of Terraform after day 2 operation or vSphere tag #467

Open
jskirde opened this issue Oct 11, 2022 · 3 comments
Labels
bug Bug needs-triage Needs Triage

Comments

@jskirde
Copy link

jskirde commented Oct 11, 2022

vRA Version

8.7.0.21169 (19508505)

Terraform Version

v1.3.2

vRA Terraform Provider Version

0.5.2

Affected Resource(s)

vra_deployment

Terraform Configuration Files

resource "vra_deployment" "vm" {
  name        = format("%s_%s_%s", var.application, var.buildEnvironment, uuid())
  description = var.description
  lifecycle {
    ignore_changes = [
      name
    ]
  }

  catalog_item_id = data.vra_catalog_item.catalog_item.id
  project_id = data.vra_project.project.id

  inputs = {
    application= var.application
    site                   = var.site
    osVersion              = var.osVersion
    applicationEnvironment = var.applicationEnvironment
    applicationTier        = var.applicationTier
    disks                  = jsonencode(var.disks)
    cpuCount               = 8
    totalMemoryMB          = 8192
    resourcePool           = "default"
    component              = ""
  }

  timeouts {
    create = "200m"
    delete = "60m"
    update = "30m"
  }
}

tfvar file is initially set with :

disks                  = []

but then after the build, update it:

disks = [{
  label      = "test"
  mountPoint = "/var"
  size       = 10
}]

Expected Behavior

A disk should have been added (it was) and the state should have been updated with the last_request return (resource_ids and status) but it wasn't. When no changes are made to the input, and the resources haven't drifted, no state drift or resource changes should be required.

Actual Behavior

Terraform advised "Note: Objects have changed outside of Terraform" and indicates the vra_deployment resource has changed in both the last_request and resources attributes and shows a diff that is not representative of the actions that will be takes (it shows a complete removal of the virtual machine

# vra_deployment.vm has changed
  ~ resource "vra_deployment" "vm" {
        id                        = "6f1a80b9-17ee-4303-a056-769959ca8b0e"
      ~ last_request              = [
          ~ {
                id              = "4a72ccdc-b508-4ef0-afca-c09500e10774"
                name            = "Update"
              ~ resource_ids    = [
                  + "04d380e9-5590-4e3a-ae47-d0df829bd71a",
                  - "3caf47fd-d6a6-46ba-a18b-8242a528040f",
                    # (1 unchanged element hidden)
                ]
                # (17 unchanged elements hidden)
            },
        ]
        name                      = "myapp_dev_30ffdeb6-c994-a823-b0a5-a24086dc95ab"
      ~ resources                 = [
          + {
              + created_at      = "2022-10-10T23:01:51.205Z"
              + depends_on      = [
                  + "Cloud_vSphere_Disk[0]",
                  + "vSphere_Network",
                ]
              + description     = ""
              + expense         = []
              + id              = "412c79c3-13a0-49ea-927c-d3aef162e260"
              + name            = "vSphere_Machine[0]"
              + properties_json = jsonencode(
                    {
                      + _clusterAllocationSize            = "1"
                      + account                           = "mycloudzone"
                      + accounts                          = [
                          + "mycloudzone",
                        ]
                      + address                           = "192.168.0.114"
                      + application                       = "myapplication"
                      + applicationEnvironment            = "dev"
                      + applicationTier                   = "web"
                      + attachedDisks                     = [
                          + {
                              + source = "/resources/disks/04d380e9-5590-4e3a-ae47-d0df829bd71a"
                            },
                        ]
                      + catalogItemName                   = "linux"
                      + cloneFromImage                    = "linux-image"
                      + componentType                     = "Cloud.vSphere.Machine"
                      + computeHostRef                    = "ResourcePool:resgroup-1234"
                      + computeHostType                   = "ResourcePool"
                      + constraints                       = [
                          + {},
                          + {
                              + tag = "application:general"
                            },
                          + {},
                          + {},
                        ]
                      + coreCount                         = "8"
                      + count                             = "1"
                      + countIndex                        = "0"
                      + cpuCount                          = 8
                      + customizationSpec                 = "linux"
                      + datacenter                        = "Datacenter:datacenter-1"
                      + datastoreName                     = "DATASTORE01"
                      + deploymentId                      = "6f1a80b9-17ee-4303-a056-769959ca8b0e"
                      + disks                             = jsonencode([])
                      + endpointId                        = "bd809ecd-9099-49db-999c-475b584efc71"
                      + endpointType                      = "vsphere"
                      + environmentName                   = "environment"
                      + folderName                        = "folder"
                      + hasSnapshots                      = "false"
                      + hostname                          = "hostname123"
                      + id                                = "/resources/compute/412c79c3-13a0-49ea-927c-d3aef162e260"
                      + image                             = "linux-image"
                      + instanceUUID                      = "501b5d3f-fbb4-519c-ab89-7361101fd9e6"
                      + memoryGB                          = "8"
                      + name                              = "vSphere_Machine"
                      + networks                          = [
                          + {
                              + "Infoblox.IPAM.Network.dnsView" = "default"
                              + "Infoblox.IPAM.RangeId"         = "network/ZG5zLm5ldHdvcmskMTAuMTAwLjE2LjAvMjIvMA:192.168.0.0/24/default"
                              + address                         = "192.168.0.114"
                              + assignment                      = "static"
                              + deviceIndex                     = 0
                              + dns                             = [
                                  + "1.1.1.1",
                                  + "1.1.0.0",
                                ]
                              + external_id                     = "ecdc5476-7749-4861-8680-d1e48a57641a"
                              + id                              = "/resources/network-interfaces/629327ad-73f4-40e8-817c-1427d2e03caf"
                              + ipv6Addresses                   = []
                              + mac_address                     = "00:00:00:00:00:f0"
                              + name                            = "portgroup1"
                              + netmask                         = "255.255.255.0"
                              + network                         = "/provisioning/resources/compute-networks/3caf47fd-d6a6-46ba-a18b-8242a528040f"
                              + resourceName                    = "portgroup1"
                            },
                        ]
                      + nsxSecurityGroups                 = jsonencode(
                            [
                              + "sg1",
                            ]
                        )
                      + powerState                        = "ON"
                      + primaryMAC                        = "00:00:00:00:00:f0"
                      + project                           = "1f1d9944-c036-401e-8407-c1aa9d8de8b9"
                      + providerId                        = "101b5d3f-fbb4-519c-ab89-7361101fd9e6"
                      + region                            = "REGION01"
                      + resourceDescLink                  = "/resources/compute-descriptions/b8739ffa-a3be-4bcd-a2dd-2be3a3e2f798"
                      + resourceId                        = "412c79c3-13a0-49ea-927c-d3aef162e260"
                      + resourceLink                      = "/resources/compute/412c79c3-13a0-49ea-927c-d3aef162e260"
                      + resourceName                      = "hostname123"
                      + resourcePool                      = "/resources/pools/8ea476dba090ae75-7f703c5265a63d87"
                      + site                              = "site1"
                      + softwareName                      = "Linux"
                      + storage                           = {
                          + disks = [
                              + {
                                  + capacityGb           = 10
                                  + controllerKey        = "1000"
                                  + controllerUnitNumber = "1"
                                  + count                = "1"
                                  + countIndex           = "0"
                                  + encrypted            = false
                                  + endpointType         = "vsphere"
                                  + existingResource     = "false"
                                  + label                = "test"
                                  + mountPoint           = "/var"
                                  + name                 = "admin-748"
                                  + persistent           = false
                                  + provisioningType     = "thin"
                                  + resourceLink         = "/resources/disks/04d380e9-5590-4e3a-ae47-d0df829bd71a"
                                  + type                 = "HDD"
                                  + vcUuid               = "6c6d6246-0929-4229-805a-083012704055"
                                },
                              + {
                                  + bootOrder            = 1
                                  + capacityGb           = 40
                                  + controllerKey        = "1000"
                                  + controllerUnitNumber = "0"
                                  + diskPlacementRef     = "Datastore:datastore-1"
                                  + encrypted            = false
                                  + endpointType         = "vsphere"
                                  + existingResource     = "false"
                                  + independent          = "false"
                                  + limitIops            = "-1"
                                  + name                 = "hostname123-boot-disk"
                                  + persistent           = false
                                  + provisioningType     = "thin"
                                  + resourceLink         = "/resources/disks/87299d18-e789-4b32-b9b7-907c09d1d7d6"
                                  + shares               = "1000"
                                  + sharesLevel          = "normal"
                                  + type                 = "HDD"
                                  + vcUuid               = "6c6d6246-0929-4229-805a-083012704055"
                                  + vm                   = "VirtualMachine:vm-16390"
                                },
                            ]
                        }
                      + tags                              = [
                          + {
                              + key   = "application"
                              + value = "myapp"
                            },
                        ]
                      + totalMemoryMB                     = 8192
                      + vcUuid                            = "6c6d6246-0929-4229-805a-083012704055"
                      + vmFolderPath                      = "[DATASTORE01] 88a44463-e8d9-2eb7-d5f1-e4434bd9e0e0"
                      + vraEnvironment                    = "edev"
                      + zone                              = "mycloudzone / Tin"
                      + zone_overlapping_migrated         = "true"
                    }
                )
              + state           = "OK"
              + sync_status     = ""
              + type            = "Cloud.vSphere.Machine"
            },
          - {
              - created_at      = "2022-10-10T23:01:51.205Z"
              - depends_on      = [
                  - "vSphere_Network",
                ]
              - description     = ""
              - expense         = []
              - id              = "412c79c3-13a0-49ea-927c-d3aef162e260"
              - name            = "vSphere_Machine[0]"
              - properties_json = jsonencode(
                    {
                      {
                      - _clusterAllocationSize            = "1"
                      - account                           = "mycloudzone"
                      - accounts                          = [
                          - "mycloudzone",
                        ]
                      - address                           = "192.168.0.114"
                      - application                       = "myapplication"
                      - applicationEnvironment            = "dev"
                      - applicationTier                   = "web"
                      - attachedDisks                     = [
                          - {
                              - source = "/resources/disks/04d380e9-5590-4e3a-ae47-d0df829bd71a"
                            },
                        ]
                      - catalogItemName                   = "linux"
                      - cloneFromImage                    = "linux-image"
                      - componentType                     = "Cloud.vSphere.Machine"
                      - computeHostRef                    = "ResourcePool:resgroup-1234"
                      - computeHostType                   = "ResourcePool"
                      - constraints                       = [
                          - {},
                          - {
                              - tag = "application:general"
                            },
                          - {},
                          - {},
                        ]
                      - coreCount                         = "8"
                      - count                             = "1"
                      - countIndex                        = "0"
                      - cpuCount                          = 8
                      - customizationSpec                 = "linux"
                      - datacenter                        = "Datacenter:datacenter-1"
                      - datastoreName                     = "DATASTORE01"
                      - deploymentId                      = "6f1a80b9-17ee-4303-a056-769959ca8b0e"
                      - disks                             = jsonencode([])
                      - endpointId                        = "bd809ecd-9099-49db-999c-475b584efc71"
                      - endpointType                      = "vsphere"
                      - environmentName                   = "environment"
                      - folderName                        = "folder"
                      - hasSnapshots                      = "false"
                      - hostname                          = "hostname123"
                      - id                                = "/resources/compute/412c79c3-13a0-49ea-927c-d3aef162e260"
                      - image                             = "linux-image"
                      - instanceUUID                      = "501b5d3f-fbb4-519c-ab89-7361101fd9e6"
                      - memoryGB                          = "8"
                      - name                              = "vSphere_Machine"
                      - networks                          = [
                          - {
                              - "Infoblox.IPAM.Network.dnsView" = "default"
                              - "Infoblox.IPAM.RangeId"         = "network/ZG5zLm5ldHdvcmskMTAuMTAwLjE2LjAvMjIvMA:192.168.0.0/24/default"
                              - address                         = "192.168.0.114"
                              - assignment                      = "static"
                              - deviceIndex                     = 0
                              - dns                             = [
                                  - "1.1.1.1",
                                  - "1.1.0.0",
                                ]
                              - external_id                     = "ecdc5476-7749-4861-8680-d1e48a57641a"
                              - id                              = "/resources/network-interfaces/629327ad-73f4-40e8-817c-1427d2e03caf"
                              - ipv6Addresses                   = []
                              - mac_address                     = "00:00:00:00:00:f0"
                              - name                            = "portgroup1"
                              - netmask                         = "255.255.255.0"
                              - network                         = "/provisioning/resources/compute-networks/3caf47fd-d6a6-46ba-a18b-8242a528040f"
                              - resourceName                    = "portgroup1"
                            },
                        ]
                      - nsxSecurityGroups                 = jsonencode(
                            [
                              - "sg1",
                            ]
                        )
                      - powerState                        = "ON"
                      - primaryMAC                        = "00:00:00:00:00:f0"
                      - project                           = "1f1d9944-c036-401e-8407-c1aa9d8de8b9"
                      - providerId                        = "101b5d3f-fbb4-519c-ab89-7361101fd9e6"
                      - region                            = "REGION01"
                      - resourceDescLink                  = "/resources/compute-descriptions/b8739ffa-a3be-4bcd-a2dd-2be3a3e2f798"
                      - resourceId                        = "412c79c3-13a0-49ea-927c-d3aef162e260"
                      - resourceLink                      = "/resources/compute/412c79c3-13a0-49ea-927c-d3aef162e260"
                      - resourceName                      = "hostname123"
                      - resourcePool                      = "/resources/pools/8ea476dba090ae75-7f703c5265a63d87"
                      - site                              = "site1"
                      - softwareName                      = "Linux"
                      - storage                           = {
                          - disks = [
                              - {
                                  - bootOrder            = 1
                                  - capacityGb           = 40
                                  - controllerKey        = "1000"
                                  - controllerUnitNumber = "0"
                                  - diskPlacementRef     = "Datastore:datastore-23"
                                  - encrypted            = false
                                  - endpointType         = "vsphere"
                                  - existingResource     = "false"
                                  - independent          = "false"
                                  - name                 = "dlw221010230101-boot-disk"
                                  - persistent           = false
                                  - provisioningType     = "thin"
                                  - resourceLink         = "/resources/disks/87299d18-e789-4b32-b9b7-907c09d1d7d6"
                                  - type                 = "HDD"
                                  - vcUuid               = "6c6d6246-0929-4229-805a-083012704055"
                                  - vm                   = "VirtualMachine:vm-16390"
                                },
                            ]
                        }
                      - tags                              = []
                      - totalMemoryMB                     = 8192
                      - vcUuid                            = "6c6d6246-0929-4229-805a-083012704055"
                      - vmFolderPath                      = "[RCC-ISD-EDEV01-DATASTORE01] 88a44463-e8d9-2eb7-d5f1-e4434bd9e0e0"
                      - vraEnvironment                    = "edev"
                      - zone                              = "RCC-ISD-EDEV01 / Tin"
                      - zoneOverride                      = ""
                      - zone_overlapping_migrated         = "true"
                    }
                )
              - state           = "OK"
              - sync_status     = ""
              - type            = "Cloud.vSphere.Machine"
            },
          + {
              + created_at      = "2022-10-10T23:13:16.356Z"
              + depends_on      = []
              + description     = ""
              + expense         = []
              + id              = "04d380e9-5590-4e3a-ae47-d0df829bd71a"
              + name            = "Cloud_vSphere_Disk[0]"
              + properties_json = jsonencode(
                    {
                      + account          = "mycloudzone"
                      + accounts         = [
                          + "mycloudzone",
                        ]
                      + capacityGb       = 10
                      + componentType    = "Cloud.vSphere.Disk"
                      + constraints      = [
                          + {
                              + tag = "storageTier:ultra"
                            },
                          + {},
                          + {
                              + tag = "application:general"
                            },
                          + {},
                          + {},
                        ]
                      + count            = "1"
                      + countIndex       = "0"
                      + encrypted        = false
                      + endpointId       = "bd809ecd-9099-49db-999c-475b584efc71"
                      + endpointType     = "vsphere"
                      + id               = "/resources/disks/04d380e9-5590-4e3a-ae47-d0df829bd71a"
                      + label            = "test"
                      + mountPoint       = "/var"
                      + name             = "test"
                      + persistent       = false
                      + providerId       = "8896-2001"
                      + provisioningType = "thin"
                      + region           = "Datacenter:datacenter-1"
                      + resourceDescLink = "/resources/disks/8e0d9843-8034-4674-9b92-df2b76204503"
                      + resourceId       = "04d380e9-5590-4e3a-ae47-d0df829bd71a"
                      + resourceLink     = "/resources/disks/04d380e9-5590-4e3a-ae47-d0df829bd71a"
                      + resourceName     = "admin-748"
                      + status           = "ATTACHED"
                      + tags             = []
                      + type             = "HDD"
                      + vcUuid           = "6c6d6246-0929-4229-805a-083012704055"
                    }
                )
              + state           = "OK"
              + sync_status     = "SUCCESS"
              + type            = "Cloud.vSphere.Disk"
            },
            # (1 unchanged element hidden)
        ]
        # (14 unchanged attributes hidden)

        # (1 unchanged block hidden)
    }

Unless you have made equivalent changes to your configuration, or ignored the relevant attributes using ignore_changes, the following plan may include actions to undo or respond to these changes.

Steps to Reproduce

  1. Run initially with disks = []
  2. Add a disk by running with
disks = [{
  label      = "test"
  mountPoint = "/var"
  size       = 10
}]
  1. Run another plan

Debug Output

N/A

Panic Output

N/A

Important Factoids

N/A

References

N/A

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment
@jskirde jskirde added bug Bug needs-triage Needs Triage labels Oct 11, 2022
@ankujuniyal
Copy link

using terraform untaint vra_deployment.vm could help you to keep latest state. even after untaint i tried to add disk its not working.

@mf-sky
Copy link

mf-sky commented Aug 27, 2024

Still happens with

vRA Version
8.17.0.35214 (23831516)

Terraform Version
v1.9.5

vRA Terraform Provider Version
0.8.6

@mmn01-sky
Copy link

mmn01-sky commented Jan 6, 2025

VMware Aria Automation: v8.17.0.35214 (23831516)
Terraform Version: v1.10.0
vRA Terraform Provider: v0.11.0

This issue seems to be happening due to the sync_status field from what I can see. I get this same issue when changing ANY field on a day 2 action. It seems the field is updated after the deployment is created and the tfstate is written - possibly a job running that does a sync and updates this field.

On successful creation of the deployment, my tfstate shows the following:

"sync_status": ""

When I update any field on my terraform resource e.g. memory or adding disks and run a plan, the only value actually changing is:

 + sync_status     = "SUCCESS"

It seems this field is only populated when a day 2 action is triggered where it possibly runs a sync.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug needs-triage Needs Triage
Projects
None yet
Development

No branches or pull requests

4 participants