Repository navigation
Description
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'sstream.Nats(pkg/events/stream/nats.go) retries withbackoff.Retryand a defaultExponentialBackOff, whoseMaxElapsedTimeis 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
SIGTERMorSIGQUIT; onlySIGKILLdoes. The root command turns these signals into a cancellation of the command's context (signal.NotifyContextinopencloud/pkg/command/root.go), which also stops Go from ending the process on them, butscanCmdnever looks at that context: neither the NATS connection norWarmupIDCachetakes one. From the code, the same applies during a long scan with NATS available, and to other subcommands that don't usecmd.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 scanneeds a running OpenCloud server, or a separate NATS"; - stop on Ctrl+C or
SIGTERM, while waiting and while scanning.
Possible fixes
- Pass
cmd.Context()down: to the NATS connection (e.g.backoff.WithContextin reva'sstream.Nats) and to the scan (WarmupIDCache, checkingctx.Done()while it walks the tree). - Let CLI commands use a short connection timeout instead of the server's 15 minutes, and say in the error what the command needs.
- Document in
opencloud posixfs scan --helpand 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).
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsPrio <= 3
Activity
feat: 1419: add a command to clean up old revisions on demand
feat: 1419: add a command to clean up old revisions on demand
feat: 1419: add a command to clean up old revisions on demand
feat: 1419: add a command to clean up old revisions on demand
feat: 1419: add a command to clean up old revisions on demand
feat: 1419: add a command to clean up old revisions on demand
feat: 1419: add a command to clean up old revisions on demand
feat: 1419: add a command to clean up old revisions on demand
feat: 1419: add a command to clean up old revisions on demand
feat: 1419: add a command to clean up old revisions on demand
feat: 1419: add a command to clean up old revisions on demand
feat: 1419: add a command to clean up old revisions on demand