Skip to content

Commit

Permalink
Fix elapse timeout
Browse files Browse the repository at this point in the history
Signed-off-by: Anisur Rahman <[email protected]>
  • Loading branch information
anisurrahman75 committed Jan 14, 2025
1 parent 401663a commit ec9b3a5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/restic/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"gomodules.xyz/pointer"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/errors"
"math"
"sync"
"time"
)
Expand Down Expand Up @@ -115,8 +116,12 @@ func (w *ResticWrapper) updateElapsedTimeout(startTime time.Time) {
if w.Config.Timeout != nil {
w.Config.Lock()
defer w.Config.Unlock()

// Calculate the new timeout by subtracting the elapsed duration
elapsed := time.Since(startTime)
newTimeout := time.Duration(math.Max(float64(w.Config.Timeout.Duration-elapsed), float64(0)))
w.Config.Timeout = &metav1.Duration{
Duration: time.Since(startTime),
Duration: newTimeout,
}
}
}
Expand Down

0 comments on commit ec9b3a5

Please sign in to comment.