Skip to content

Commit

Permalink
Merge pull request #170 from sonroyaalmerol/instant-fail
Browse files Browse the repository at this point in the history
do not retry on job is still running error
  • Loading branch information
sonroyaalmerol authored Feb 17, 2025
2 parents 71e5520 + 8797880 commit 31da1cb
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion internal/backend/backup/jobrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"github.com/sonroyaalmerol/pbs-plus/internal/syslog"
)

var ErrOneInstance = errors.New("a job is still running; only one instance allowed")

type BackupOperation struct {
Task *proxmox.Task
waitGroup *sync.WaitGroup
Expand All @@ -45,7 +47,7 @@ func runBackupAttempt(
return nil, fmt.Errorf("runBackupAttempt: failed to create job mutex: %w", err)
}
if err := jobInstanceMutex.TryLock(); err != nil {
return nil, errors.New("a job is still running; only one instance allowed")
return nil, ErrOneInstance
}

var agentMount *mount.AgentMount
Expand Down Expand Up @@ -298,6 +300,11 @@ func RunBackup(ctx context.Context, job *types.Job, storeInstance *store.Store,
op, err := runBackupAttempt(ctx, job, storeInstance, skipCheck)
if err != nil {
lastErr = err
if err == ErrOneInstance {
autoOp.err = err
close(autoOp.done)
return
}
log.Printf("Backup attempt %d setup failed: %v", attempt, err)
time.Sleep(10 * time.Second)
continue
Expand Down

0 comments on commit 31da1cb

Please sign in to comment.