Split build and upgrade events.

This commit is contained in:
曾庆国 2019-08-23 11:41:47 +08:00
parent d429d32530
commit 3e410f0450

View File

@ -373,16 +373,32 @@ type rollingUpgradeTaskBody struct {
} }
func (e *exectorManager) sendAction(tenantID, serviceID, eventID, newVersion, actionType string, configs map[string]string, logger event.Logger) error { func (e *exectorManager) sendAction(tenantID, serviceID, eventID, newVersion, actionType string, configs map[string]string, logger event.Logger) error {
// update build event complete status
logger.Info("Build success", map[string]string{"step": "last", "status": "running"})
switch actionType { switch actionType {
case "upgrade": case "upgrade":
//add upgrade event
event := &dbmodel.ServiceEvent{
EventID: util.NewUUID(),
TenantID: tenantID,
ServiceID: serviceID,
StartTime: time.Now().Format(time.RFC3339),
OptType: "upgrade",
Status: "running",
}
if err := db.GetManager().ServiceEventDao().AddModel(event); err != nil {
logrus.Errorf("create upgrade event failure %s, service %s do not auto upgrade", err.Error(), serviceID)
return nil
}
if err := db.GetManager().TenantServiceDao().UpdateDeployVersion(serviceID, newVersion); err != nil { if err := db.GetManager().TenantServiceDao().UpdateDeployVersion(serviceID, newVersion); err != nil {
return fmt.Errorf("Update app service deploy version failure.Please try the upgrade again") logrus.Errorf("Update app service deploy version failure %s, service %s do not auto upgrade", err.Error(), serviceID)
return nil
} }
body := workermodel.RollingUpgradeTaskBody{ body := workermodel.RollingUpgradeTaskBody{
TenantID: tenantID, TenantID: tenantID,
ServiceID: serviceID, ServiceID: serviceID,
NewDeployVersion: newVersion, NewDeployVersion: newVersion,
EventID: eventID, EventID: event.EventID,
Configs: configs, Configs: configs,
} }
if err := e.mqClient.SendBuilderTopic(mqclient.TaskStruct{ if err := e.mqClient.SendBuilderTopic(mqclient.TaskStruct{
@ -392,10 +408,9 @@ func (e *exectorManager) sendAction(tenantID, serviceID, eventID, newVersion, ac
}); err != nil { }); err != nil {
return err return err
} }
logger.Info("Build success,start upgrade app service", map[string]string{"step": "builder", "status": "running"}) logger.Info("Build success", map[string]string{"step": "last", "status": "running"})
return nil return nil
default: default:
logger.Info("Build success,do not other action", map[string]string{"step": "last", "status": "success"})
} }
return nil return nil
} }