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

fix: import of r/vsphere_virtual_disk imports the wrong vmdk_path #1762

Merged
merged 1 commit into from
Feb 12, 2024

Conversation

zxinyu08
Copy link
Contributor

@zxinyu08 zxinyu08 commented Sep 27, 2022

Description

Fix: Import of r/vsphere_virtual_disk imports the wrong vmdk_path.

Acceptance tests

  • Have you added an acceptance test for the functionality being added?
  • Have you run the acceptance tests on this branch?

Output from local testing:

$rm terraform.tfstate
$terraform import vsphere_virtual_disk.vmdk '{"virtual_disk_path": "/DataCenter/[vsanDatastore]namespace_test/secondary.vmdk", "create_directories": "true"}'
...
vsphere_virtual_disk.vmdk: Importing from ID "{\"virtual_disk_path\": \"/DataCenter/[vsanDatastore]namespace_test/secondary.vmdk\", \"create_directories\": \"true\"}"...
2022-09-26T19:23:44.709-0700 [INFO]  provider.terraform-provider-vsphere: 2022/09/26 19:23:44 [INFO] Set create_directories during import: true: timestamp=2022-09-26T19:23:44.709-0700   <----newly added log info, field is successfully set during import
2022-09-26T19:23:45.164-0700 [INFO]  provider.terraform-provider-vsphere: 2022/09/26 19:23:45 [DEBUG] DatastorePathFromString: success: true, path: "[vsanDatastore] 795e3263-e238-26e7-a8c6-02008e76a48b/secondary.vmdk": timestamp=2022-09-26T19:23:45.164-0700
vsphere_virtual_disk.vmdk: Import prepared!
  Prepared vsphere_virtual_disk for import
vsphere_virtual_disk.vmdk: Refreshing state... [id=namespace_test/secondary.vmdk]
....
Import successful!

The resources that were imported are shown above. These resources are now in
your Terraform state and will henceforth be managed by Terraform.

$cat terraform.tfstate
{
  "version": 4,
  "terraform_version": "1.2.1",
  "serial": 1,
  "lineage": "54097c80-aeff-a51b-a5d2-7c91fca8daa5",
  "outputs": {},
  "resources": [
    {
      "mode": "managed",
      "type": "vsphere_virtual_disk",
      "name": "vmdk",
      "provider": "provider[\"terraform-example.com/provider/vsphere\"]",
      "instances": [
        {
          "schema_version": 0,
          "attributes": {
            "adapter_type": "lsiLogic",
            "create_directories": true,  <--- set to true after import
            "datacenter": "DataCenter",
            "datastore": "vsanDatastore",
            "id": "namespace_test/secondary.vmdk",  <--- change to readable name, same as former tfstate file
            "size": 500,
            "type": "thin",
            "vmdk_path": "namespace_test/secondary.vmdk". <--- change to readable name, same as former tfstate file
          },
          "sensitive_attributes": [],
          "private": "eyJzY2hlbWFfdmVyc2lvbiI6IjAifQ=="
        }
      ]
    }
  ]
}
$terraform plan
....
2022-09-26T19:24:07.894-0700 [DEBUG] no planned changes, skipping apply graph check
2022-09-26T19:24:07.894-0700 [INFO]  backend/local: plan operation completed

No changes. Your infrastructure matches the configuration.

Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed.

Local test without create_directories field was also done. Import won't be blocked, and the issue is expected to be reproed.

Release Note

Release note for CHANGELOG:

resource/virtual_disk: Update import usage

References

Closes #1482

@github-actions github-actions bot added documentation Type: Documentation provider Type: Provider size/xs Relative Sizing: Extra-Small labels Sep 27, 2022
@tenthirtyam tenthirtyam added needs-review Status: Pull Request Needs Review area/storage Area: Storage labels Sep 27, 2022
@tenthirtyam tenthirtyam added this to the v2.3.0 milestone Sep 27, 2022
@tenthirtyam tenthirtyam changed the title fix: Import of vsphere_virtual_disk imports the wrong vmdk_path fix: Import of r/vsphere_virtual_disk' imports the wrong vmdk_path` Sep 27, 2022
@tenthirtyam tenthirtyam changed the title fix: Import of r/vsphere_virtual_disk' imports the wrong vmdk_path` fix: import of r/vsphere_virtual_disk' imports the wrong vmdk_path` Sep 27, 2022
tenthirtyam
tenthirtyam previously approved these changes Sep 27, 2022
Copy link
Collaborator

@tenthirtyam tenthirtyam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🚀 - awaiting review from @appilon

@appilon
Copy link
Contributor

appilon commented Sep 28, 2022

Hello @zxinyu08 this is a very creative solution. I'm going to take a look at the issue though #1482 to see if we can solve this problem more conventionally.

@zxinyu08
Copy link
Contributor Author

Sure, conventional one could be much better, thanks @appilon.

@tenthirtyam tenthirtyam changed the title fix: import of r/vsphere_virtual_disk' imports the wrong vmdk_path` fix: import of r/vsphere_virtual_disk imports the wrong vmdk_path Oct 5, 2022
@tenthirtyam tenthirtyam self-requested a review October 12, 2022 20:34
@tenthirtyam tenthirtyam dismissed their stale review October 12, 2022 20:36

Will reviewed again to see if this can be solved more conventionally.

@tenthirtyam tenthirtyam modified the milestones: v2.3.0, v2.4.0 Feb 1, 2023
@tenthirtyam tenthirtyam modified the milestones: v2.4.0, v2.5.0 May 4, 2023
@tenthirtyam tenthirtyam removed the needs-review Status: Pull Request Needs Review label Jul 25, 2023
@tenthirtyam tenthirtyam added the bug Type: Bug label Aug 7, 2023
@tenthirtyam tenthirtyam modified the milestones: v2.5.0, v2.6.0 Oct 9, 2023
Copy link
Collaborator

@tenthirtyam tenthirtyam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I'd rather get this one in as-is versus refactor and delay.

@tenthirtyam tenthirtyam removed this from the v2.6.0 milestone Nov 10, 2023
@tenthirtyam tenthirtyam added this to the Backlog milestone Nov 10, 2023
@tenthirtyam tenthirtyam merged commit c6b790f into hashicorp:main Feb 12, 2024
1 check passed
@tenthirtyam tenthirtyam modified the milestones: Backlog, v2.7.0 Feb 12, 2024
Copy link

github-actions bot commented Mar 6, 2024

This functionality has been released in v2.7.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

Copy link

github-actions bot commented Apr 6, 2024

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/storage Area: Storage bug Type: Bug documentation Type: Documentation provider Type: Provider size/xs Relative Sizing: Extra-Small
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Import of vsphere_virtual_disk imports the wrong vmdk_path
5 participants