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

[WIP] vSphere provider support for SDRS with storage pods #7031

Closed
wants to merge 23 commits into from

Conversation

chrislovecnm
Copy link
Contributor

This is working for a couple of use cases, but getting errors with multiple disks.

@chrislovecnm
Copy link
Contributor Author

@markpeek @thetuxkeeper @dkalleg @dougm

I am getting the following error running any test that has two disks, when I use a storagepod with DRS. The example code that I have with govc only does a single disk at a time, and I have no idea what is causing this error. I have the recommended datastore, and the intial disk is working. Also the tests with multiple disks using a non-drs datastore, work.

resource_vsphere_virtual_machine.go:1277: [DEBUG] addHardDisk - diskPath: [.] terraform-test/two
resource_vsphere_virtual_machine.go:1281: [DEBUG] disk: &types.VirtualDisk{VirtualDevice:types.VirtualDevice{DynamicData:types.DynamicData{}, Key:-1, DeviceInfo:types.BaseDescription(nil), Backing:(*types.VirtualDiskFlatVer2BackingInfo)(0xc8202f05b0), Connectable:(*types.VirtualDeviceConnectInfo)(nil), SlotInfo:types.BaseVirtualDeviceBusSlotInfo(nil), ControllerKey:1000, UnitNumber:(*int32)(0xc8202cf3c8)}, CapacityInKB:0, CapacityInBytes:0, Shares:(*types.SharesInfo)(nil), StorageIOAllocation:(*types.StorageIOAllocationInfo)(nil), DiskObjectId:"", VFlashCacheConfigInfo:(*types.VirtualDiskVFlashCacheConfigInfo)(nil), Iofilter:[]string(nil)}
resource_vsphere_virtual_machine.go:1301: [DEBUG] addHardDisk: &{{{} %!s(int32=-1) <nil> %!s(*types.VirtualDiskFlatVer2BackingInfo=&{{{{}} [.] terraform-test/two.vmdk 0xc8201b2080 } persistent <nil> <nil> 0xc8202cf550 0xc8202cf551    <nil>  <nil> 0  }) %!s(*types.VirtualDeviceConnectInfo=<nil>) <nil> %!s(int32=1000) %!s(*int32=0xc8202cf3c8)} %!s(int64=1048576) %!s(int64=0) %!s(*types.SharesInfo=<nil>) %!s(*types.StorageIOAllocationInfo=&{{} 500 <nil> 0})  %!s(*types.VirtualDiskVFlashCacheConfigInfo=<nil>) []}
resource_vsphere_virtual_machine.go:1302: [DEBUG] addHardDisk capacity: 1048576
dag.go:210: [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.foo
eval.go:52: [DEBUG] root: eval: *terraform.EvalWriteState
eval.go:52: [DEBUG] root: eval: *terraform.EvalApplyProvisioners
eval.go:52: [DEBUG] root: eval: *terraform.EvalIf
eval.go:52: [DEBUG] root: eval: *terraform.EvalWriteState
eval.go:52: [DEBUG] root: eval: *terraform.EvalWriteDiff
eval.go:52: [DEBUG] root: eval: *terraform.EvalApplyPost
eval.go:58: [ERROR] root: eval: *terraform.EvalApplyPost, err: 1 error(s) occurred:

* vsphere_virtual_machine.foo: Invalid datastore path '[.] terraform-test/two.vmdk'.
eval.go:58: [ERROR] root: eval: *terraform.EvalSequence, err: 1 error(s) occurred:

The following call is failing. Ideas?

return vm.AddDevice(context.TODO(), disk)

@thetuxkeeper
Copy link
Contributor

Why is there a dot as datastore name? Is that correct? (don't know SDRS and if there's a special naming)

@chrislovecnm
Copy link
Contributor Author

chrislovecnm commented Jun 6, 2016

@thetuxkeeper I am just using our old code with the new way to look up recommended datastores with DRS ... don't know.

btw there is my TF from testing;

template config=
resource "vsphere_virtual_machine" "foo" {
    name = "terraform-test"
    use_sdrs = true

    datacenter = "Engpipeline Datacenter"
    cluster = "Engpipeline-cluster"

    vcpu = 2
    memory = 1024
    network_interface {
        label = "VM-vlan409"
        ipv4_address = "10.192.71.172"
        ipv4_prefix_length = 24
        ipv4_gateway = "10.192.71.1"
    }
     disk {
        datastore = "BEL-SDRS-VMAX1789-POOL01"

        template = "centos-clove-tpl"
        iops = 500
    }

    disk {
        size = 1
        iops = 500
        datastore = "BEL-SDRS-VMAX1789-POOL01"

    name = "two"
    }

}

Error:

--- FAIL: TestAccVSphereVirtualMachine_updateDRSDisks (24.34s)
    testing.go:247: Step 0 error: Error applying: 1 error(s) occurred:

        * vsphere_virtual_machine.foo: Invalid datastore path '[.] terraform-test/two.vmdk'.
FAIL
exit status 1
FAIL    github.com/hashicorp/terraform/builtin/providers/vsphere    24.362s
make: *** [testacc] Error 1

@chrislovecnm
Copy link
Contributor Author

@thetuxkeeper I assume it is the . in the vmdk name ... only a gues.

@chrislovecnm
Copy link
Contributor Author

chrislovecnm commented Jun 7, 2016

@dougm @markpeek here is what I am at

The code we are using matches the code used in govc's vm.disk.create. I have not figured out how to use vm.disk.create, so I have not recreated it. Probably next on my todo ...

When I am adding a new non-drs disk we call

disk := devices.CreateDisk(controller, datastore.Reference(), diskPath)

Where

diskPath := "[BEL-5798813-EMC-VMAX1789-LUN-06] terraform-test/one"

This is calculated with

diskPath = fmt.Sprintf("[%v] %v", datastore.Name(), diskPath)

When datastore is a managed reference using DRS datastore.Name() is not populated. datastore.Reference().Value is populated, but that value does not work.

How do I get the correct value for the govomi api method CreateDisk, or does CreateDisk support using storage pods?

Also this does not work either

diskPath := "[BEL-SDRS-VMAX1789-POOL01] terraform-test/two.vmdk"

@dougm
Copy link

dougm commented Jun 7, 2016

@chrislovecnm haven't had a chance to look yet, I'll try to get to it by tomorrow

@chrislovecnm
Copy link
Contributor Author

Thanks @dougm

@chrislovecnm
Copy link
Contributor Author

@dougm ping

@chrislovecnm
Copy link
Contributor Author

@dougm good news is that I figured it out :)

@dougm
Copy link

dougm commented Jun 10, 2016

great news @chrislovecnm

@chrislovecnm
Copy link
Contributor Author

@markpeek @stack72 @jen20 @thetuxkeeper @dkalleg ~ can I get a code review? I have a couple of unit tests that are failing ... Don't think I broke the other tests, but I will get them happy regardless, but the code is at a good please to review :)

Do you think we should start breaking apart the testing into separate files? For instance very few developers will be able to run the SDRS unit tests.

@chrislovecnm
Copy link
Contributor Author

Thanks Daniel, yah a lot of shops do not have enterprise installed

@mixacha
Copy link
Contributor

mixacha commented Jun 13, 2016

@chrislovecnm is the testingg doc up to date? I'll build and run tests tomorrow, ive got 5.5u3 and 6.0 latest u environments.

@chrislovecnm
Copy link
Contributor Author

@mixacha the tests will now print to stdout if the are skipped. Let me know if you have questions about the ENV vars.

Thanks

Chris

@chrislovecnm
Copy link
Contributor Author

chrislovecnm commented Jun 13, 2016

@mixacha here are my testing ENV vars https://gist.github.com/chrislovecnm/bf43c64a6e64a00cc2e533dbca5035ee - btw I have tested against 5.5

@chrislovecnm
Copy link
Contributor Author

chrislovecnm commented Jun 13, 2016

@jen20 @stack72 @phinze all my tests are passing, and @mixacha offered to test locally. How soon is 0.7?

We have new test that I created that uncovered an existing bug.

FAIL: TestAccVSphereVirtualMachine_createWithNewVmdk (234.21s)

Also tests are now skipping or failing more gracefully. For posterity https://gist.github.com/chrislovecnm/474fe0c5862386c1349739f7a7553cc3

@chrislovecnm
Copy link
Contributor Author

@mixacha you get a chance to test?

@mixacha
Copy link
Contributor

mixacha commented Jun 15, 2016

@chrislovecnm I'm setting up the environment at the moment, was too busy with regular schedule yesterday.

@mixacha
Copy link
Contributor

mixacha commented Jun 15, 2016

Tests are running, I've observed that it keeps creating thick disks even in thin tests:

=== RUN TestAccVSphereVirtualMachine_diskInitType from debug log: eval_apply.go:66: [DEBUG] apply: vsphere_virtual_machine.thin: executing Apply resource_vsphere_virtual_machine.go:869: [DEBUG] network_interface init: [{ mng 10.5.251.200 24 10.5.250.1 0 }] resource_vsphere_virtual_machine.go:902: [DEBUG] reading disk info: map[uuid: datastore: use_sdrs:%!s(bool=false) vmdk: bootable:%!s(bool=false) type:eager_zeroed name:two keep_on_remove:%!s(bool=false) iops:%!s(int=0) key:%!s(int=0) template: controller_type:ide size:%!s(int=1)] resource_vsphere_virtual_machine.go:992: [DEBUG] disk init: {two 1 0 eager_zeroed ide false false } resource_vsphere_virtual_machine.go:902: [DEBUG] reading disk info: map[template:Templates/Linux/CentOS_6_x86_64 type:eager_zeroed name: key:%!s(int=0) iops:%!s(int=500) vmdk: controller_type:scsi datastore:RG0-LUN0 use_sdrs:%!s(bool=false) size:%!s(int=0) bootable:%!s(bool=false) keep_on_remove:%!s(bool=false) uuid:]

@chrislovecnm
Copy link
Contributor Author

Which tests? Is this a new behavior?

@mixacha
Copy link
Contributor

mixacha commented Jun 15, 2016

@chrislovecnm I think it's old behavior if you use different disk types in same virtual machine, terraform will apply last virtual machine disk type to all.

TestAccVSphereVirtualMachine_diskInitType and pretty much any other VM related test that adds additional disks.

@mixacha
Copy link
Contributor

mixacha commented Jun 15, 2016

const testAccCheckVSphereVirtualMachineConfig_initType =
resource "vsphere_virtual_machine" "thin" {
name = "terraform-test"
+ testAccTemplateBasicBody +
disk {
size = 1
iops = 500
controller_type = "scsi"
name = "one"
}
disk {
size = 1
controller_type = "ide"
type = "eager_zeroed"
name = "two"
}
}
``

I believe this is where one of problem lies, we're adding a thin disk but init_type for virtual machine resource defaults to eager_zeroed. Sorry I'm not of a big help, I need to get my gofu up to date.

@mixacha
Copy link
Contributor

mixacha commented Jun 15, 2016

Full test output : vsphere 6.0 https://gist.github.com/mixacha/8d8d7f1bd6176a57a9969139f7a6e279

@chrislovecnm
Copy link
Contributor Author

@mixacha you have DHCP setup by any chance? A bunch of those tests are bailing because of that. Also can you do the full debug output 😁

I want to get this stuff fixed :P

@mixacha
Copy link
Contributor

mixacha commented Jun 15, 2016

@chrislovecnm I'll setup a small box tomorrow to enable dhcp and post debug output afterwards.

@chrislovecnm
Copy link
Contributor Author

When yah do please run full debug logs.

@mixacha
Copy link
Contributor

mixacha commented Jun 16, 2016

@chrislovecnm gitst from my previous comment was updated with latest test results and debug.log attached. Do note that majority of tests create thick disks, that's why testing takes quite a while.

@chrislovecnm chrislovecnm changed the title vSphere provider support for SDRS with storage pods [WIP] vSphere provider support for SDRS with storage pods Jun 17, 2016
@chrislovecnm
Copy link
Contributor Author

need to verify that I have not introduced #7217

@twm1010
Copy link

twm1010 commented Jul 14, 2016

I can test this tomorrow sometime.


relocateSpec := types.VirtualMachineRelocateSpec{
DeviceChange: spds.ConfigSpecsNetwork,
Folder: &folderref,
Copy link
Contributor

Choose a reason for hiding this comment

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

where is the Folder parameter coming from, it is not defined in the VirtualMachineRelocateSpec:
https://www.vmware.com/support/developer/vc-sdk/visdk2xpubs/ReferenceGuide/vim.vm.RelocateSpec.html

@justinclayton
Copy link
Contributor

Any word on this getting reviewed and added?

@chrislovecnm
Copy link
Contributor Author

This is still WIP, tryin to see if and when we can get this done :(

@chrislovecnm
Copy link
Contributor Author

I am going to close this, but it will still be on my fork. If someone wants to pick this up, please let me know. I have not had client sponsored time to pick up this work, hopefully in the new year.

@ghost
Copy link

ghost commented Apr 21, 2020

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.

@ghost ghost locked and limited conversation to collaborators Apr 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants