[REV] Improved status reminder,remove event auto timeout

This commit is contained in:
qingguo 2018-03-24 17:26:11 +08:00
parent 88ba46897c
commit beb3fdcdd8
6 changed files with 6 additions and 36 deletions

View File

@ -45,8 +45,6 @@ func createEvent(eventID, serviceID, optType, tenantID, deployVersion string) (*
if eventID == "" {
eventID = tutil.NewUUID()
}
logrus.Infof("creating event,id is %s", eventID)
event := dbmodel.ServiceEvent{}
event.EventID = eventID
event.ServiceID = serviceID
@ -79,43 +77,16 @@ func createEvent(eventID, serviceID, optType, tenantID, deployVersion string) (*
status, err := checkCanAddEvent(serviceID, event.EventID)
if err != nil {
logrus.Errorf("error check event")
logrus.Errorf("error check event", err.Error())
return nil, status, nil
}
if status == 0 {
db.GetManager().ServiceEventDao().AddModel(&event)
go autoTimeOut(&event)
return &event, status, nil
}
return nil, status, nil
}
func autoTimeOut(event *dbmodel.ServiceEvent) {
var timer *time.Timer
if event.OptType == "build" {
timer = time.NewTimer(3 * time.Minute)
} else {
timer = time.NewTimer(30 * time.Second)
}
for {
select {
case <-timer.C:
//时间到检查是否完成未完成设置为timeout
e, err := db.GetManager().ServiceEventDao().GetEventByEventID(event.EventID)
if err != nil {
return
}
if e.FinalStatus == "" {
//未完成
e.FinalStatus = "timeout"
logrus.Warnf("event id:%s time out,", event.EventID)
err = db.GetManager().ServiceEventDao().UpdateModel(e)
return
}
return
}
}
}
func checkCanAddEvent(s, eventID string) (int, error) {
events, err := db.GetManager().ServiceEventDao().GetEventByServiceID(s)
if err != nil {

View File

@ -1564,7 +1564,6 @@ func (s *ServiceAction) ServiceProbe(tsp *dbmodel.ServiceProbe, action string) e
if err := db.GetManager().ServiceProbeDao().UpdateModel(tsp); err != nil {
return err
}
return nil
}
}
case "delete":

View File

@ -305,7 +305,7 @@ func (t *ServiceProbeDaoImpl) AddModel(mo model.Interface) error {
//UpdateModel 更新应用Probe
func (t *ServiceProbeDaoImpl) UpdateModel(mo model.Interface) error {
probe := mo.(*model.ServiceProbe)
if probe.ProbeID == "" {
if probe.ProbeID == "" || probe.ID == 0 {
return fmt.Errorf("probe id can not be empty when update ")
}
if err := t.DB.Save(probe).Error; err != nil {

View File

@ -51,7 +51,7 @@ func (s *restartTask) RunError(e error) {
//应用启动超时,怎么处理?
//是否关闭应用?
//暂时不自动关闭
s.logger.Error("重启超时", map[string]string{"step": "callback", "status": "failure"})
s.logger.Error("应用重启超时,情稍等并注意应用状态", map[string]string{"step": "callback", "status": "timeout"})
return
}
s.logger.Info("开始移除Service", map[string]string{"step": "worker-executor", "status": "starting"})

View File

@ -57,12 +57,12 @@ func (s *rollingUpgradeTask) RunError(e error) {
//应用启动超时,怎么处理?
//是否关闭应用?
//暂时不自动关闭
s.logger.Error("滚动更新超时,应用关闭或启动缓慢,状态将由后台处理", map[string]string{"step": "callback", "status": "failure"})
s.logger.Error("应用升级或启动超时,情稍等并注意应用状态", map[string]string{"step": "callback", "status": "timeout"})
} else {
//TODO:
//是否还原到原版本
if e.Error() == "应用容器重启" {
s.logger.Error("滚动升级失败,应用动失败,请查询应用日志", map[string]string{"step": "callback", "status": "failure"})
s.logger.Error("滚动升级失败,应用发生重启,请查询应用日志", map[string]string{"step": "callback", "status": "failure"})
} else if e.Error() != "dont't support" {
s.logger.Error("滚动升级失败,请重试", map[string]string{"step": "callback", "status": "failure"})
}

View File

@ -55,7 +55,7 @@ func (s *startTask) RunError(e error) {
//应用启动超时,怎么处理?
//是否关闭应用?
//暂时不自动关闭
s.logger.Error("应用启动超时,请留意应用状态变化进行后续操作", map[string]string{"step": "callback", "status": "failure"})
s.logger.Error("应用启动超时,情稍等并注意应用状态", map[string]string{"step": "callback", "status": "timeout"})
return
}
if e.Error() == "deploy info is exist" {