Community Health Toolkit

Core Framework: Failed to create initial CouchDB administrative account

Describe the Bug
During CHT installation I am getting Fatal: Failed to create initial CouchDB administrative account error
Moving conversation from Github for the benefit of other Community members: https://github.com/medic/cht-infrastructure/issues/5

How To Reproduce The Issue

  1. Clone https://github.com/medic/cht-infrastructure
  2. Follow instructions to run CHT
  3. Check the CouchDB logs for the error message

Expected Behavior
CouchDB admin user should be created and CHT app should run
Logs
root@cf3c91e7cff4:/srv/storage/medic-core# tail -f /srv/storage/medic-core/couchdb/logs/startup.log

[notice] 2020-07-26T10:18:52.333172Z couchdb@127.0.0.1 <0.350.0> -------- chttpd_auth_cache changes listener died database_does_not_exist at mem3_shards:load_shards_from_db/6(line:395) <= mem3_shards:load_shards_from_disk/1(line:370) <= mem3_shards:load_shards_from_disk/2(line:399) <= mem3_shards:for_docid/3(line:86) <= fabric_doc_open:go/3(line:39) <= chttpd_auth_cache:ensure_auth_ddoc_exists/2(line:195) <= chttpd_auth_cache:listen_for_changes/1(line:142)
[error] 2020-07-26T10:18:57.335931Z couchdb@127.0.0.1 emulator -------- Error in process <0.19943.1> on node ‘couchdb@127.0.0.1’ with exit value:
{database_does_not_exist,[{mem3_shards,load_shards_from_db,"_users",[{file,“src/mem3_shards.erl”},{line,395}]},{mem3_shards,load_shards_from_disk,1,[{file,“src/mem3_shards.erl”},{line,370}]},{mem3_shards,load_shards_from_disk,2,[{file,“src/mem3_shards.erl”},{line,399}]},{mem3_shards,for_docid,3,[{file,“src/mem3_shards.erl”},{line,86}]},{fabric_doc_open,go,3,[{file,“src/fabric_doc_open.erl”},{line,39}]},{chttpd_auth_cache,ensure_auth_ddoc_exists,2,[{file,“src/chttpd_auth_cache.erl”},{line,195}]},{chttpd_auth_cache,listen_for_changes,1,[{file,“src/chttpd_auth_cache.erl”},{line,142}]}]}

Environment

  • OS
    root@osboxes:~# lsb_release -a
    No LSB modules are available.
    Distributor ID: Ubuntu
    Description: Ubuntu 18.04.4 LTS
    Release: 18.04
    Codename: bionic

  • Instance: Local instance

  • Version:
    Docker: Docker version 19.03.6, build 369ce74a3c
    Docker Compose: version 1.26.2, build unknown

Additional Context
The problem started after the upgrade of medic-os docker to: medic-os:cht-3.9.0-rc.1

@munjoma please confirm that you are running docker-compose up as root and also that you exported the couchdb admin password in your shell before running docker-compose up?

export DOCKER_COUCHDB_ADMIN_PASSWORD=<random_pw>

You may need to prune your system of past installs because any second install attempt will assume that you have already installed

@nyika

Yes I am running docker-compose up as root. I am running the prepare.sh script as root.

I did not run that step. With the prepare.sh script how do I do that? Do I just follow instructions in Docker Setup?

Yeah the instructions here detail how you should get the CHT Medic-Os up and running through docker. Make sure you use our later docker image though. The process is a simple 3 step

  1. Install all docker prerequisites
  2. Export the CouchDB admin password.
  3. Run docker-compose up (run in detached mode if you are running it in production mode.)

Hi @nyika

I pruned my system of past installs.

the did run

from /cht-infrastructure/self-hosting/main$

confirm I have to replace <random_pw> with a password of my choice? (which I did)

Still no luck.
Please find the log file here (I can not upload the file, file format not supported)

From what I see in this logfile there’s a hint that CouchDB was not set up properly and you are trying over a failed install. The _users DB is missing. To do a fresh install follow these steps.

  1. Prune your system (assuming you only have the CHT docker images )
    docker system prune -a --volumes

  2. Get the latest docker-compose file here.

  3. In your shell as root Export the CouchDB password. export DOCKER_COUCHDB_ADMIN_PASSWORD=myAwesomePassword

  4. In the same shell install the medic-os and ha-proxy containers in detached mode.
    # docker-compose -f /path/to/docker-compose.yml up -d

2 Likes