Fix the inconsistency between the console and cluster data after opening the plug-in for the component

This commit is contained in:
yangk 2021-08-06 15:22:59 +08:00
parent 8af5fe8bff
commit 07dc0719b4

View File

@ -154,14 +154,22 @@ func (s *ServiceAction) SetTenantServicePluginRelation(tenantID, serviceID strin
tx.Rollback()
return nil, util.CreateAPIHandleErrorFromDBError("set service plugin env error ", err)
}
tsprCPU := pluginversion.ContainerCPU
tsprMemory := pluginversion.ContainerMemory
if pss.Body.PluginCPU != 0 {
tsprCPU = pss.Body.PluginCPU
}
if pss.Body.PluginMemory != 0 {
tsprMemory = pss.Body.PluginMemory
}
relation := &dbmodel.TenantServicePluginRelation{
VersionID: pss.Body.VersionID,
ServiceID: serviceID,
PluginID: pss.Body.PluginID,
Switch: pss.Body.Switch,
PluginModel: plugin.PluginModel,
ContainerCPU: pluginversion.ContainerCPU,
ContainerMemory: pluginversion.ContainerMemory,
ContainerCPU: tsprCPU,
ContainerMemory: tsprMemory,
}
if err := db.GetManager().TenantServicePluginRelationDaoTransactions(tx).AddModel(relation); err != nil {
tx.Rollback()