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

BED-4384: Bump Postgres to 16 in development #887

Merged
merged 8 commits into from
Oct 4, 2024
Merged

BED-4384: Bump Postgres to 16 in development #887

merged 8 commits into from
Oct 4, 2024

Conversation

ALCooper12
Copy link
Contributor

@ALCooper12 ALCooper12 commented Sep 25, 2024

Description

  • Added new just command for only spinning up the database and pgadmin containers

Motivation and Context

  • Ticket: BED-4384

Why is this change required? What problem does it solve?

  • This solves the issue of proper data transfer and bumping Postgres from version 13.2 to version 16

How Has This Been Tested?

  • Local testing where running the instruction commands below in my terminal resulted in no data loss being seen in pgadmin/UI, and the bhce docker pod spins up with the proper Postgres 16 image without seeing data directory error logs

Screenshots (optional):

Running from BHCE repo:

# 1. First, stop any running containers and start only the database and pgadmin containers
just pg-only

# 2. Change the password encryption from MD5 to SCRAM-SHA-256 format (Postgres 16 defaults to this format)
just pg-only exec app-db sh -c "\"psql -c \\\"SET password_encryption = 'scram-sha-256'; ALTER ROLE CURRENT_USER PASSWORD '\${BH_POSTGRES_PASSWORD:-bloodhoundcommunityedition}';\\\" \""

# 3. Export existing data via a database dump (while the database and pgadmin containers are running)
just pg-only exec app-db pg_dumpall > dump.sql

# 4. Stop with Ctrl+C and remove all containers
just bh-dev down

# 5. Remove only the database volume for the Postgres service
just pg-only down -v

# 6. Edit the docker-compose file from 13.2 to 16 in /docker-compose.dev.yml 

# 7. Start only the database and pgAdmin containers
just pg-only

# 8. Restore the database from the dump file
just pg-only exec -T app-db psql < dump.sql

# 9. Stop the database and pgAdmin containers with Ctrl+C

# 10. Finally, start all containers
just bh-dev

Otherwise:

# 1. First, stop any running containers, navigate to examples/docker-compose/, and start only the database container
docker compose up app-db

# 2. Change the password encryption from MD5 to SCRAM-SHA-256 format (Postgres 16 defaults to this format)
docker compose exec app-db sh -c "psql -c \"SET password_encryption = 'scram-sha-256'; ALTER ROLE CURRENT_USER PASSWORD '\${BH_POSTGRES_PASSWORD:-bloodhoundcommunityedition}';\""

# 3. Export existing data via a database dump (while the database container is running)
docker compose exec app-db pg_dumpall > dump.sql

# 4. Stop with Ctrl+C and remove the database container
docker compose rm -f app-db

# 5. Remove only the database volume for the Postgres service
docker volume rm docker-compose_postgres-data

# 6. Edit the docker-compose file from 13.2 to 16 in examples/docker-compose/docker-compose.yml or whatever directory the file is kept

# 7. Start only the database container
docker compose up app-db

# 8. Restore the database from the dump file
docker compose exec -T app-db psql < dump.sql

# 9. Stop the database container with Ctrl+C

# 10. Finally, start all containers
docker compose up

Types of changes

  • Chore (a change that does not modify the application functionality)
  • Database Migrations

Checklist:

@ALCooper12 ALCooper12 added the tooling This updates developer tooling label Sep 25, 2024
@ALCooper12 ALCooper12 self-assigned this Sep 25, 2024
@ALCooper12 ALCooper12 changed the title BED-4384: Bump Postgres to 16.1 in development BED-4384: Bump Postgres to 16 in development Sep 26, 2024
@ALCooper12 ALCooper12 marked this pull request as ready for review September 26, 2024 21:40
docker-compose.dev.yml Outdated Show resolved Hide resolved
Copy link
Contributor

@ddlees ddlees left a comment

Choose a reason for hiding this comment

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

Let's go ahead and update the postgres version in each docker-compose file

@ddlees ddlees merged commit 425e916 into main Oct 4, 2024
4 checks passed
@ddlees ddlees deleted the BED-4384 branch October 4, 2024 16:06
@github-actions github-actions bot locked and limited conversation to collaborators Oct 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
tooling This updates developer tooling
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants