mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-11-29 18:27:58 +08:00
change rollback api impl
This commit is contained in:
parent
14c12e1dbd
commit
601f22783b
@ -737,42 +737,19 @@ func (t *TenantStruct) CheckCode(w http.ResponseWriter, r *http.Request) {
|
||||
// "$ref": "#/responses/commandResponse"
|
||||
// description: 统一返回格式
|
||||
func (t *TenantStruct) RollBack(w http.ResponseWriter, r *http.Request) {
|
||||
rules := validator.MapData{
|
||||
"deploy_version": []string{"required"},
|
||||
"operator": []string{},
|
||||
}
|
||||
data, ok := httputil.ValidatorRequestMapAndErrorResponse(r, w, rules, nil)
|
||||
var rollbackRequest api_model.RollbackInfoRequestStruct
|
||||
ok := httputil.ValidatorRequestStructAndErrorResponse(r, w, &rollbackRequest, nil)
|
||||
if !ok {
|
||||
logrus.Errorf("start operation validate request body failure")
|
||||
return
|
||||
}
|
||||
tenantID := r.Context().Value(middleware.ContextKey("tenant_id")).(string)
|
||||
serviceID := r.Context().Value(middleware.ContextKey("service_id")).(string)
|
||||
sEvent, status, err := createEvent(getOrNilEventID(data), serviceID, "rollback", tenantID, data["deploy_version"].(string))
|
||||
handleStatus(status, err, w, r)
|
||||
if status != 0 {
|
||||
if rollbackRequest.ServiceID != serviceID {
|
||||
httputil.ReturnError(r, w, 400, "rollback service id failure")
|
||||
return
|
||||
}
|
||||
eventID := sEvent.EventID
|
||||
logger := event.GetManager().GetLogger(eventID)
|
||||
defer event.CloseManager()
|
||||
rs := &api_model.RollbackStruct{
|
||||
TenantID: tenantID,
|
||||
ServiceID: serviceID,
|
||||
EventID: eventID,
|
||||
//todo
|
||||
DeployVersion: data["deploy_version"].(string),
|
||||
}
|
||||
if _, ok := data["operator"]; ok {
|
||||
rs.Operator = data["operator"].(string)
|
||||
}
|
||||
|
||||
if err := handler.GetServiceManager().RollBack(rs); err != nil {
|
||||
logger.Error("应用回滚任务发送失败 "+err.Error(), map[string]string{"step": "callback", "status": "failure"})
|
||||
httputil.ReturnError(r, w, 500, fmt.Sprintf("check deploy version error, %v", err))
|
||||
return
|
||||
}
|
||||
logger.Info("应用回滚任务发送成功 ", map[string]string{"step": "rollback-service", "status": "starting"})
|
||||
httputil.ReturnSuccess(r, w, sEvent)
|
||||
re := handler.GetOperationHandler().RollBack(rollbackRequest)
|
||||
httputil.ReturnSuccess(r, w, re)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -669,8 +669,7 @@ func MergeDir(fromdir, todir string) error {
|
||||
//CreateVersionByTime create version number
|
||||
func CreateVersionByTime() string {
|
||||
now := time.Now()
|
||||
re := fmt.Sprintf("%d%d%d%d%d%d", now.Year(), now.Month(), now.Day(), now.Hour(), now.Minute(), now.Second())
|
||||
return re
|
||||
return now.Format("20060102150405")
|
||||
}
|
||||
|
||||
// GetDirList get all lower level dir
|
||||
|
Loading…
Reference in New Issue
Block a user