Skip to content

Commit

Permalink
r/vmfs_datastore: Better error messages
Browse files Browse the repository at this point in the history
Quoted most entities, and also provided better context for whole disk
selection error messages.
  • Loading branch information
vancluever committed Sep 1, 2017
1 parent c118a4d commit 15c9b9a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions vsphere/host_data_store_system_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func diskSpecForCreate(dss *object.HostDatastoreSystem, name string) (*types.Vmf
defer cancel()
options, err := dss.QueryVmfsDatastoreCreateOptions(ctx, disk.DevicePath)
if err != nil {
return nil, fmt.Errorf("could not get disk creation options for %s: %s", name, err)
return nil, fmt.Errorf("could not get disk creation options for %q: %s", name, err)
}
var option *types.VmfsDatastoreOption
for _, o := range options {
Expand All @@ -68,7 +68,7 @@ func diskSpecForCreate(dss *object.HostDatastoreSystem, name string) (*types.Vmf
}
}
if option == nil {
return nil, fmt.Errorf("cannot use entire disk on device %s for datastore", name)
return nil, fmt.Errorf("device %q is not available as a new whole-disk device for datastore", name)
}
return option.Spec.(*types.VmfsDatastoreCreateSpec), nil
}
Expand All @@ -83,11 +83,16 @@ func diskSpecForExtend(dss *object.HostDatastoreSystem, ds *object.Datastore, na
return nil, err
}

props, err := datastoreProperties(ds)
if err != nil {
return nil, fmt.Errorf("error getting properties for datastore ID %q: %s", ds.Reference().Value, err)
}

ctx, cancel := context.WithTimeout(context.Background(), defaultAPITimeout)
defer cancel()
options, err := queryVmfsDatastoreExtendOptions(ctx, dss, ds, disk.DevicePath, true)
if err != nil {
return nil, fmt.Errorf("could not get disk extension options for %s: %s", name, err)
return nil, fmt.Errorf("could not get disk extension options for %q: %s", name, err)
}
var option *types.VmfsDatastoreOption
for _, o := range options {
Expand All @@ -97,7 +102,7 @@ func diskSpecForExtend(dss *object.HostDatastoreSystem, ds *object.Datastore, na
}
}
if option == nil {
return nil, fmt.Errorf("cannot use entire disk on device %s for datastore", name)
return nil, fmt.Errorf("device %q cannot be used as a new whole-disk device for datastore %q", name, props.Summary.Name)
}
return option.Spec.(*types.VmfsDatastoreExtendSpec), nil
}
Expand Down

0 comments on commit 15c9b9a

Please sign in to comment.