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-07-13 15:30:03 +01:00
parent 560d3928d0
commit 64331a4eae
+12 -1
View File
@@ -21,6 +21,12 @@ import (
"github.com/rclone/rclone/vfs/vfscommon" "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 // Driver implements docker driver api
type Driver struct { type Driver struct {
root string root string
@@ -356,7 +362,12 @@ func (drv *Driver) restoreState(ctx context.Context) error {
} }
for _, vol := range state { 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) fs.Logf(nil, "Failed to restore volume %q: %v", vol.Name, err)
continue continue
} }