return when update deploy version

This commit is contained in:
yangk 2021-05-31 19:13:36 +08:00
parent 59ae05e9ca
commit cebc6302c9

View File

@ -307,7 +307,9 @@ func (e *exectorManager) buildFromImage(task *pb.TaskMessage) {
for k, v := range i.Configs {
configs[k] = v.String()
}
e.UpdateDeployVersion(i.ServiceID, i.DeployVersion)
if err := e.UpdateDeployVersion(i.ServiceID, i.DeployVersion); err != nil {
break
}
err = e.sendAction(i.TenantID, i.ServiceID, i.EventID, i.DeployVersion, i.Action, configs, i.Logger)
if err != nil {
i.Logger.Error("Send upgrade action failed", map[string]string{"step": "callback", "status": "failure"})
@ -365,7 +367,9 @@ func (e *exectorManager) buildFromSourceCode(task *pb.TaskMessage) {
for k, v := range i.Configs {
configs[k] = v.String()
}
e.UpdateDeployVersion(i.ServiceID, i.DeployVersion)
if err := e.UpdateDeployVersion(i.ServiceID, i.DeployVersion); err != nil {
return
}
err = e.sendAction(i.TenantID, i.ServiceID, i.EventID, i.DeployVersion, i.Action, configs, i.Logger)
if err != nil {
i.Logger.Error("Send upgrade action failed", map[string]string{"step": "callback", "status": "failure"})
@ -407,7 +411,9 @@ func (e *exectorManager) buildFromMarketSlug(task *pb.TaskMessage) {
i.Logger.Error("Build app version from market slug failure", map[string]string{"step": "callback", "status": "failure"})
}
} else {
e.UpdateDeployVersion(i.ServiceID, i.DeployVersion)
if err := e.UpdateDeployVersion(i.ServiceID, i.DeployVersion); err != nil {
break
}
err = e.sendAction(i.TenantID, i.ServiceID, i.EventID, i.DeployVersion, i.Action, i.Configs, i.Logger)
if err != nil {
i.Logger.Error("Send upgrade action failed", map[string]string{"step": "callback", "status": "failure"})
@ -583,10 +589,11 @@ func (e *exectorManager) GetCurrentConcurrentTask() float64 {
return float64(len(e.tasks))
}
func (e *exectorManager) UpdateDeployVersion(serviceID, newVersion string) {
func (e *exectorManager) UpdateDeployVersion(serviceID, newVersion string) error {
if err := db.GetManager().TenantServiceDao().UpdateDeployVersion(serviceID, newVersion); err != nil {
logrus.Errorf("Update app service deploy version failure %s, service %s do not auto upgrade", err.Error(), serviceID)
} else {
logrus.Debugf("Update app service deploy version %s success", newVersion)
return err
}
logrus.Debugf("Update app service deploy version %s success", newVersion)
return nil
}