From ef58c108fc4f60c06cb8e06e1f750de9e6682ff1 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Tue, 22 Nov 2016 17:49:25 +0000 Subject: [PATCH] ciao-controller: Make CNCI storage ephemeral Refactor the instance launching code to make storage for the CNCI ephemeral so that it will be cleaned up when the CNCI is deleted. Fixes: #851 Signed-off-by: Rob Bradford --- ciao-controller/instance.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ciao-controller/instance.go b/ciao-controller/instance.go index 1fb084f06..35ebf009f 100644 --- a/ciao-controller/instance.go +++ b/ciao-controller/instance.go @@ -87,18 +87,18 @@ func newInstance(ctl *controller, tenantID string, workload *types.Workload) (*i } func (i *instance) Add() error { + ds := i.ctl.ds if i.CNCI == false { - ds := i.ctl.ds ds.AddInstance(&i.Instance) - storage := i.newConfig.sc.Start.Storage - if (storage != payloads.StorageResources{}) { - _, err := ds.CreateStorageAttachment(i.Instance.ID, storage.ID, storage.Ephemeral) - if err != nil { - glog.Error(err) - } - } } else { - i.ctl.ds.AddTenantCNCI(i.TenantID, i.ID, i.MACAddress) + ds.AddTenantCNCI(i.TenantID, i.ID, i.MACAddress) + } + storage := i.newConfig.sc.Start.Storage + if (storage != payloads.StorageResources{}) { + _, err := ds.CreateStorageAttachment(i.Instance.ID, storage.ID, storage.Ephemeral) + if err != nil { + glog.Error(err) + } } return nil