The logs in #6746 show the real cause of "write: permission denied" from
database-restore and of WeKan waiting forever for FerretDB: 1300 kernel
lines of apparmor="DENIED" operation="file_perm" class="net" for
snap.wekan.wekan on 127.0.0.1:27019, with the same denial for snap-store
and standard-notes on that computer. FerretDB was running and accepting
connections; the kernel refused the first write. That is snapd 2.77.1 on a
kernel with an AppArmor socket mediation bug (Launchpad snapd bug 2169038),
fixed by a newer kernel and worked around by `snap revert snapd`.
WeKan cannot lift that denial, so it now says what it is. A new
bin/socket-denied recognises the refusal and prints the denial to look for,
the upstream bug and both ways out. wekan-control's FerretDB and MongoDB
wait loops keep each attempt's error and print it on the first refused
attempt instead of "not ready yet" for two minutes; database-backup and
database-restore stop at once instead of starting an already running
service and waiting 90 seconds.
The same log began with "error: snapctl: get which option?" four times:
SAML_IDP_PROFILE, SAML_WANT_RESPONSE_SIGNED, SAML_WANT_ASSERTIONS_SIGNED
and SAML_LOGIN_FLOW were listed in bin/config without a KEY_ name, so
wekan-read-settings ran a bare `snapctl get` for them and `snap set` could
never reach them. They now have their snap keys, the CORS_EXPOSE_HEADERS
description has its right name, and a key without a snap name falls back
to its default instead of calling snapctl.
Tests: snapSocketDenied, snapSettingsKeys, and extended snapDatabaseRestore
and ferretdbWaitTimeout.
Related to #6746: the reporter still has to update the kernel or revert
snapd, so the issue stays open until that is confirmed.
Thanks to fabiosalles and xet7 !
wekan.database-restore and wekan.database-backup talked to whatever was
on the database port and nothing else. After `snap stop wekan`, which the
restore steps tell people to run, nothing is there; on a FerretDB snap the
database is its own service that starting WeKan alone does not bring back.
The tools then failed after a 30-second server-selection timeout with a
driver topology dump naming neither the service nor its log.
The new bin/database-ready asks bin/database-role which database holds
the data, starts that service when nothing answers, waits for it, and when
it still does not answer stops with the driver's own error and the
`snap logs` / `snap services` commands that show the reason. A "permission
denied" is explained as a security-policy denial on this system, not the
database, with the journal command that names the rule.
WeKan's own wait for FerretDB discarded the ping error, so its log said only
"FerretDB not ready yet" for every cause. db-eval now prints why a command
failed on stderr, and the wait's one-time hint shows it. The same hint
suggested `snap set wekan database=mongodb`, a setting the configure hook
removes, so that advice did nothing; it is gone.
The backup script also sources its settings and passes the archive path
quoted now, so a path with a space works.
tests/snapDatabaseRestore.test.cjs runs both scripts in a stand-in snap:
FerretDB or MongoDB started by role, a running database left alone, and,
negatively, a database that never answers stopping the tool before it
runs, with the error shown. A source guard requires both tools to wait for
the database first. tests/ferretdbWaitTimeout.test.cjs now requires the
ping error in the hint and rejects the removed setting. Not run inside an
installed snap here.
Thanks to fabiosalles and xet7 !
Retain the existing --drop restore behavior that prevents duplicate-key collisions, validate that exactly one real archive was supplied, and preserve paths containing spaces as one mongorestore argument. Add command-level positive and negative regressions with a mocked Snap environment.
Thanks to ram19890 and xet7 !
Fixes#6547,