mirror of
https://github.com/rclone/rclone.git
synced 2026-05-25 01:14:45 -04:00
docker serve: add timeout to volume restore so slow remotes don't block startup
When restoring volumes from saved state during plugin startup, a slow or unreachable remote could block indefinitely in fs.NewFs. Add a 30-second per-volume timeout context so that individual volume failures are logged and skipped rather than blocking the entire plugin.
This commit is contained in:
@@ -21,6 +21,12 @@ import (
|
||||
"github.com/rclone/rclone/vfs/vfscommon"
|
||||
)
|
||||
|
||||
const (
|
||||
// volTimeout is the maximum time to wait for a single volume to
|
||||
// be restored (filesystem setup) during plugin startup.
|
||||
volTimeout = 30 * time.Second
|
||||
)
|
||||
|
||||
// Driver implements docker driver api
|
||||
type Driver struct {
|
||||
root string
|
||||
@@ -356,7 +362,12 @@ func (drv *Driver) restoreState(ctx context.Context) error {
|
||||
}
|
||||
|
||||
for _, vol := range state {
|
||||
if err := vol.restoreState(ctx, drv); err != nil {
|
||||
// Use a timeout so that a slow or unreachable remote does
|
||||
// not block the plugin from starting up.
|
||||
volCtx, cancel := context.WithTimeout(ctx, volTimeout)
|
||||
err := vol.restoreState(volCtx, drv)
|
||||
cancel()
|
||||
if err != nil {
|
||||
fs.Logf(nil, "Failed to restore volume %q: %v", vol.Name, err)
|
||||
continue
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user