pushkin-consortium / pushkin-cli

A CLI designed to facilitate the setup process of a Pushkin stack
MIT License
0 stars 4 forks source link

Failing to setup test_db (mac OS, machine specific?) #77

Closed conbainbridge closed 4 years ago

conbainbridge commented 4 years ago

When running pushkin prep, the test_db fails to setup and throws this error, regardless of whether or not I have run pushkin armageddon and restarted Docker first:

Failed to setup databases:
    error: database "test_db" does not exist

The following is the logs output from Docker desktop:

The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /var/lib/postgresql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default timezone ... Etc/UTC
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

Success. You can now start the database server using:

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

pg_ctl -D /var/lib/postgresql/data -l logfile start

waiting for server to start....2020-07-29 20:15:43.435 UTC [46] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2020-07-29 20:15:43.484 UTC [47] LOG: database system was shut down at 2020-07-29 20:15:42 UTC
2020-07-29 20:15:43.498 UTC [46] LOG: database system is ready to accept connections
done
server started
CREATE DATABASE

/usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*

2020-07-29 20:15:44.053 UTC [46] LOG: received fast shutdown request
waiting for server to shut down....2020-07-29 20:15:44.061 UTC [46] LOG: aborting any active transactions
2020-07-29 20:15:44.077 UTC [46] LOG: background worker "logical replication launcher" (PID 53) exited with exit code 1
2020-07-29 20:15:44.078 UTC [48] LOG: shutting down
2020-07-29 20:15:44.128 UTC [46] LOG: database system is shut down
done
server stopped

PostgreSQL init process complete; ready for start up.

2020-07-29 20:15:44.197 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
2020-07-29 20:15:44.197 UTC [1] LOG: listening on IPv6 address "::", port 5432
2020-07-29 20:15:44.206 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2020-07-29 20:15:44.232 UTC [64] LOG: database system was shut down at 2020-07-29 20:15:44 UTC
2020-07-29 20:15:44.240 UTC [1] LOG: database system is ready to accept connections
2020-07-29 20:15:53.220 UTC [1] LOG: received smart shutdown request
2020-07-29 20:15:53.225 UTC [1] LOG: background worker "logical replication launcher" (PID 70) exited with exit code 1
2020-07-29 20:15:53.229 UTC [65] LOG: shutting down
2020-07-29 20:15:53.260 UTC [1] LOG: database system is shut down

PostgreSQL Database directory appears to contain a database; Skipping initialization

2020-07-29 20:25:29.740 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
2020-07-29 20:25:29.742 UTC [1] LOG: listening on IPv6 address "::", port 5432
2020-07-29 20:25:29.750 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2020-07-29 20:25:29.788 UTC [25] LOG: database system was shut down at 2020-07-29 20:15:53 UTC
2020-07-29 20:25:29.825 UTC [1] LOG: database system is ready to accept connections

And the specs of the container (the top section header that got chopped off by the window size is the "Environment"):

Screen Shot 2020-07-31 at 11 40 43 AM
conbainbridge commented 4 years ago

pushkin start seems to power up the container, but it says this in regards to test_db:

2020-07-31 16:18:36.940 UTC [199] FATAL: password authentication failed for user "postgres"

2020-07-31 16:18:36.940 UTC [199] DETAIL: Password does not match for user "postgres".

Connection matched pg_hba.conf line 95: "host all all all md5"

Still guessing this might be an issue with my global postgres though still confused how Docker is getting influenced by it.

jkhartshorne commented 4 years ago

Can you confirm that your docker-compose has this text:

` test_db: image: 'postgres:11' environment: POSTGRES_PASSWORD: example POSTGRES_DB: test_db ports:

and that your pushkin.yaml has this:

# databases configs experiments can use databases: localtestdb: user: 'postgres' pass: 'example' url: 'localhost' name: 'test_db'

If that matches exactly, can you please pop in your docker-compose here just so I can double-check that there isn't anything else weird lying around?

jkhartshorne commented 4 years ago

Another thing you can try is using a late v0 of the CLI with compatible site and experiment templates. (You should be able to figure out which ones those are by looking at the version noters on github, and just finding the last one before the notes say 'upgrading to be compatible with cli v1'). If you can get things to work with an earlier version, maybe we can figure out what's going on that way.

conbainbridge commented 4 years ago

The pushkin.yaml and docker-compose.dev.yml do indeed have these (and this issue happens to any pushkin site I try to run, even when I build a new one). Below is my docker-compose.dev.yml:

version: '3.1'
volumes:
  message_queue_volume: null
  test_db_volume: null
services:
  api:
    build: ./api
    environment:
      - 'AMQP_ADDRESS=amqp://message-queue:5672'
      - PORT=3000
    expose:
      - '3000'
    links:
      - message-queue
  message-queue:
    image: 'rabbitmq:3.6-management'
    expose:
      - 5672
      - 15672
    ports:
      - 15672
    environment:
      CONFD_ARGS: '--interval 5'
      RABBITMQ_CLUSTER_PARTITION_HANDLING: autoheal
      RABBITMQ_NET_TICKTIME: '60'
      RABBITMQ_ERLANG_COOKIE: message-queue-cookie
      RABBITMQ_NODENAME: rabbitmqnode@localhost
    volumes:
      - 'message_queue_volume:/var/lib/rabbitmq'
  server:
    build: ./front-end
    environment:
      API_PORT: '3000'
    ports:
      - '80:80'
      - '433:433'
    links:
      - api
  test_db:
    image: 'postgres:11'
    environment:
      POSTGRES_PASSWORD: example
      POSTGRES_DB: test_db
    ports:
      - '5432:5432'
    volumes:
      - 'test_db_volume:/var/lib/postgresql/data'
    healthcheck:
      test:
        - CMD-SHELL
        - pg_isready -U postgres
      interval: 10s
      timeout: 5s
      retries: 5
  reading_worker:
    image: reading_worker
    links:
      - message-queue
      - test_db
    environment:
      - 'AMQP_ADDRESS=amqp://message-queue:5672'
      - DB_USER=postgres
      - DB_PASS=
      - DB_URL=test_db
      - DB_NAME=test_db
    labels:
      isPushkinWorker: true
conbainbridge commented 4 years ago

I also noticed this pop up in Docker desktop, which makes me wonder if some global postgres configurations are messed up, since user should be postgres instead of root.

2020-07-31 17:00:43.605 UTC [96] FATAL: role "root" does not exist
jkhartshorne commented 4 years ago

Can you pop in your pushkin.yaml as well?

conbainbridge commented 4 years ago

pushkin.yaml:

# main directories relative to project root ('..')
experimentsDir: 'experiments'
coreDir: 'pushkin'

# databases configs experiments can use
databases:
  localtestdb:
    user: 'postgres'
    pass: 'example'
    url: 'localhost'
    name: 'test_db'
jkhartshorne commented 4 years ago

Is the 'root' role used anywhere?

conbainbridge commented 4 years ago

I didn't think so, thinking about it I believe that line in the Docker logs may have come up because I went into the container from terminal to try to figure out what it thought the password should be.

conbainbridge commented 4 years ago

Issue was Postgres clogging port 5432. Running the following line in terminal fixes this: sudo pkill -u postgres

If anyone else runs into a similar issue and finds this thread, to check if this solution will work for you, confirm Postgres is in port 5432 using: sudo lsof -i tcp:5432