Merge branch 'V5.2' into V5.2

This commit is contained in:
黄润豪 2020-03-10 23:50:56 +08:00 committed by GitHub
commit dc456631dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 23 deletions

View File

@ -554,11 +554,18 @@ func (s *ServiceAction) ServiceCreate(sc *api_model.ServiceStruct) error {
v.HostPath = fmt.Sprintf("%s/tenant/%s/service/%s%s", sharePath, sc.TenantID, ts.ServiceID, volumn.VolumePath)
//本地文件存储
case dbmodel.LocalVolumeType.String():
if sc.ExtendMethod != "state" {
if !dbmodel.ServiceType(sc.ExtendMethod).IsState() {
tx.Rollback()
return util.CreateAPIHandleError(400, fmt.Errorf("应用类型不为有状态应用.不支持本地存储"))
return util.CreateAPIHandleError(400, fmt.Errorf("local volume type only support state component"))
}
v.HostPath = fmt.Sprintf("%s/tenant/%s/service/%s%s", localPath, sc.TenantID, ts.ServiceID, volumn.VolumePath)
case dbmodel.ConfigFileVolumeType.String(), dbmodel.MemoryFSVolumeType.String():
logrus.Debug("simple volume type : ", volumn.VolumeType)
default:
if !dbmodel.ServiceType(sc.ExtendMethod).IsState() {
tx.Rollback()
return util.CreateAPIHandleError(400, fmt.Errorf("custom volume type only support state component"))
}
}
}
if volumn.VolumeName == "" {

View File

@ -59,11 +59,7 @@ func checkTimeout(event *dbmodel.ServiceEvent) bool {
return false
}
var end time.Time
if event.OptType == "deploy-service" || event.OptType == "create-service" || event.OptType == "build-service" {
end = start.Add(10 * time.Minute)
} else {
end = start.Add(3 * time.Minute)
}
end = start.Add(3 * time.Minute)
if time.Now().After(end) {
event.FinalStatus = "timeout"
err = db.GetManager().ServiceEventDao().UpdateModel(event)

View File

@ -21,6 +21,13 @@ package exector
import (
"context"
"fmt"
"io/ioutil"
"os"
"path"
"path/filepath"
"strings"
"time"
"github.com/Sirupsen/logrus"
"github.com/coreos/etcd/clientv3"
"github.com/docker/docker/client"
@ -33,12 +40,6 @@ import (
"github.com/goodrain/rainbond/util"
"github.com/pquerna/ffjson/ffjson"
"github.com/tidwall/gjson"
"io/ioutil"
"os"
"path"
"path/filepath"
"strings"
"time"
)
//BackupAPPRestore restrore the group app backup
@ -479,17 +480,21 @@ func (b *BackupAPPRestore) restoreMetadata(appSnapshot *AppSnapshot) error {
//local
case dbmodel.LocalVolumeType.String():
a.HostPath = fmt.Sprintf("%s/tenant/%s/service/%s%s", localPath, b.TenantID, a.ServiceID, a.VolumePath)
case dbmodel.MemoryFSVolumeType.String(), dbmodel.ConfigFileVolumeType.String():
logrus.Debugf("simple volume type: %s", a.VolumeType)
default:
logrus.Warnf("custom volumeType: %s", a.VolumeType)
volumeType, err := db.GetManager().VolumeTypeDao().GetVolumeTypeByType(a.VolumeType)
if err != nil {
logrus.Warnf("get volumeType[%s] error : %s, use share-file instead", a.VolumeType, err.Error())
}
if volumeType == nil {
logrus.Warnf("service[%s] volumeType[%s] do not exists, use default volumeType[%s]", a.ServiceID, a.VolumeType, dbmodel.ShareFileVolumeType.String())
a.VolumeType = dbmodel.ShareFileVolumeType.String()
a.HostPath = fmt.Sprintf("%s/tenant/%s/service/%s%s", sharePath, b.TenantID, a.ServiceID, a.VolumePath)
}
}
volumeType, err := db.GetManager().VolumeTypeDao().GetVolumeTypeByType(a.VolumeType)
if err != nil {
logrus.Warnf("get volumeType error : %s", err.Error())
return err
}
if volumeType == nil {
logrus.Warnf("service[%s] volumeType[%s] do not exists, use default volumeType[%s]", a.ServiceID, a.VolumeType, dbmodel.ShareFileVolumeType.String())
a.VolumeType = dbmodel.ShareFileVolumeType.String()
a.HostPath = fmt.Sprintf("%s/tenant/%s/service/%s%s", sharePath, b.TenantID, a.ServiceID, a.VolumePath)
}
if err := db.GetManager().TenantServiceVolumeDaoTransactions(tx).AddModel(a); err != nil {
tx.Rollback()
return fmt.Errorf("create app volume when restore backup error. %s", err.Error())