mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-12-19 05:49:02 +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,
|
"minio": 9001,
|
||||||
}
|
}
|
||||||
|
|
||||||
func createLink(ctx context.Context, installTask *task.Task, app model.App, appInstall *model.AppInstall, params map[string]interface{}) error {
|
func CreateDB(ctx context.Context, 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 {
|
|
||||||
database := &model.Database{
|
database := &model.Database{
|
||||||
AppInstallID: appInstall.ID,
|
AppInstallID: appInstall.ID,
|
||||||
Name: appInstall.Name,
|
Name: appInstall.Name,
|
||||||
|
|
@ -158,7 +148,6 @@ func createLink(ctx context.Context, installTask *task.Task, app model.App, appI
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
formFields := &dto.AppForm{}
|
formFields := &dto.AppForm{}
|
||||||
if err := json.Unmarshal([]byte(detail.Params), formFields); err != nil {
|
if err := json.Unmarshal([]byte(detail.Params), formFields); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -214,6 +203,20 @@ func createLink(ctx context.Context, installTask *task.Task, app model.App, appI
|
||||||
}
|
}
|
||||||
return databaseRepo.Create(ctx, database)
|
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)
|
installTask.AddSubTask(i18n.GetMsgByKey("HandleDatabaseApp"), handleDataBaseApp, deleteAppLink)
|
||||||
}
|
}
|
||||||
if ToolKeys[app.Key] > 0 {
|
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 {
|
func hasLinkDB(installID uint) bool {
|
||||||
resources, _ := appInstallResourceRepo.GetBy(appInstallResourceRepo.WithAppInstallId(installID))
|
resources, _ := appInstallResourceRepo.GetBy(appInstallResourceRepo.WithAppInstallId(installID))
|
||||||
|
hasDB := false
|
||||||
if len(resources) > 0 {
|
if len(resources) > 0 {
|
||||||
for _, resource := range resources {
|
for _, resource := range resources {
|
||||||
if resource.Key == constant.AppPostgres || resource.Key == constant.AppMysql ||
|
if resource.Key == constant.AppPostgres || resource.Key == constant.AppMysql ||
|
||||||
resource.Key == constant.AppMariaDB || resource.Key == constant.AppMysqlCluster ||
|
resource.Key == constant.AppMariaDB || resource.Key == constant.AppMysqlCluster ||
|
||||||
resource.Key == constant.AppPostgresql || resource.Key == constant.AppPostgresqlCluster {
|
resource.Key == constant.AppPostgresql || resource.Key == constant.AppPostgresqlCluster {
|
||||||
return true
|
hasDB = true
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false
|
return hasDB
|
||||||
}
|
}
|
||||||
|
|
||||||
func isEditCompose(installed model.AppInstall) bool {
|
func isEditCompose(installed model.AppInstall) bool {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue