oVirt / terraform-provider-ovirt

Terraform provider for oVirt 4.x
https://registry.terraform.io/providers/oVirt/ovirt/latest/docs
Other
137 stars 72 forks source link

Cannot use ovirt_image_transfer with FCOS image #197

Closed duritong closed 4 years ago

duritong commented 4 years ago

Trying to add a fcos image to my ovirt 4.3.8.2-1.el7 using terraform plugin based on c4dfefbe2ea87ced0b9593584d8df398d3858c62

I am trying to follow your example, though just switching cirros image to fcos and this seems to fail:

resource "ovirt_image_transfer" "fcos_transfer" {

  alias             = "fcos31"
  source_url        = "https://builds.coreos.fedoraproject.org/prod/streams/stable/builds/31.20200210.3.0/x86_64/fedora-coreos-31.20200210.3.0-openstack.x86_64.qcow2.xz"
  sparse            = true
  storage_domain_id = local.sds_id
}

But I keep getting:

Error: Fault reason is "Operation Failed". Fault detail is "[Cannot add Virtual Disk. Disk's provisioned size has to be greater than 0.]". HTTP response code is "400". HTTP response message is "400 Bad Request".

  on main.tf line 41, in resource "ovirt_image_transfer" "fcos_transfer":
  41: resource "ovirt_image_transfer" "fcos_transfer" {

This error comes from ovirt as I am seeing it as well in the logs:

2020-02-25 21:34:14,081Z ERROR [org.ovirt.engine.api.restapi.resource.AbstractBackendResource] (default task-113) [] Operation Failed: [Cannot add Virtual Disk. Disk's provisioned size has to be greater than 0.]
2020-02-25 21:34:16,255Z WARN  [org.ovirt.engine.core.bll.storage.disk.AddDiskCommand] (default task-113) [e838a4c1-8609-4ef7-9ae2-f3821278162f] Validation of action 'AddDisk' failed for user terraform@internal-authz. Reasons: VAR__ACTION__ADD,VAR__TYPE__DISK,ACTION_TYPE_FAILED_DISK_SIZE_ZER

The cirros image seems to work.

rgolangh commented 4 years ago

I think that is because xz extension is not recognized by ovirt. We support qcow2. Can you download locally, extract, and then change the source_url: file:///path/to/disk.qcow2 ?

rgolangh commented 4 years ago

can we close this?

duritong commented 4 years ago

I wasn't yet able to re-test. But given it took 1 month for an answer, I can also get 1 month to test? :-)

duritong commented 4 years ago

Using a locally extracted image and 73f2734a19ba1e2fff504574c5b60c4c6e1e2696 I think I came one step further.

One side comment: It is really hard to find out the cluster id in ovirt if not even impossible from purely the web ui.

Anyway, currently I get a terraform crash, which probably shouldn't happen and rather a proper error message raised.

I am investigating whether the underlying issue is something on my side, though in general uploading images work.

$ terraform apply
data.ovirt_clusters.clusters: Refreshing state...

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # ovirt_image_transfer.fcos_transfer will be created
  + resource "ovirt_image_transfer" "fcos_transfer" {
      + alias             = "fcos31"
      + disk_id           = (known after apply)
      + id                = (known after apply)
      + source_url        = "/tmp/fedora-coreos-31.20200210.3.0-openstack.x86_64.qcow2"
      + sparse            = true
      + storage_domain_id = "d3d21d97-3ec9-4b37-b0e0-f94f0851d808"
    }

  # ovirt_template.fcos_template will be created
  + resource "ovirt_template" "fcos_template" {
      + clone             = false
      + cluster_id        = "7ceaf68d-09b5-4015-9444-7cdfcdd81aef"
      + cores             = 1
      + high_availability = false
      + id                = (known after apply)
      + name              = "template-for-fcos31"
      + sockets           = 1
      + status            = (known after apply)
      + threads           = 1
      + vm_id             = (known after apply)
    }

  # ovirt_vm.tmpvm will be created
  + resource "ovirt_vm" "tmpvm" {
      + clone             = false
      + cluster_id        = "7ceaf68d-09b5-4015-9444-7cdfcdd81aef"
      + cores             = 1
      + high_availability = false
      + id                = (known after apply)
      + name              = "tmpvm-for-fcos31"
      + sockets           = 1
      + status            = (known after apply)
      + template_id       = "00000000-0000-0000-0000-000000000000"
      + threads           = 1

      + block_device {
          + active               = true
          + disk_id              = (known after apply)
          + interface            = "virtio_scsi"
          + read_only            = false
          + use_scsi_reservation = false
        }
    }

Plan: 3 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

ovirt_image_transfer.fcos_transfer: Creating...
ovirt_image_transfer.fcos_transfer: Still creating... [10s elapsed]
ovirt_image_transfer.fcos_transfer: Still creating... [20s elapsed]
ovirt_image_transfer.fcos_transfer: Still creating... [30s elapsed]
ovirt_image_transfer.fcos_transfer: Still creating... [40s elapsed]
ovirt_image_transfer.fcos_transfer: Still creating... [50s elapsed]
ovirt_image_transfer.fcos_transfer: Still creating... [1m0s elapsed]
ovirt_image_transfer.fcos_transfer: Still creating... [1m10s elapsed]
ovirt_image_transfer.fcos_transfer: Still creating... [1m20s elapsed]
ovirt_image_transfer.fcos_transfer: Still creating... [1m30s elapsed]
ovirt_image_transfer.fcos_transfer: Still creating... [1m40s elapsed]
ovirt_image_transfer.fcos_transfer: Still creating... [1m50s elapsed]
ovirt_image_transfer.fcos_transfer: Still creating... [2m0s elapsed]
ovirt_image_transfer.fcos_transfer: Still creating... [2m10s elapsed]

Error: rpc error: code = Unavailable desc = transport is closing

panic: runtime error: invalid memory address or nil pointer dereference
2020-04-06T12:04:35.533+0200 [DEBUG] plugin.terraform-provider-ovirt: [signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x1572201]
2020-04-06T12:04:35.533+0200 [DEBUG] plugin.terraform-provider-ovirt: 
2020-04-06T12:04:35.533+0200 [DEBUG] plugin.terraform-provider-ovirt: goroutine 115 [running]:
2020-04-06T12:04:35.533+0200 [DEBUG] plugin.terraform-provider-ovirt: github.com/ovirt/terraform-provider-ovirt/ovirt.detectUploadUrl(0xc0001b8640, 0xc00013c148, 0x0, 0x0, 0x1)
2020-04-06T12:04:35.533+0200 [DEBUG] plugin.terraform-provider-ovirt:   /home/mh/dev/go/src/github.com/oVirt/terraform-provider-ovirt/ovirt/resource_ovirt_image_transfer.go:217 +0x5b1
2020-04-06T12:04:35.533+0200 [DEBUG] plugin.terraform-provider-ovirt: github.com/ovirt/terraform-provider-ovirt/ovirt.UploadToDisk(0xc0001510e0, 0xc000010af0, 0xc0001302d0, 0x24, 0xc0001429c6, 0x6, 0x66d50000, 0x0, 0x0, 0x0)
2020-04-06T12:04:35.533+0200 [DEBUG] plugin.terraform-provider-ovirt:   /home/mh/dev/go/src/github.com/oVirt/terraform-provider-ovirt/ovirt/resource_ovirt_image_transfer.go:190 +0x4d3
2020-04-06T12:04:35.533+0200 [DEBUG] plugin.terraform-provider-ovirt: github.com/ovirt/terraform-provider-ovirt/ovirt.resourceOvirtImageTransferCreate(0xc00029cf50, 0x19a5e80, 0xc0001510e0, 0x2, 0x28db500)
2020-04-06T12:04:35.533+0200 [DEBUG] plugin.terraform-provider-ovirt:   /home/mh/dev/go/src/github.com/oVirt/terraform-provider-ovirt/ovirt/resource_ovirt_image_transfer.go:134 +0x7eb
2020-04-06T12:04:35.533+0200 [DEBUG] plugin.terraform-provider-ovirt: github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Resource).Apply(0xc000147600, 0xc0003ee690, 0xc00000fe60, 0x19a5e80, 0xc0001510e0, 0xc00039d701, 0xc0003f4360, 0xc00039d768)
2020-04-06T12:04:35.533+0200 [DEBUG] plugin.terraform-provider-ovirt:   /home/mh/dev/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.8.0/helper/schema/resource.go:305 +0x365
2020-04-06T12:04:35.533+0200 [DEBUG] plugin.terraform-provider-ovirt: github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Provider).Apply(0xc0004beb80, 0xc000019918, 0xc0003ee690, 0xc00000fe60, 0xc0003ed3a8, 0xc0000108c8, 0x17d6f40)
2020-04-06T12:04:35.533+0200 [DEBUG] plugin.terraform-provider-ovirt:   /home/mh/dev/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.8.0/helper/schema/provider.go:294 +0x99
2020-04-06T12:04:35.533+0200 [DEBUG] plugin.terraform-provider-ovirt: github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin.(*GRPCProviderServer).ApplyResourceChange(0xc00013c560, 0x1d45220, 0xc0003d5590, 0xc0000999e0, 0xc00013c560, 0xc0003d5590, 0xc000086a80)
2020-04-06T12:04:35.533+0200 [DEBUG] plugin.terraform-provider-ovirt:   /home/mh/dev/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.8.0/internal/helper/plugin/grpc_provider.go:885 +0x8b4
2020-04-06T12:04:35.533+0200 [DEBUG] plugin.terraform-provider-ovirt: github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5._Provider_ApplyResourceChange_Handler(0x19a8000, 0xc00013c560, 0x1d45220, 0xc0003d5590, 0xc000099980, 0x0, 0x1d45220, 0xc0003d5590, 0xc0003f2280, 0x25b)
2020-04-06T12:04:35.533+0200 [DEBUG] plugin.terraform-provider-ovirt:   /home/mh/dev/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.8.0/internal/tfplugin5/tfplugin5.pb.go:3189 +0x217
2020-04-06T12:04:35.533+0200 [DEBUG] plugin.terraform-provider-ovirt: google.golang.org/grpc.(*Server).processUnaryRPC(0xc0003c6000, 0x1d534c0, 0xc000121080, 0xc0004f2400, 0xc0001364b0, 0x28af320, 0x0, 0x0, 0x0)
2020-04-06T12:04:35.533+0200 [DEBUG] plugin.terraform-provider-ovirt:   /home/mh/dev/go/pkg/mod/google.golang.org/grpc@v1.23.0/server.go:995 +0x460
2020-04-06T12:04:35.533+0200 [DEBUG] plugin.terraform-provider-ovirt: google.golang.org/grpc.(*Server).handleStream(0xc0003c6000, 0x1d534c0, 0xc000121080, 0xc0004f2400, 0x0)
2020-04-06T12:04:35.533+0200 [DEBUG] plugin.terraform-provider-ovirt:   /home/mh/dev/go/pkg/mod/google.golang.org/grpc@v1.23.0/server.go:1275 +0xd97
2020-04-06T12:04:35.533+0200 [DEBUG] plugin.terraform-provider-ovirt: google.golang.org/grpc.(*Server).serveStreams.func1.1(0xc000142130, 0xc0003c6000, 0x1d534c0, 0xc000121080, 0xc0004f2400)
2020-04-06T12:04:35.533+0200 [DEBUG] plugin.terraform-provider-ovirt:   /home/mh/dev/go/pkg/mod/google.golang.org/grpc@v1.23.0/server.go:710 +0xbb
2020-04-06T12:04:35.533+0200 [DEBUG] plugin.terraform-provider-ovirt: created by google.golang.org/grpc.(*Server).serveStreams.func1
2020-04-06T12:04:35.533+0200 [DEBUG] plugin.terraform-provider-ovirt:   /home/mh/dev/go/pkg/mod/google.golang.org/grpc@v1.23.0/server.go:708 +0xa1
2020-04-06T12:04:35.535+0200 [DEBUG] plugin: plugin process exited: path=/home/mh/.terraform.d/plugins/terraform-provider-ovirt pid=1568365 error="exit status 2"
2020/04/06 12:04:35 [DEBUG] ovirt_image_transfer.fcos_transfer: apply errored, but we're indicating that via the Error pointer rather than returning it: rpc error: code = Unavailable desc = transport is closing
2020/04/06 12:04:35 [TRACE] <root>: eval: *terraform.EvalMaybeTainted
2020/04/06 12:04:35 [TRACE] EvalMaybeTainted: ovirt_image_transfer.fcos_transfer encountered an error during creation, so it is now marked as tainted
2020/04/06 12:04:35 [TRACE] <root>: eval: *terraform.EvalWriteState
2020/04/06 12:04:35 [TRACE] EvalWriteState: removing state object for ovirt_image_transfer.fcos_transfer
2020/04/06 12:04:35 [TRACE] <root>: eval: *terraform.EvalApplyProvisioners
2020/04/06 12:04:35 [TRACE] EvalApplyProvisioners: ovirt_image_transfer.fcos_transfer has no state, so skipping provisioners
2020/04/06 12:04:35 [TRACE] <root>: eval: *terraform.EvalMaybeTainted
2020/04/06 12:04:35 [TRACE] EvalMaybeTainted: ovirt_image_transfer.fcos_transfer encountered an error during creation, so it is now marked as tainted
2020/04/06 12:04:35 [TRACE] <root>: eval: *terraform.EvalWriteState
2020/04/06 12:04:35 [TRACE] EvalWriteState: removing state object for ovirt_image_transfer.fcos_transfer
2020/04/06 12:04:35 [TRACE] <root>: eval: *terraform.EvalIf
2020/04/06 12:04:35 [TRACE] <root>: eval: *terraform.EvalIf
2020/04/06 12:04:35 [TRACE] <root>: eval: *terraform.EvalWriteDiff
2020/04/06 12:04:35 [TRACE] <root>: eval: *terraform.EvalApplyPost
2020/04/06 12:04:35 [ERROR] <root>: eval: *terraform.EvalApplyPost, err: rpc error: code = Unavailable desc = transport is closing
2020/04/06 12:04:35 [ERROR] <root>: eval: *terraform.EvalSequence, err: rpc error: code = Unavailable desc = transport is closing
2020/04/06 12:04:35 [TRACE] [walkApply] Exiting eval tree: ovirt_image_transfer.fcos_transfer
2020/04/06 12:04:35 [TRACE] vertex "ovirt_image_transfer.fcos_transfer": visit complete
2020/04/06 12:04:35 [TRACE] dag/walk: upstream of "ovirt_vm.tmpvm" errored, so skipping
2020/04/06 12:04:35 [TRACE] dag/walk: upstream of "ovirt_template.fcos_template" errored, so skipping
2020/04/06 12:04:35 [TRACE] dag/walk: upstream of "provider.ovirt (close)" errored, so skipping
2020/04/06 12:04:35 [TRACE] dag/walk: upstream of "meta.count-boundary (EachMode fixup)" errored, so skipping
2020/04/06 12:04:35 [TRACE] dag/walk: upstream of "root" errored, so skipping
2020/04/06 12:04:35 [TRACE] statemgr.Filesystem: creating backup snapshot at terraform.tfstate.backup
2020/04/06 12:04:35 [TRACE] statemgr.Filesystem: state has changed since last snapshot, so incrementing serial to 3
2020/04/06 12:04:35 [TRACE] statemgr.Filesystem: writing snapshot at terraform.tfstate
2020/04/06 12:04:35 [TRACE] statemgr.Filesystem: removing lock metadata file .terraform.tfstate.lock.info
2020/04/06 12:04:35 [TRACE] statemgr.Filesystem: unlocking terraform.tfstate using fcntl flock
2020-04-06T12:04:35.537+0200 [DEBUG] plugin: plugin exited

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

Terraform crashed! This is always indicative of a bug within Terraform.
A crash log has been placed at "crash.log" relative to your current
working directory. It would be immensely helpful if you could please
report the crash with Terraform[1] so that we can fix this.

When reporting bugs, please include your terraform version. That
information is available on the first line of crash.log. You can also
get it by running 'terraform --version' on the command line.

SECURITY WARNING: the "crash.log" file that was created may contain 
sensitive information that must be redacted before it is safe to share 
on the issue tracker.

[1]: https://github.com/hashicorp/terraform/issues

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!
rgolangh commented 4 years ago

this is a nasty unchecked error in the code, while trying to run OPTIONS http request to your host url. I guess your host isn't directly accesible from where you running tf.

duritong commented 4 years ago

Yeah, the engine is, the host itself aren't but I can make them available.

Thanks for the pointers, I recall something like that. I try terraform from a different place, than my usual uploads, so could be that now we have a missing firewall setting.

rgolangh commented 4 years ago

Please review #206

duritong commented 4 years ago

Success to transfer the image with 160de6e4a2963116ed0cef286742a398517d2882 - Firewall had always 443 and 54323 open to the engine. I don't think more is needed? https://access.redhat.com/documentation/en-us/red_hat_virtualization/4.3/html/planning_and_prerequisites_guide/rhv_requirements

$ terraform apply
data.ovirt_clusters.clusters: Refreshing state...

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # ovirt_image_transfer.fcos_transfer will be created
  + resource "ovirt_image_transfer" "fcos_transfer" {
      + alias             = "fcos31"
      + disk_id           = (known after apply)
      + id                = (known after apply)
      + source_url        = "/tmp/fedora-coreos-31.20200210.3.0-openstack.x86_64.qcow2"
      + sparse            = true
      + storage_domain_id = "d3d21d97-3ec9-4b37-b0e0-f94f0851d808"
    }

  # ovirt_template.fcos_template will be created
  + resource "ovirt_template" "fcos_template" {
      + clone             = false
      + cluster_id        = "7ceaf68d-09b5-4015-9444-7cdfcdd81aef"
      + cores             = 1
      + high_availability = false
      + id                = (known after apply)
      + name              = "template-for-fcos31"
      + sockets           = 1
      + status            = (known after apply)
      + threads           = 1
      + vm_id             = (known after apply)
    }

  # ovirt_vm.tmpvm will be created
  + resource "ovirt_vm" "tmpvm" {
      + clone             = false
      + cluster_id        = "7ceaf68d-09b5-4015-9444-7cdfcdd81aef"
      + cores             = 1
      + high_availability = false
      + id                = (known after apply)
      + name              = "tmpvm-for-fcos31"
      + sockets           = 1
      + status            = (known after apply)
      + template_id       = "00000000-0000-0000-0000-000000000000"
      + threads           = 1

      + block_device {
          + active               = true
          + disk_id              = (known after apply)
          + interface            = "virtio_scsi"
          + read_only            = false
          + use_scsi_reservation = false
        }
    }

Plan: 3 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

ovirt_image_transfer.fcos_transfer: Creating...
ovirt_image_transfer.fcos_transfer: Still creating... [10s elapsed]
ovirt_image_transfer.fcos_transfer: Still creating... [20s elapsed]
ovirt_image_transfer.fcos_transfer: Still creating... [30s elapsed]
ovirt_image_transfer.fcos_transfer: Still creating... [40s elapsed]
ovirt_image_transfer.fcos_transfer: Still creating... [50s elapsed]
ovirt_image_transfer.fcos_transfer: Still creating... [1m0s elapsed]
ovirt_image_transfer.fcos_transfer: Still creating... [1m10s elapsed]
ovirt_image_transfer.fcos_transfer: Still creating... [1m20s elapsed]
ovirt_image_transfer.fcos_transfer: Still creating... [1m30s elapsed]
ovirt_image_transfer.fcos_transfer: Still creating... [1m40s elapsed]
ovirt_image_transfer.fcos_transfer: Still creating... [1m50s elapsed]
ovirt_image_transfer.fcos_transfer: Still creating... [2m0s elapsed]
ovirt_image_transfer.fcos_transfer: Still creating... [2m10s elapsed]
ovirt_image_transfer.fcos_transfer: Still creating... [2m20s elapsed]
ovirt_image_transfer.fcos_transfer: Still creating... [2m30s elapsed]
ovirt_image_transfer.fcos_transfer: Still creating... [2m40s elapsed]
ovirt_image_transfer.fcos_transfer: Still creating... [2m50s elapsed]
ovirt_image_transfer.fcos_transfer: Still creating... [3m0s elapsed]
ovirt_image_transfer.fcos_transfer: Still creating... [3m10s elapsed]
ovirt_image_transfer.fcos_transfer: Still creating... [3m20s elapsed]
ovirt_image_transfer.fcos_transfer: Still creating... [3m30s elapsed]
ovirt_image_transfer.fcos_transfer: Still creating... [3m40s elapsed]
ovirt_image_transfer.fcos_transfer: Still creating... [3m50s elapsed]
ovirt_image_transfer.fcos_transfer: Still creating... [4m0s elapsed]
ovirt_image_transfer.fcos_transfer: Still creating... [4m10s elapsed]
ovirt_image_transfer.fcos_transfer: Creation complete after 4m17s [id=f3b95c1d-ae98-45dd-b3f3-35993471baae]
ovirt_vm.tmpvm: Creating...
ovirt_vm.tmpvm: Still creating... [10s elapsed]
ovirt_vm.tmpvm: Still creating... [20s elapsed]
ovirt_vm.tmpvm: Still creating... [30s elapsed]
ovirt_vm.tmpvm: Still creating... [40s elapsed]
ovirt_vm.tmpvm: Still creating... [50s elapsed]
ovirt_vm.tmpvm: Still creating... [1m0s elapsed]
ovirt_vm.tmpvm: Still creating... [1m10s elapsed]
ovirt_vm.tmpvm: Still creating... [1m20s elapsed]
ovirt_vm.tmpvm: Still creating... [1m30s elapsed]
ovirt_vm.tmpvm: Creation complete after 1m37s [id=36c0037b-3aaa-4ed5-b344-dc61f1a7cfa3]
ovirt_template.fcos_template: Creating...
ovirt_template.fcos_template: Still creating... [10s elapsed]
ovirt_template.fcos_template: Still creating... [20s elapsed]
ovirt_template.fcos_template: Still creating... [30s elapsed]
ovirt_template.fcos_template: Still creating... [40s elapsed]
ovirt_template.fcos_template: Still creating... [50s elapsed]
ovirt_template.fcos_template: Still creating... [1m0s elapsed]
ovirt_template.fcos_template: Still creating... [1m10s elapsed]
ovirt_template.fcos_template: Still creating... [1m20s elapsed]
ovirt_template.fcos_template: Still creating... [1m30s elapsed]
ovirt_template.fcos_template: Creation complete after 1m33s [id=2de0ceb9-1011-47e8-8fa9-b4c78f2be624]

Apply complete! Resources: 3 added, 0 changed, 0 destroyed.