mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-10-09 23:17:21 +08:00
fix: Optimize duplicate execution error messages for cronjob (#10307)
This commit is contained in:
parent
50e99f1f4c
commit
f682f07dbc
13 changed files with 17 additions and 5 deletions
|
@ -32,7 +32,7 @@ type ICronjobRepo interface {
|
|||
StartRecords(cronjobID uint) model.JobRecords
|
||||
UpdateRecords(id uint, vars map[string]interface{}) error
|
||||
EndRecords(record model.JobRecords, status, message, records string)
|
||||
AddFailedRecord(cronjobID uint)
|
||||
AddFailedRecord(cronjobID uint, message string)
|
||||
PageRecords(page, size int, opts ...DBOption) (int64, []model.JobRecords, error)
|
||||
}
|
||||
|
||||
|
@ -169,12 +169,12 @@ func (u *CronjobRepo) EndRecords(record model.JobRecords, status, message, recor
|
|||
}
|
||||
_ = u.Update(record.CronjobID, map[string]interface{}{"is_executing": false})
|
||||
}
|
||||
func (u *CronjobRepo) AddFailedRecord(cronjobID uint) {
|
||||
func (u *CronjobRepo) AddFailedRecord(cronjobID uint, message string) {
|
||||
var record model.JobRecords
|
||||
record.StartTime = time.Now()
|
||||
record.CronjobID = cronjobID
|
||||
record.Status = constant.StatusFailed
|
||||
record.Message = "The current cronjob is being executed"
|
||||
record.Message = message
|
||||
if err := global.DB.Create(&record).Error; err != nil {
|
||||
global.LOG.Errorf("create record status failed, err: %v", err)
|
||||
}
|
||||
|
|
|
@ -464,7 +464,7 @@ func uploadWithMap(taskItem task.Task, accountMap map[string]backupClientHelper,
|
|||
"file": path.Join(itemBackup.backupPath, dst),
|
||||
"backup": name,
|
||||
}))
|
||||
for i := 0; i < int(retry); i++ {
|
||||
for i := 0; i < int(retry)+1; i++ {
|
||||
_, err := itemBackup.client.Upload(src, path.Join(itemBackup.backupPath, dst))
|
||||
taskItem.LogWithStatus(i18n.GetMsgByKey("Upload"), err)
|
||||
if err != nil {
|
||||
|
|
|
@ -536,6 +536,9 @@ func (u *CronjobService) HandleOnce(id uint) error {
|
|||
if cronjob.ID == 0 {
|
||||
return buserr.New("ErrRecordNotFound")
|
||||
}
|
||||
if cronjob.IsExecuting {
|
||||
return buserr.New("InExecuting")
|
||||
}
|
||||
u.HandleJob(&cronjob)
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ import (
|
|||
func (u *CronjobService) HandleJob(cronjob *model.Cronjob) {
|
||||
cronjobItem, _ := cronjobRepo.Get(repo.WithByID(cronjob.ID))
|
||||
if cronjobItem.IsExecuting {
|
||||
cronjobRepo.AddFailedRecord(cronjob.ID)
|
||||
cronjobRepo.AddFailedRecord(cronjob.ID, i18n.GetMsgByKey("InExecuting"))
|
||||
return
|
||||
}
|
||||
record := cronjobRepo.StartRecords(cronjob.ID)
|
||||
|
|
|
@ -234,6 +234,7 @@ Upload: "Upload"
|
|||
IgnoreBackupErr: "Backup failed, error: {{ .detail }}, ignoring this error..."
|
||||
IgnoreUploadErr: "Upload failed, error: {{ .detail }}, ignoring this error..."
|
||||
LoadBackupFailed: "Failed to get backup account connection, error: {{ .detail }}"
|
||||
InExecuting: "The current task is being executed, please do not repeat the execution!"
|
||||
|
||||
#toolbox
|
||||
ErrNotExistUser: 'The current user does not exist, please modify and try again!'
|
||||
|
|
|
@ -234,6 +234,7 @@ Upload: "アップロード"
|
|||
IgnoreBackupErr: "バックアップ失敗、エラー: {{ .detail }}、このエラーを無視します..."
|
||||
IgnoreUploadErr: "アップロード失敗、エラー: {{ .detail }}、このエラーを無視します..."
|
||||
LoadBackupFailed: "バックアップアカウントの接続取得に失敗、エラー: {{ .detail }}"
|
||||
InExecuting: "現在のタスクは実行中です。重複して実行しないでください!"
|
||||
|
||||
#toolbox
|
||||
ErrNotExistUser: '現在のユーザーは存在しません。変更してもう一度お試しください。'
|
||||
|
|
|
@ -234,6 +234,7 @@ Upload: "업로드"
|
|||
IgnoreBackupErr: "백업 실패, 오류: {{ .detail }}, 이 오류를 무시합니다..."
|
||||
IgnoreUploadErr: "업로드 실패, 오류: {{ .detail }}, 이 오류를 무시합니다..."
|
||||
LoadBackupFailed: "백업 계정 연결 획득 실패, 오류: {{ .detail }}"
|
||||
InExecuting: "현재 작업이 실행 중입니다. 중복 실행하지 마세요!"
|
||||
|
||||
#도구상자
|
||||
ErrNotExistUser: '현재 사용자가 존재하지 않습니다. 수정한 후 다시 시도하세요!'
|
||||
|
|
|
@ -234,6 +234,7 @@ Upload: "Muat Naik"
|
|||
IgnoreBackupErr: "Sandaran gagal, ralat: {{ .detail }}, abaikan ralat ini..."
|
||||
IgnoreUploadErr: "Muat naik gagal, ralat: {{ .detail }}, abaikan ralat ini..."
|
||||
LoadBackupFailed: "Gagal mendapatkan sambungan akaun sandaran, ralat: {{ .detail }}"
|
||||
InExecuting: "Tugas semasa sedang dilaksanakan, jangan ulangi pelaksanaan!"
|
||||
|
||||
#kotak alat
|
||||
ErrNotExistUser: 'Pengguna semasa tidak wujud, sila ubah suai dan cuba lagi!'
|
||||
|
|
|
@ -234,6 +234,7 @@ Upload: "Enviar"
|
|||
IgnoreBackupErr: "Backup falhou, erro: {{ .detail }}, ignorando este erro..."
|
||||
IgnoreUploadErr: "Upload falhou, erro: {{ .detail }}, ignorando este erro..."
|
||||
LoadBackupFailed: "Falha ao obter conexão da conta de backup, erro: {{ .detail }}"
|
||||
InExecuting: "A tarefa atual está sendo executada, não repita a execução!"
|
||||
|
||||
#caixa de ferramentas
|
||||
ErrNotExistUser: 'O usuário atual não existe, modifique e tente novamente!'
|
||||
|
|
|
@ -234,6 +234,7 @@ Upload: "Загрузить"
|
|||
IgnoreBackupErr: "Ошибка резервного копирования: {{ .detail }}, игнорируем эту ошибку..."
|
||||
IgnoreUploadErr: "Ошибка загрузки: {{ .detail }}, игнорируем эту ошибку..."
|
||||
LoadBackupFailed: "Не удалось получить подключение к учетной записи резервной копии, ошибка: {{ .detail }}"
|
||||
InExecuting: "Текущая задача выполняется, не повторяйте выполнение!"
|
||||
|
||||
#ящик для инструментов
|
||||
ErrNotExistUser: 'Текущий пользователь не существует, измените его и повторите попытку!'
|
||||
|
|
|
@ -235,6 +235,7 @@ Upload: "Yükle"
|
|||
IgnoreBackupErr: "Yedekleme başarısız, hata: {{ .detail }}, bu hata yoksayılıyor..."
|
||||
IgnoreUploadErr: "Yükleme başarısız, hata: {{ .detail }}, bu hata yoksayılıyor..."
|
||||
LoadBackupFailed: "Yedek hesap bağlantısı alınamadı, hata: {{ .detail }}"
|
||||
InExecuting: "Mevcut görev yürütülüyor, lütfen tekrar yürütmeyin!"
|
||||
|
||||
#toolbox
|
||||
ErrNotExistUser: 'Mevcut kullanıcı mevcut değil, lütfen değiştirin ve tekrar deneyin!'
|
||||
|
|
|
@ -233,6 +233,7 @@ Upload: "上傳"
|
|||
IgnoreBackupErr: "備份失敗,錯誤:{{ .detail }},忽略本次錯誤..."
|
||||
IgnoreUploadErr: "上傳失敗,錯誤:{{ .detail }},忽略本次錯誤..."
|
||||
LoadBackupFailed: "獲取備份帳號連接失敗,錯誤:{{ .detail }}"
|
||||
InExecuting: "當前任務正在執行中,請勿重複執行!"
|
||||
|
||||
#toolbox
|
||||
ErrNotExistUser: '目前使用者不存在,請修改後重試!'
|
||||
|
|
|
@ -233,6 +233,7 @@ Upload: "上传"
|
|||
IgnoreBackupErr: "备份失败,错误:{{ .detail }},忽略本次错误..."
|
||||
IgnoreUploadErr: "上传失败,错误:{{ .detail }},忽略本次错误..."
|
||||
LoadBackupFailed: "获取备份账号连接失败,错误:{{ .detail }}"
|
||||
InExecuting: "当前任务正在执行中,请勿重复执行!"
|
||||
|
||||
#toolbox
|
||||
ErrNotExistUser: "当前用户不存在,请修改后重试!"
|
||||
|
|
Loading…
Add table
Reference in a new issue