diff --git a/api/handler/plugin.go b/api/handler/plugin.go index 483495ad1..76809b244 100644 --- a/api/handler/plugin.go +++ b/api/handler/plugin.go @@ -96,7 +96,20 @@ func (p *PluginAction) UpdatePluginAct(pluginID, tenantID string, cps *api_model //DeletePluginAct DeletePluginAct func (p *PluginAction) DeletePluginAct(pluginID, tenantID string) *util.APIHandleError { tx := db.GetManager().Begin() - err := db.GetManager().TenantPluginDaoTransactions(tx).DeletePluginByID(pluginID, tenantID) + //step1: delete service plugin relation + err := db.GetManager().TenantServicePluginRelationDaoTransactions(tx).DeleteALLRelationByPluginID(pluginID) + if err != nil { + tx.Rollback() + return util.CreateAPIHandleErrorFromDBError("delete plugin relation", err) + } + //step2: delete plugin build version + err = db.GetManager().TenantPluginBuildVersionDaoTransactions(tx).DeleteBuildVersionByPluginID(pluginID) + if err != nil { + tx.Rollback() + return util.CreateAPIHandleErrorFromDBError("delete plugin build version", err) + } + //step3: delete plugin + err = db.GetManager().TenantPluginDaoTransactions(tx).DeletePluginByID(pluginID, tenantID) if err != nil { tx.Rollback() return util.CreateAPIHandleErrorFromDBError("delete plugin", err) diff --git a/db/mysql/dao/plugin.go b/db/mysql/dao/plugin.go index ad949589f..702b2fd2a 100644 --- a/db/mysql/dao/plugin.go +++ b/db/mysql/dao/plugin.go @@ -64,10 +64,8 @@ func (t *PluginDaoImpl) GetPluginByID(id, tenantID string) (*model.TenantPlugin, //DeletePluginByID DeletePluginByID func (t *PluginDaoImpl) DeletePluginByID(id, tenantID string) error { - relation := &model.TenantPlugin{ - PluginID: id, - } - if err := t.DB.Where("plugin_id=? and tenant_id=?", id, tenantID).Delete(relation).Error; err != nil { + var plugin model.TenantPlugin + if err := t.DB.Where("plugin_id=? and tenant_id=?", id, tenantID).Delete(&plugin).Error; err != nil { return err } return nil diff --git a/node/masterserver/node/nodecluster.go b/node/masterserver/node/nodecluster.go index ed72a2fce..a0affccc1 100644 --- a/node/masterserver/node/nodecluster.go +++ b/node/masterserver/node/nodecluster.go @@ -137,6 +137,7 @@ func (n *NodeCluster) UpdateNode(node *model.HostNode) { n.nodes[node.ID] = node n.client.Put(option.Config.NodePath+"/"+node.ID, node.String()) } + func (n *NodeCluster) getNodeFromKV(kv *mvccpb.KeyValue) *model.HostNode { var node model.HostNode if err := ffjson.Unmarshal(kv.Value, &node); err != nil {