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:
Nick Craig-Wood
2026-03-05 17:55:20 +00:00
parent ad9e335cde
commit f83be9e1b2

View File

@@ -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
}