mirror of
https://github.com/wekan/wekan.git
synced 2026-11-25 04:49:41 -05:00
#6583, comment 5282677837: "sudo snap run wekan.database-compare brings me to: error: cannot find app "database-compare" in "wekan" It seems, that database compare is not included in wekan 10.82, we have installed. Should I upgrade to the most recent version and then try again?" Yes - the two recovery commands are snap APPS, so they exist only in the revision that ships them (v10.90). That is the smaller half of this. The larger half is what happened before it: the same instance, serving data from a migration done in July, was told "No problems detected" by `snap run wekan.problems`, and the admin had to find the command names in a GitHub thread. That report was not wrong. It reads ONE database - the one WeKan is connected to - and every check inside it passed. The question that mattered, WHICH of the two copies that is, was asked by nothing, while the docs already claimed this command answered it. So the report ends with a "Databases on this machine" section: which copy is being served and why (`bin/database-role --why`, the one helper every part of the snap asks, so the report cannot disagree with what the snap does), whether MongoDB files and a FerretDB database both exist, and - when they do - the two commands to run. It reads the files rather than a database, so it answers with WeKan down, and it declares no fault: two copies is the normal state of a migrated snap, and calling that a problem would make every migrated instance look broken. A revision without the commands says so and says to refresh, instead of leaving snapd's "cannot find app" as the last word, and says why refreshing is safe for exactly this case: it does not import an old MongoDB over a FerretDB already in use (#6585), and neither copy is ever deleted. The script ran the Node report with `exec`, which replaces the process, so this had to stop doing that; the report's exit status is still the command's. `wekan.problems migrations|login|cpu|broken-cards` are unchanged - they are used in pipes - and `wekan.help` and Migration-to-FerretDB.md now list the two commands, with the release they arrived in. tests/snapProblemsDatabases.test.cjs pins all of it, including the two negatives: no fault is declared, and the sub-commands print only what they were asked for. Thanks to waltermhl and xet7 ! Refs #6583 — the reporter still has to run the two commands, so this does not close it.
82 lines
4.1 KiB
Bash
Executable File
82 lines
4.1 KiB
Bash
Executable File
#!/bin/bash
|
|
# wekan-problems — print the Admin Panel / Problems "Status" overview as text, so an
|
|
# admin with server (snap) access can see problems, migrations and repairs WITHOUT
|
|
# Admin Panel access. Runs wekan-problems.mjs with the bundled Node.js and the WeKan
|
|
# bundle's node_modules on NODE_PATH so the `mongodb` driver resolves (same pattern
|
|
# as db-eval).
|
|
#
|
|
# Usage:
|
|
# snap run wekan.problems # full overview
|
|
# snap run wekan.problems migrations # only migrations/repairs in progress
|
|
# snap run wekan.problems login # only the "Must be logged in" checks
|
|
# snap run wekan.problems broken-cards # only the broken-cards count
|
|
# snap run wekan.problems cpu # machine CPU load / core count
|
|
# snap run wekan.problems help
|
|
|
|
# Load the snap settings so the login-page checks see the SAME configuration WeKan
|
|
# runs with — ROOT_URL, LDAP_ENABLE, DATABASE, etc. Without this the command reads an
|
|
# empty process.env and always reported ROOT_URL as "not set" even after
|
|
# `snap set wekan root-url=...` (wekan/wekan feedback). wekan-read-settings exports
|
|
# each key; suppress its per-key echo so it doesn't pollute the report.
|
|
if [ -r "$SNAP/bin/wekan-read-settings" ]; then
|
|
# shellcheck disable=SC1091
|
|
. "$SNAP/bin/wekan-read-settings" >/dev/null 2>&1 || true
|
|
fi
|
|
|
|
env NODE_PATH="$SNAP/programs/server/node_modules" \
|
|
"$SNAP/bin/node" "$SNAP/bin/wekan-problems.mjs" "$@"
|
|
rc=$?
|
|
|
|
# ── Which copy of the data is being served ───────────────────────────────────
|
|
#
|
|
# #6583, comment 5282677837: an admin whose site was showing data from a
|
|
# migration done a month earlier ran this command and was told "No problems
|
|
# detected". That was true of everything it checks — it reads ONE database, the
|
|
# one WeKan is connected to, and every check inside it passed. The question that
|
|
# mattered, "which of my two copies am I looking at", was not asked by anything.
|
|
#
|
|
# It is asked here, from the files, so it works even when the site is down. This
|
|
# is a report: nothing is started, nothing is written.
|
|
#
|
|
# A section, not a "problem": two copies is the normal state of a migrated snap.
|
|
# It becomes a problem only when the copy being served is not the one with the
|
|
# work in it, and that is what database-compare answers.
|
|
case "${1:-}" in
|
|
''|status|databases)
|
|
SNAP_COMMON="${SNAP_COMMON:-/var/snap/${SNAP_INSTANCE_NAME:-${SNAP_NAME:-wekan}}/common}"
|
|
svc="${SNAP_INSTANCE_NAME:-${SNAP_NAME:-wekan}}"
|
|
echo
|
|
echo "Databases on this machine"
|
|
echo "-------------------------"
|
|
if [ -r "$SNAP/bin/database-role" ]; then
|
|
echo " Serving: $(bash "$SNAP/bin/database-role" --why 2>/dev/null)"
|
|
fi
|
|
mongo=no
|
|
ferret=no
|
|
{ [ -f "$SNAP_COMMON/WiredTiger" ] || ls "$SNAP_COMMON"/collection-*.wt >/dev/null 2>&1; } && mongo=yes
|
|
ls "$SNAP_COMMON/files/db"/*.sqlite >/dev/null 2>&1 && ferret=yes
|
|
echo " MongoDB files in $SNAP_COMMON: $mongo"
|
|
echo " FerretDB database in $SNAP_COMMON/files/db: $ferret"
|
|
if [ "$mongo" = yes ] && [ "$ferret" = yes ]; then
|
|
echo
|
|
echo " There are TWO copies of this site's data. That is normal after a"
|
|
echo " migration - $SNAP_COMMON is shared across snap revisions and nothing"
|
|
echo " deletes the old copy. If what WeKan shows looks older than your work:"
|
|
if [ -r "$SNAP/bin/database-compare" ]; then
|
|
echo " sudo snap run ${svc}.database-compare # what does each copy hold? changes nothing"
|
|
echo " sudo snap run ${svc}.database-merge # insert into the served copy what only the other has"
|
|
else
|
|
# The two commands arrived in WeKan v10.90; on an older revision the
|
|
# error is snapd's `cannot find app "database-compare" in "wekan"`,
|
|
# which says nothing about what to do next. This does.
|
|
echo " This WeKan revision has no database-compare / database-merge."
|
|
echo " sudo snap refresh ${svc} # then run: sudo snap run ${svc}.database-compare"
|
|
echo " Refreshing does not re-import the old MongoDB over a FerretDB that"
|
|
echo " is already in use, and neither copy is deleted."
|
|
fi
|
|
fi
|
|
;;
|
|
esac
|
|
|
|
exit $rc
|