mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-12-18 13:29:03 +08:00
fix: Fixed the issue of database transfer failure to child nodes (#10906)
This commit is contained in:
parent
ec4533e7de
commit
c6fe487e46
1 changed files with 75 additions and 70 deletions
|
|
@ -134,17 +134,7 @@ var ToolKeys = map[string]uint{
|
|||
"minio": 9001,
|
||||
}
|
||||
|
||||
func createLink(ctx context.Context, installTask *task.Task, app model.App, appInstall *model.AppInstall, params map[string]interface{}) error {
|
||||
deleteAppLink := func(t *task.Task) {
|
||||
del := dto.DelAppLink{
|
||||
Ctx: ctx,
|
||||
Install: appInstall,
|
||||
ForceDelete: true,
|
||||
}
|
||||
_ = deleteLink(del)
|
||||
}
|
||||
if DatabaseKeys[app.Key] > 0 {
|
||||
handleDataBaseApp := func(task *task.Task) error {
|
||||
func CreateDB(ctx context.Context, app model.App, appInstall *model.AppInstall, params map[string]interface{}) error {
|
||||
database := &model.Database{
|
||||
AppInstallID: appInstall.ID,
|
||||
Name: appInstall.Name,
|
||||
|
|
@ -158,7 +148,6 @@ func createLink(ctx context.Context, installTask *task.Task, app model.App, appI
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
formFields := &dto.AppForm{}
|
||||
if err := json.Unmarshal([]byte(detail.Params), formFields); err != nil {
|
||||
return err
|
||||
|
|
@ -214,6 +203,20 @@ func createLink(ctx context.Context, installTask *task.Task, app model.App, appI
|
|||
}
|
||||
return databaseRepo.Create(ctx, database)
|
||||
}
|
||||
|
||||
func createLink(ctx context.Context, installTask *task.Task, app model.App, appInstall *model.AppInstall, params map[string]interface{}) error {
|
||||
deleteAppLink := func(t *task.Task) {
|
||||
del := dto.DelAppLink{
|
||||
Ctx: ctx,
|
||||
Install: appInstall,
|
||||
ForceDelete: true,
|
||||
}
|
||||
_ = deleteLink(del)
|
||||
}
|
||||
if DatabaseKeys[app.Key] > 0 {
|
||||
handleDataBaseApp := func(task *task.Task) error {
|
||||
return CreateDB(ctx, app, appInstall, params)
|
||||
}
|
||||
installTask.AddSubTask(i18n.GetMsgByKey("HandleDatabaseApp"), handleDataBaseApp, deleteAppLink)
|
||||
}
|
||||
if ToolKeys[app.Key] > 0 {
|
||||
|
|
@ -2135,16 +2138,18 @@ func needsUpdate(localTag *model.Tag, remoteTag dto.Tag, translations string) bo
|
|||
|
||||
func hasLinkDB(installID uint) bool {
|
||||
resources, _ := appInstallResourceRepo.GetBy(appInstallResourceRepo.WithAppInstallId(installID))
|
||||
hasDB := false
|
||||
if len(resources) > 0 {
|
||||
for _, resource := range resources {
|
||||
if resource.Key == constant.AppPostgres || resource.Key == constant.AppMysql ||
|
||||
resource.Key == constant.AppMariaDB || resource.Key == constant.AppMysqlCluster ||
|
||||
resource.Key == constant.AppPostgresql || resource.Key == constant.AppPostgresqlCluster {
|
||||
return true
|
||||
hasDB = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
return hasDB
|
||||
}
|
||||
|
||||
func isEditCompose(installed model.AppInstall) bool {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue