Skip to content
This repository has been archived by the owner on Jul 16, 2020. It is now read-only.

Commit

Permalink
ciao-controller: datastore.GetStorageAttachments cannot return an error
Browse files Browse the repository at this point in the history
The prototype returns an error but there is no way for this code to
generate an error so modify the prototype and users not to generate an
error.

Fixes: #1008

Signed-off-by: Rob Bradford <[email protected]>
  • Loading branch information
rbradford committed Jan 18, 2017
1 parent 1bcf6b0 commit 0bc450a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 15 deletions.
2 changes: 1 addition & 1 deletion ciao-controller/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (client *ssntpClient) CommandNotify(command ssntp.Command, frame *ssntp.Fra
}

func (client *ssntpClient) deleteEphemeralStorage(instanceID string) {
attachments, _ := client.ctl.ds.GetStorageAttachments(instanceID)
attachments := client.ctl.ds.GetStorageAttachments(instanceID)
for _, attachment := range attachments {
if !attachment.Ephemeral {
continue
Expand Down
4 changes: 2 additions & 2 deletions ciao-controller/internal/datastore/datastore.go
Original file line number Diff line number Diff line change
Expand Up @@ -1615,7 +1615,7 @@ func (ds *Datastore) CreateStorageAttachment(instanceID string, volume payloads.
}

// GetStorageAttachments returns a list of volumes associated with this instance.
func (ds *Datastore) GetStorageAttachments(instanceID string) ([]types.StorageAttachment, error) {
func (ds *Datastore) GetStorageAttachments(instanceID string) []types.StorageAttachment {
var links []types.StorageAttachment

ds.attachLock.RLock()
Expand All @@ -1626,7 +1626,7 @@ func (ds *Datastore) GetStorageAttachments(instanceID string) ([]types.StorageAt
}
ds.attachLock.RUnlock()

return links, nil
return links
}

func (ds *Datastore) updateStorageAttachments(instanceID string, volumes []string) {
Expand Down
10 changes: 2 additions & 8 deletions ciao-controller/internal/datastore/datastore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1705,10 +1705,7 @@ func TestCreateStorageAttachment(t *testing.T) {
}

// get the attachments associated with this instance
a1, err := ds.GetStorageAttachments(instance.ID)
if err != nil {
t.Fatal(err)
}
a1 := ds.GetStorageAttachments(instance.ID)

if len(a1) != 1 {
t.Fatal(err)
Expand Down Expand Up @@ -1766,10 +1763,7 @@ func TestUpdateStorageAttachmentExisting(t *testing.T) {
}

// get the attachments associated with this instance
a1, err := ds.GetStorageAttachments(instance.ID)
if err != nil {
t.Fatal(err)
}
a1 := ds.GetStorageAttachments(instance.ID)

if len(a1) != 1 {
t.Fatal(err)
Expand Down
5 changes: 1 addition & 4 deletions ciao-controller/openstack_compute.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ func instanceToServer(ctl *controller, instance *types.Instance) (compute.Server

var volumes []string

instance.Attachments, err = ctl.ds.GetStorageAttachments(instance.ID)
if err != nil {
return compute.ServerDetails{}, err
}
instance.Attachments = ctl.ds.GetStorageAttachments(instance.ID)

for _, vol := range instance.Attachments {
volumes = append(volumes, vol.BlockID)
Expand Down

0 comments on commit 0bc450a

Please sign in to comment.