From 0bc450a983b62a4dc42934d7351da1788780430f Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Mon, 16 Jan 2017 15:22:46 +0000 Subject: [PATCH] ciao-controller: datastore.GetStorageAttachments cannot return an error 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 --- ciao-controller/client.go | 2 +- ciao-controller/internal/datastore/datastore.go | 4 ++-- ciao-controller/internal/datastore/datastore_test.go | 10 ++-------- ciao-controller/openstack_compute.go | 5 +---- 4 files changed, 6 insertions(+), 15 deletions(-) diff --git a/ciao-controller/client.go b/ciao-controller/client.go index f71ed7a28..ba15cf45f 100644 --- a/ciao-controller/client.go +++ b/ciao-controller/client.go @@ -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 diff --git a/ciao-controller/internal/datastore/datastore.go b/ciao-controller/internal/datastore/datastore.go index b80f68eb4..3417f2a9a 100644 --- a/ciao-controller/internal/datastore/datastore.go +++ b/ciao-controller/internal/datastore/datastore.go @@ -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() @@ -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) { diff --git a/ciao-controller/internal/datastore/datastore_test.go b/ciao-controller/internal/datastore/datastore_test.go index 0b19f9a2c..01656e890 100644 --- a/ciao-controller/internal/datastore/datastore_test.go +++ b/ciao-controller/internal/datastore/datastore_test.go @@ -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) @@ -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) diff --git a/ciao-controller/openstack_compute.go b/ciao-controller/openstack_compute.go index 183d14097..c35dc8035 100644 --- a/ciao-controller/openstack_compute.go +++ b/ciao-controller/openstack_compute.go @@ -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)