SYNC_DB_SENTINEL - Whether to sync the content of the medic-sentinel database. Suggested: true
When I run cht-couch2pg I get this error:
[2025-02-04T05:39:18.632Z ERROR]: Couch2PG import failed
[2025-02-04T05:39:18.632Z ERROR]: {
error: 'forbidden',
reason: 'You are not allowed to access this db.',
status: 403,
name: 'forbidden',
message: 'You are not allowed to access this db.',
stack: 'Error\n' +
' at Object.generateErrorFromResponse (/var/adapter/shared/cht-couch2pg-v3.6.2/node_modules/pouchdb-errors/lib/index.js:104:18)\n' +
' at /var/adapter/shared/cht-couch2pg-v3.6.2/node_modules/pouchdb-adapter-http/lib/index.js:254:33\n' +
' at runMicrotasks (<anonymous>)\n' +
' at processTicksAndRejections (internal/process/task_queues.js:97:5)'
}
And I’ve been told that this is because the user I’m using (couch2pg) doesn’t have access to the medic-sentinel database in CouchDB.
How do I give my couch2pg user access to the database to avoid this 403 when cht-couch2pg runs??
(I know I should be using CHT Sync, but this is an old install that hasn’t made the migration yet)
I’m suspecting this older project started on 3.x and recently upgraded to 4.x leading to a change in couchdb configuration files that hold admin user credentials. Unfortunately, the current bootstrap scripts and templates don’t allow importing custom configuration files as lots of default config values changed. If that is a path we want to resolve, a few scripts that ensure the import of CouchDB settings are appropriate parameters for its version should be sufficient.
The manual workarounds would be:
edit couch2pg configuration to use the single admin in cht-core 4.x
OR
Log into couchdb-1 container and add a new admin to the persistent volume, in location: /opt/couchdb/etc/local.d/cluster-credentials.ini. Restart couchdb-1 and copy that password hash into the couchdb containers at the same location.
Sweet! Confirming that clicking the lock for medic-sentinel and then adding my couch2pg user in the “Members” section worked! (note: screenshot above shows medic-audit DB, but users should click medic-sentinel or which ever DB is in question)
I tested this before the change with curl and got a forbidden:
$ curl -s https://couch2pg:********@my.cht-url-here.com/medic-sentinel/ | jq
{
"error": "forbidden",
"reason": "You are not allowed to access this db."
}
And the re-running the exact same command after adding my user I got the expected JSON payload: