Skip to content

posixfs: without a running server, 'opencloud posixfs scan' waits for NATS for 16 minutes and ignores Ctrl+C #3805

Open

Description

@pbleser-oc

With the single binary stopped, opencloud posixfs scan doesn't scan anything: it waits for NATS for about 16 minutes, without saying why, and it can't be interrupted with Ctrl+C in the meantime.

Found while reproducing #3804, where running the scan with the server stopped would be the safe way to use it. With the single binary, that's not possible: NATS runs inside the server.

What happens

$ opencloud posixfs scan /var/lib/opencloud/storage/users/users/<user id>
{"level":"error","error":"error connecting to nats cluster opencloud-cluster: error connecting to nats at 127.0.0.1:9233 with tls enabled (false): nats: no servers available for connection",...,"message":"can't connect to nats (jetstream) server, retrying in 3.217208632s"}
{"level":"error",...,"message":"can't connect to nats (jetstream) server, retrying in 7.320660249s"}
...
{"level":"error",...,"message":"can't connect to nats (jetstream) server, retrying in 1m27.47239962s"}
Failed to create event stream for posix driver: error connecting to nats cluster opencloud-cluster: error connecting to nats at 127.0.0.1:9233 with tls enabled (false): nats: no servers available for connection
  • It waits about 16 minutes before giving up (962 s and 19 retries in the test, then exit status 1): scanCmd (opencloud/pkg/command/posixfs.go) connects to NATS before anything else (event.NewStream), and reva's stream.Nats (pkg/events/stream/nats.go) retries with backoff.Retry and a default ExponentialBackOff, whose MaxElapsedTime is 15 minutes (cenkalti/backoff v2.2.1).
  • Nothing tells the admin why: the log lines only say that NATS isn't reachable, not that the scan needs a running OpenCloud server, or a separate NATS.
  • Ctrl+C doesn't stop it, nor does SIGTERM or SIGQUIT; only SIGKILL does. The root command turns these signals into a cancellation of the command's context (signal.NotifyContext in opencloud/pkg/command/root.go), which also stops Go from ending the process on them, but scanCmd never looks at that context: neither the NATS connection nor WarmupIDCache takes one. From the code, the same applies during a long scan with NATS available, and to other subcommands that don't use cmd.Context() (not tested).

Tested on opencloud main (8acaef2), vendored reva 7983cec1cd3a, single binary with the posix driver, server stopped, nothing listening on 127.0.0.1:9233. With only NATS running (opencloud nats server), the scan completes at once.

Expected

  • fail after a few seconds with a clear message, e.g. "cannot connect to NATS at 127.0.0.1:9233: opencloud posixfs scan needs a running OpenCloud server, or a separate NATS";
  • stop on Ctrl+C or SIGTERM, while waiting and while scanning.

Possible fixes

  1. Pass cmd.Context() down: to the NATS connection (e.g. backoff.WithContext in reva's stream.Nats) and to the scan (WarmupIDCache, checking ctx.Done() while it walks the tree).
  2. Let CLI commands use a short connection timeout instead of the server's 15 minutes, and say in the error what the command needs.
  3. Document in opencloud posixfs scan --help and in the docs that the command needs NATS, and whether the server may run during the scan (see posixfs: 'opencloud posixfs scan' leaves the server's in-memory metadata cache stale: wrong sizes, truncated downloads, wrong tree sizes #3804).

The cleanup command of #3778 (opencloud storage-users revisions cleanup, not merged yet) has the same problem with posix, as it creates the event stream the same way; that will be fixed there.

Related: #3804 (the scan leaves the running server's metadata cache stale).

Activity

  1. moved this from Qualification to Prio <= 3 in OpenCloud Team Boardon Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions