From 0af31b5e508faa227a36e687346e7905a7a10ed6 Mon Sep 17 00:00:00 2001 From: Eric Multanen Date: Thu, 2 Jul 2020 15:34:13 -0700 Subject: Add terminate support to orchestrator and ncm Complete the basic terminate support for the orchestrator and ncm services. 1. When terminate REST API is invoked on a deployment intent group, call the uninstall grpc api to rsync and then remove the app context. 2. When terminate REST API is invoked on a cluster, add the uninstall grpc api call to rsync to remove the network resources from the clusters. Issue-ID: MULTICLOUD-1040 Signed-off-by: Eric Multanen Change-Id: I181e891a8c7c973970af061f9ff07d80c3bb64f9 --- .../pkg/module/deployment_intent_groups.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src/orchestrator/pkg/module/deployment_intent_groups.go') diff --git a/src/orchestrator/pkg/module/deployment_intent_groups.go b/src/orchestrator/pkg/module/deployment_intent_groups.go index 3412a034..0decb68f 100644 --- a/src/orchestrator/pkg/module/deployment_intent_groups.go +++ b/src/orchestrator/pkg/module/deployment_intent_groups.go @@ -62,7 +62,7 @@ type OverrideValues struct { type DeploymentIntentGroupManager interface { CreateDeploymentIntentGroup(d DeploymentIntentGroup, p string, ca string, v string) (DeploymentIntentGroup, error) GetDeploymentIntentGroup(di string, p string, ca string, v string) (DeploymentIntentGroup, error) - GetDeploymentIntentGroupContext(di string, p string, ca string, v string) (appcontext.AppContext, error) + GetDeploymentIntentGroupContext(di string, p string, ca string, v string) (appcontext.AppContext, string, error) DeleteDeploymentIntentGroup(di string, p string, ca string, v string) error } @@ -165,7 +165,7 @@ func (c *DeploymentIntentGroupClient) GetDeploymentIntentGroup(di string, p stri } // GetDeploymentIntentGroup returns the DeploymentIntentGroup with a given name, project, compositeApp and version of compositeApp -func (c *DeploymentIntentGroupClient) GetDeploymentIntentGroupContext(di string, p string, ca string, v string) (appcontext.AppContext, error) { +func (c *DeploymentIntentGroupClient) GetDeploymentIntentGroupContext(di string, p string, ca string, v string) (appcontext.AppContext, string, error) { key := DeploymentIntentGroupKey{ Name: di, @@ -176,7 +176,7 @@ func (c *DeploymentIntentGroupClient) GetDeploymentIntentGroupContext(di string, result, err := db.DBconn.Find(c.storeName, key, c.tagContext) if err != nil { - return appcontext.AppContext{}, pkgerrors.Wrap(err, "Get DeploymentIntentGroup Context error") + return appcontext.AppContext{}, "", pkgerrors.Wrap(err, "Get DeploymentIntentGroup Context error") } if result != nil { @@ -184,12 +184,12 @@ func (c *DeploymentIntentGroupClient) GetDeploymentIntentGroupContext(di string, var cc appcontext.AppContext _, err = cc.LoadAppContext(ctxVal) if err != nil { - return appcontext.AppContext{}, pkgerrors.Wrap(err, "Error loading DeploymentIntentGroup Appcontext") + return appcontext.AppContext{}, "", pkgerrors.Wrap(err, "Error loading DeploymentIntentGroup Appcontext") } - return cc, nil + return cc, ctxVal, nil } - return appcontext.AppContext{}, pkgerrors.New("Error getting DeploymentIntentGroup AppContext") + return appcontext.AppContext{}, "", pkgerrors.New("Error getting DeploymentIntentGroup AppContext") } // DeleteDeploymentIntentGroup deletes a DeploymentIntentGroup @@ -200,10 +200,14 @@ func (c *DeploymentIntentGroupClient) DeleteDeploymentIntentGroup(di string, p s CompositeApp: ca, Version: v, } + _, _, err := c.GetDeploymentIntentGroupContext(di, p, ca, v) + if err == nil { + return pkgerrors.Wrap(err, "DeploymentIntentGroup must be terminated before it can be deleted "+di) + } - err := db.DBconn.Remove(c.storeName, k) + err = db.DBconn.Remove(c.storeName, k) if err != nil { - return pkgerrors.Wrap(err, "Delete DeploymentIntentGroup entry;") + return pkgerrors.Wrap(err, "Error deleting DeploymentIntentGroup entry") } return nil -- cgit 1.2.3-korg