Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dev-environment): Wait for Postgres to initialise before running CloudQuery #1034

Merged
merged 2 commits into from
May 24, 2024

Conversation

akash1810
Copy link
Member

What does this change?

In the DEV environment, CloudQuery fails to connect to the Postgres database, logging:

failed to init destination postgresql: rpc error: code = Internal desc = failed to init plugin: failed to initialize client: failed to get current database: failed to connect to `host=postgres user=postgres database=postgres`: dial error (dial tcp 172.26.0.2:5432: connect: connection refused)

This is because Postgres is still initialising when the connection is attempted. This initialisation includes creating the tables, and inserting rows copied from CODE.

In this change, a healthcheck is added to the Postgres container, passing only once the initialisation has completed. CloudQuery (and Grafana) starts afterwards.

Additionally, the configuration is updated, getting the CloudQuery container to connect to the Postgres container via the Docker network, as opposed to going via the host.

How has it been verified?

  • Start the dev-environment on main, observe the above error from the CloudQuery container
  • Start the dev-environment on this branch, observe the CloudQuery container running

@akash1810 akash1810 force-pushed the aa/dev-cq-works branch 2 times, most recently from 57ac443 to e8bdcdc Compare May 24, 2024 14:52
Configure a healthcheck on the Postgres container, passing only once the initialisation scripts have completed.

This fixes the behaviour where CloudQuery would fail stating:

```log
failed to init destination postgresql: rpc error: code = Internal desc = failed to init plugin: failed to initialize client: failed to get current database: failed to connect to `host=postgres user=postgres database=postgres`: dial error (dial tcp 172.26.0.2:5432: connect: connection refused)
```
Copy link
Contributor

@tjsilver tjsilver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! Tested locally on main and this branch and observed the error go away 🥇

@akash1810 akash1810 merged commit 6d8beab into main May 24, 2024
2 checks passed
@akash1810 akash1810 deleted the aa/dev-cq-works branch May 24, 2024 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants