example-voting-app icon indicating copy to clipboard operation
example-voting-app copied to clipboard

Worker pod not able to connect to db

Open akshaygmenon opened this issue 4 years ago • 6 comments

** PLEASE ONLY USE THIS ISSUE TRACKER TO SUBMIT ISSUES WITH THE EXAMPLE VOTING APP **

  • If you have a bug working with Docker itself, not related to these labs, please file the bug on the Docker repo *
  • If you would like general support figuring out how to do something with Docker, please use the Docker Slack channel. If you're not on that channel, sign up for the Docker Community and you'll get an invite. *
  • Or go to the Docker Forums *

Please provide the following information so we can assess the issue you're having

The worker pod is not able to connect to the database

I am deploying this on Openshift and I was able to get the vote and result services running, but when I try to deploy the worker pod, I see that the pod is running, but on checking the logs I see continuous logging of "Waiting for db" , due to that I am not able to connect to the database and not able to see the voting in real time.

Has anyone else seen this error and have any idea on how to fix this on platform running Openshift ver 4.8?

Thanks,

AKshay

akshaygmenon avatar Oct 25 '21 19:10 akshaygmenon

I'm getting the same error.

thejordanclark avatar Nov 16 '21 22:11 thejordanclark

Try adding the following environment variable in db-deployment.yaml.

- name: POSTGRES_HOST_AUTH_METHOD
  value: trust

gelbander avatar Nov 19 '21 09:11 gelbander

With the given yamls, worker-app uses the db credentials "postgres:postgres", so you'll need to specify two environment variables with the db (postgres) deployment i.e. POSTGRES_USER: postgres and POSTGRES_PASSWORD: postgres. Once that's done, worker-app will automatically connect to the db.

prabhatsingh014 avatar Feb 12 '22 15:02 prabhatsingh014

With the given yamls, worker-app uses the db credentials "postgres:postgres", so you'll need to specify two environment variables with the db (postgres) deployment i.e. POSTGRES_USER: postgres and POSTGRES_PASSWORD: postgres. Once that's done, worker-app will automatically connect to the db.

this is right i fix my problem by doing this. add two environment postgres name and postgres password to connect postgres,so the db container will run consistantly without exited. db: image: postgres:9.4 environment: POSTGRES_USER: "postgres" POSTGRES_PASSWORD: "postgres" them docker-compose up

mumong avatar Jun 06 '22 08:06 mumong

If you install postgres with minimum version 12, u must add argument for authentication encryption method to md5 , u can add this environtment variable to postgres deployment file name: POSTGRES_INITDB_ARGS
value: "--auth-host=md5 --auth-local=md5"

feriva22 avatar Sep 03 '22 15:09 feriva22

If you install postgres with minimum version 12, u must add argument for authentication encryption method to md5 , u can add this environtment variable to postgres deployment file name: POSTGRES_INITDB_ARGS value: "--auth-host=md5 --auth-local=md5"

I've solved worker to db connection issues after adding this env variable. Thanks @feriva22

worker log showed this message:

System.NotSupportedException: Authentication method not supported (Received: 10) at Npgsql.NpgsqlConnector.ParseServerMessage(ReadBuffer buf, BackendMessageCode code, Int32 len, DataRowLoadingMode dataRowLoadingMode, Boolean isPrependedMessage) at Npgsql.NpgsqlConnector.DoReadMessage(DataRowLoadingMode dataRowLoadingMode, Boolean isPrependedMessage) at Npgsql.NpgsqlConnector.ReadMessageWithPrepended(DataRowLoadingMode dataRowLoadingMode) at Npgsql.NpgsqlConnector.HandleAuthentication(String username, NpgsqlTimeout timeout) at Npgsql.NpgsqlConnector.Open(NpgsqlTimeout timeout) at Npgsql.ConnectorPool.Allocate(NpgsqlConnection conn, NpgsqlTimeout timeout) at Npgsql.NpgsqlConnection.OpenInternal() at Worker.Program.OpenDbConnection(String connectionString) in /code/src/Worker/Program.cs:line 78 at Worker.Program.Main(String[] args) in /code/src/Worker/Program.cs:line 19

mluelmo avatar Sep 04 '22 18:09 mluelmo

We're sorry for the late response. Linux images have been refreshed, cleaned up, and are now multi-platform. If you're still having issues with the latest images, feel free to reopen this ticket.

BretFisher avatar Dec 17 '22 03:12 BretFisher