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

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

harsh-px
Copy link

@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 [email protected]

@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 <[email protected]>
Signed-off-by: Harsh Desai <[email protected]>
@adityadani
Copy link
Contributor

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

err error
)

if len(instanceID) == 0 {
Copy link
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

@@ -90,8 +94,13 @@ type Storage interface {
// 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
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
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.

@@ -408,7 +415,7 @@ func (s *gceOps) DeleteInstance(instanceID string, zone string, timeout time.Dur
instanceID, operation.Name, operation.Status)
}

_, err = task.DoRetryWithTimeout(f, timeout, retrySeconds*time.Second)
_, err = task.DoRetryWithTimeout(f, 2*time.Minute, retrySeconds*time.Second)
Copy link
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.

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
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

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
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

return folder, nil
}

func (ops *vsphereOps) getFinderAndDC(ctx context.Context, datacenter string) (
Copy link
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) {

}

func (ops *vsphereOps) ListInstances(opts *cloudops.ListInstancesOpts) (
[]*cloudops.InstanceInfo, error) {
Copy link
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) {


var datacenter string
if opts != nil && opts.LabelSelector != nil {
datacenter = opts.LabelSelector["datacenter"]
Copy link
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.

return false, err
}

return o.Runtime.ConnectionState != "invalid", nil
Copy link
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?

return o.Config.Name, nil
}

// We treat a VM's zone as the vSphere cluster in which the vm resizes.
Copy link
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