Skip to content

New compute methods for vSphere, storage operations by instance ID, misc vSphere fixes#23

Open
harsh-px wants to merge 2 commits intolibopenstorage:masterfrom
harsh-px:shared-vmdk
Open

New compute methods for vSphere, storage operations by instance ID, misc vSphere fixes#23
harsh-px wants to merge 2 commits intolibopenstorage:masterfrom
harsh-px:shared-vmdk

Conversation

@harsh-px
Copy link
Copy Markdown

@harsh-px harsh-px commented Aug 8, 2019

  • Fix error types for vSphere when disk is not attached
  • Add InspectInstance implementation for vSphere
  • Add new methods, ListInstances, CreateInstance, AttachByInstanceID
  • DeviceMappings can now be done by instance ID
  • Remove timeout from DeleteInstance. Callers should use exponentional backoff instead
  • Add attach options to Attach method

Signed-off-by: Harsh Desai harsh@portworx.com

@harsh-px harsh-px self-assigned this Aug 8, 2019
@harsh-px harsh-px added the enhancement New feature or request label Aug 8, 2019
…isc vSphere fixes

- Fix error types for vSphere when disk is not attached
- Add InspectInstance implementation for vSphere
- Add new methods, ListInstances, CreateInstance, AttachByInstanceID
- DeviceMappings can now be done by instance ID
- Remove timeout from DeleteInstance. Callers should use exponentional backoff instead
- Add attach options to Attach method

Signed-off-by: Harsh Desai <harsh@portworx.com>
Signed-off-by: Harsh Desai <harsh@portworx.com>
@adityadani
Copy link
Copy Markdown
Contributor

Can you split the vendor code and the actual cloudops changes into different commits ?

Comment thread aws/aws.go
err error
)

if len(instanceID) == 0 {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we should define a constant Local and error out if instanceID is empty.
The API is confusing when there is added intelligence if a param is not given.
You can also just add a new API like the other ones - DeviceMappingsForInstance

Comment thread cloudops.go
// GetDeviceID returns ID/Name of the given device/disk or snapshot
GetDeviceID(template interface{}) (string, error)
// Attach volumeID.
// options are passthough options given to the cloud provider
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: passthrough

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

also at other places.

Comment thread gce/gce.go
}

_, err = task.DoRetryWithTimeout(f, timeout, retrySeconds*time.Second)
_, err = task.DoRetryWithTimeout(f, 2*time.Minute, retrySeconds*time.Second)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: add this as a constant.

Comment thread test/cloudops.go
require.NotNil(t, info, "got nil instance info from inspect")
require.NotEmpty(t, info.Zone, "inspect must returns instance zone")

instances, err = driver.ListInstances(&cloudops.ListInstancesOpts{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can add a UT using LabelSelectors

Comment thread vsphere/vsphere.go
StoragePod string
// Datastore is the VMFS datastore to use for the VM
Datastore string
// ResourcePool is the resource pool to use to place to VM
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: ResourcePool is the resource pool where the VM is placed

Comment thread vsphere/vsphere.go
return folder, nil
}

func (ops *vsphereOps) getFinderAndDC(ctx context.Context, datacenter string) (
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit:

Suggested change
func (ops *vsphereOps) getFinderAndDC(ctx context.Context, datacenter string) (
func (ops *vsphereOps) getFinderAndDC(
ctx context.Context,
datacenter string,
) (*find.Finder, *object.Datacenter, error) {

Comment thread vsphere/vsphere.go
}

func (ops *vsphereOps) ListInstances(opts *cloudops.ListInstancesOpts) (
[]*cloudops.InstanceInfo, error) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit:

Suggested change
[]*cloudops.InstanceInfo, error) {
func (ops *vsphereOps) ListInstances(
opts *cloudops.ListInstancesOpts,
) ([]*cloudops.InstanceInfo, error) {

Comment thread vsphere/vsphere.go

var datacenter string
if opts != nil && opts.LabelSelector != nil {
datacenter = opts.LabelSelector["datacenter"]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: "datacenter" seems to be used at multiple places. It can be a constant.

Comment thread vsphere/vsphere.go
return false, err
}

return o.Runtime.ConnectionState != "invalid", nil
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Aren't there any constants defined in vsphere library for such states?

Comment thread vsphere/vsphere.go
return o.Config.Name, nil
}

// We treat a VM's zone as the vSphere cluster in which the vm resizes.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit:

Suggested change
// We treat a VM's zone as the vSphere cluster in which the vm resizes.
// We treat a VM's zone as the vSphere cluster in which the vm resides.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants