medic / couchdb-migration

0 stars 0 forks source link

Failure to connect to couchdb while migrating #18

Open 1yuv opened 4 months ago

1yuv commented 4 months ago

I've occasionally seen issues while trying to run pre-index-views.

sudo docker compose -f migration_ha.yaml run couch-migration pre-index-views 4.6.0
(node:1) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.
(Use `node --trace-warnings ...` to show where the warning was created)
An unexpected error occurred Error: Failed to connect to CouchDb. Please verify that the COUCH_URL provided is reachable through docker network.
    at prepareCouchUrl (/app/src/utils.js:44:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Object.getUrl (/app/src/utils.js:72:3)
    at async dbExists (/app/src/pre-index-views.js:51:17)
    at async getStagedDdocs (/app/src/pre-index-views.js:65:10)
    at async preIndexViews (/app/src/pre-index-views.js:121:23)
    at async /app/bin/pre-index-views.js:13:5

Without changing anythin on my migration_ha.yaml file, I can connect to the COUCH_URL from medic-os docker container.

dianabarsan commented 4 months ago

Hi @1yuv

To be clear, you're saying the error is transitory and if you try again, the command succeeds?

1yuv commented 4 months ago

Hi @dianabarsan , retrying the command is not working. I was just trying to mention that the values on my migration_ha.yaml file was corret and using the right credentials.

1yuv commented 4 months ago

I've found the solution for this by clearing orphan networks and containers and suggest following that for anyone having issues.

sudo docker network prune
sudo docker container prune
1yuv commented 4 months ago

Hi @dianabarsan , Looks like while I was doing docker network prune, i was giving some time for process to kick off. It looks like, we need to give some time between executing two commands.

sudo docker compose -f docker-compose.yaml up -d
sudo docker compose -f migration_ha.yaml run couch-migration pre-index-views 4.6.0

This time, I didn't try anything and just ran pre-index-views after it failed for the first time.

So,

To be clear, you're saying the error is transitory and if you try again, the command succeeds?

is true.

dianabarsan commented 4 months ago

I'm not sure why this would happen, there's no intermediary steps that happen within the container. I'm not sure why the docker network would be so flaky. Can you share your system details?