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

vsphere_file error: A specified parameter was not correct: fileType #1243

Closed
pentiumoverdrive opened this issue Oct 19, 2020 · 6 comments · Fixed by #1409
Closed

vsphere_file error: A specified parameter was not correct: fileType #1243

pentiumoverdrive opened this issue Oct 19, 2020 · 6 comments · Fixed by #1409
Labels
acknowledged Status: Issue or Pull Request Acknowledged bug Type: Bug

Comments

@pentiumoverdrive
Copy link

Terraform Version

Terraform v0.12.26

vSphere Provider Version

provider.vsphere v1.24.2

Affected Resource(s)

Terraform Configuration Files

resource "vsphere_file" "templateupload" {
  datacenter       = "LAB"
  datastore        = "DS1111"
  create_directories = "true"
  source_file      = "/vmimages/mytemplate/somefile.vmdk"
  destination_file = "/_templatestest/somefile.vmdk"
}

Debug Output

2020/10/19 16:50:24 [DEBUG] vsphere_file.templateupload: applying the planned Create change
2020-10-19T16:50:24.228+0200 [DEBUG] plugin.terraform-provider-vsphere_v1.24.2_x4: 2020/10/19 16:50:24 [DEBUG] creating file: &schema.ResourceData{schema:map[string]*schema.Schema{"create_directories":(*schema.Schema)(0xc0004f2140), "datacenter":(*schema.Schema)(0xc0004ef900), "datastore":(*schema.Schema)(0xc0004efb80), "destination_file":(*schema.Schema)(0xc0004f2000), "source_datacenter":(*schema.Schema)(0xc0004efa40), "source_datastore":(*schema.Schema)(0xc0004efcc0), "source_file":(*schema.Schema)(0xc0004efe00)}, config:(*terraform.ResourceConfig)(nil), state:(*terraform.InstanceState)(0xc0004acaa0), diff:(*terraform.InstanceDiff)(0xc0007cfc60), meta:map[string]interface {}(nil), timeouts:(*schema.ResourceTimeout)(0xc000208a50), multiReader:(*schema.MultiLevelFieldReader)(nil), setWriter:(*schema.MapFieldWriter)(nil), newState:(*terraform.InstanceState)(nil), partial:false, partialMap:map[string]struct {}(nil), once:sync.Once{done:0x0, m:sync.Mutex{state:0, sema:0x0}}, isNew:true, panicOnError:false}
2020/10/19 16:50:26 [DEBUG] vsphere_file.templateupload: apply errored, but we're indicating that via the Error pointer rather than returning it: error A specified parameter was not correct: fileType
2020/10/19 16:50:26 [ERROR] : eval: *terraform.EvalApplyPost, err: error A specified parameter was not correct: fileType
2020/10/19 16:50:26 [ERROR] : eval: *terraform.EvalSequence, err: error A specified parameter was not correct: fileType

Error: error A specified parameter was not correct: fileType

on upload.tf line 11, in resource "vsphere_file" "templateupload":
11: resource "vsphere_file" "templateupload" {

Panic Output

Expected Behavior

File should be uploaded to datastore.

Actual Behavior

Terraform attempted to upload the file, but got an error.
I can see the same error from inside vcenter under recent tasks as well.

Steps to Reproduce

Important Factoids

References

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
@pentiumoverdrive pentiumoverdrive added the bug Type: Bug label Oct 19, 2020
@pentiumoverdrive
Copy link
Author

pentiumoverdrive commented Oct 22, 2020

This is funny, I haven't checked the source code..but if I rename my local VMDK to something random, like my_vm_file.apples I can upload the file to the datastore perfecly fine

This does not work:
resource "vsphere_file" "templateupload" {
datacenter = "LAB"
datastore = "DS1111"
create_directories = "true"
source_file = "/vmimages/mytemplate/somefile.vmdk"
destination_file = "/_templatestest/somefile.vmdk"
}

This works!
resource "vsphere_file" "templateupload" {
datacenter = "LAB"
datastore = "DS1111"
create_directories = "true"
source_file = "/vmimages/mytemplate/somefile.apples"
destination_file = "/_templatestest/somefile.vmdk"
}

Its like vcenter refuses to receive VMDK-files (it comes to this conclusion when upload is complete) but its OK to upload .log or other random file endings. Renaming the file is apparently OK after upload :)

@feckert
Copy link

feckert commented Oct 29, 2020

I get the following error:

2020-10-29T12:29:33.359+0100 [DEBUG] plugin.terraform-provider-vsphere_v1.24.2_x4: 2020/10/29 12:29:33 [DEBUG] creating file: &schema.ResourceData{schema:map[string]*schema.Schema{"create_directories":(*schema.Schema)(0xc0001ba140), "datacenter":(*schema.Schema)(0xc0001b9900), "datastore":(*schema.Schema)(0xc0001b9b80), "destination_file":(*schema.Schema)(0xc0001ba000), "source_datacenter":(*schema.Schema)(0xc0001b9a40), "source_datastore":(*schema.Schema)(0xc0001b9cc0), "source_file":(*schema.Schema)(0xc0001b9e00)}, config:(*terraform.ResourceConfig)(nil), state:(*terraform.InstanceState)(0xc000756aa0), diff:(*terraform.InstanceDiff)(0xc00067b7e0), meta:map[string]interface {}(nil), timeouts:(*schema.ResourceTimeout)(0xc0000f3f50), multiReader:(*schema.MultiLevelFieldReader)(nil), setWriter:(*schema.MapFieldWriter)(nil), newState:(*terraform.InstanceState)(nil), partial:false, partialMap:map[string]struct {}(nil), once:sync.Once{done:0x0, m:sync.Mutex{state:0, sema:0x0}}, isNew:true, panicOnError:false}
2020/10/29 12:29:37 [DEBUG] vsphere_file.apos-latest: apply errored, but we're indicating that via the Error pointer rather than returning it: error Error caused by file /vmfs/volumes/5eb8fcea-8ba7426e-9346-001e6799bae1/TEST-latest.vmdk
2020/10/29 12:29:37 [TRACE] eval: *terraform.EvalMaybeTainted
2020/10/29 12:29:37 [TRACE] EvalMaybeTainted: vsphere_file.apos-latest encountered an error during creation, so it is now marked as tainted
2020/10/29 12:29:37 [TRACE] eval: *terraform.EvalWriteState
2020/10/29 12:29:37 [TRACE] EvalWriteState: removing state object for vsphere_file.apos-latest
2020/10/29 12:29:37 [TRACE] eval: *terraform.EvalApplyProvisioners
2020/10/29 12:29:37 [TRACE] EvalApplyProvisioners: vsphere_file.apos-latest has no state, so skipping provisioners
2020/10/29 12:29:37 [TRACE] eval: *terraform.EvalMaybeTainted
2020/10/29 12:29:37 [TRACE] EvalMaybeTainted: vsphere_file.apos-latest encountered an error during creation, so it is now marked as tainted
2020/10/29 12:29:37 [TRACE] eval: *terraform.EvalWriteState
2020/10/29 12:29:37 [TRACE] EvalWriteState: removing state object for vsphere_file.apos-latest
2020/10/29 12:29:37 [TRACE] eval: *terraform.EvalIf
2020/10/29 12:29:37 [TRACE] eval: *terraform.EvalIf
2020/10/29 12:29:37 [TRACE] eval: *terraform.EvalWriteDiff
2020/10/29 12:29:37 [TRACE] eval: *terraform.EvalApplyPost
2020/10/29 12:29:37 [ERROR] eval: *terraform.EvalApplyPost, err: error Error caused by file /vmfs/volumes/5eb8fcea-8ba7426e-9346-001e6799bae1/TEST-latest.vmdk
2020/10/29 12:29:37 [ERROR] eval: *terraform.EvalSequence, err: error Error caused by file /vmfs/volumes/5eb8fcea-8ba7426e-9346-001e6799bae1/TEST-latest.vmdk

If I renamed the file from TEST-latest.vmdk to TEST-latest.upload everything works.
This is strange!
@pentiumoverdrive thanks for this hint 👍 I almost despaired!!!!

@feckert
Copy link

feckert commented Oct 29, 2020

@pentiumoverdrive

I don't know if I'm too stupid, but I can't get it to assign the file I uploaded to a VM.
I have already tried all possibilities and combinations from the documentation.
I have not found a recipe either.
Either it is too easy or I miss the crucial hint.

Does I need this too https://registry.terraform.io/providers/hashicorp/vsphere/latest/docs/resources/virtual_disk
You notice that I am just starting to use terraform.

My version I use are:

  • ESXI 6.7
  • terraform-vsphere 1.24.2
  • terraform v.0.13.5

My main.tf extract

resource "vsphere_file" "test" {
        datacenter = data.vsphere_datacenter.dc.id
        datastore = "datastore1"
        source_file = "/tmp/latest.vmdk.upload"
        destination_file ="latest.vmdk"
}

resource "vsphere_virtual_machine" "test" {
        name  = "Test1"
        resource_pool_id = data.vsphere_resource_pool.pool.id
        datastore_id = data.vsphere_datastore.vmdatastore.id

        num_cpus = 2
        memory = 1024
        guest_id = "other3xLinux64Guest"
        annotation = "Deployed by terraform"

        network_interface {
                network_id = data.vsphere_network.mgmt_lan.id
        }

        disk {
                label = "disk0"
                controller_type = "sata"
                attach = true
                datastore_id = data.vsphere_datastore.datastore.id
                path = vsphere_file.test.destination_file
        }
}

EDIT:

Error message from terraform is:
Error: error powering on virtual machine: powerOn task for vm "/ha-datacenter/vm/latest" failed: Unsupported or invalid disk type 22 for 'sata0:0'. Ensure that the disk has been imported

@tenthirtyam
Copy link
Collaborator

The issue seems to be below in the code where a .vmdk is copied to a temporary file and then moved to the final destination.

case path.Ext(f.sourceFile) == ".vmdk":
tempDstFile := fmt.Sprintf("tfm-temp-%d.vmdk", time.Now().Nanosecond())
err = fileUpload(client, dstDatacenter, dstDatastore, f.sourceFile, tempDstFile)
if err != nil {
return fmt.Errorf("error %s", err)
}
err = dstDfm.Move(context.TODO(), tempDstFile, f.destinationFile)
if err != nil {
return fmt.Errorf("error %s", err)
}

This was introduced in d7d070b#diff-2355e16e1bc6ee045465c7d31518f399d7ebe738bcf5c573f361a9c4f8b3169b by @jcpowermac for support of vmdks.

@jcpowermac, would you be willing to review this issue?

Ryan

@tenthirtyam
Copy link
Collaborator

Duplicated in #1296.

@tenthirtyam tenthirtyam changed the title vsphere_file complains about "error A specified parameter was not correct: fileType" vsphere_file error: A specified parameter was not correct: fileType Feb 4, 2022
@tenthirtyam tenthirtyam added acknowledged Status: Issue or Pull Request Acknowledged needs-triage Status: Issue Needs Triage labels Feb 5, 2022
@github-actions
Copy link

I'm going to lock this issue 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 similar to this, 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 Mar 12, 2022
@tenthirtyam tenthirtyam removed the needs-triage Status: Issue Needs Triage label Jun 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
acknowledged Status: Issue or Pull Request Acknowledged bug Type: Bug
Projects
None yet
3 participants