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

Update configuration of PostgreSQL for CI to use /tmp directory #259

Merged
merged 2 commits into from
Mar 26, 2024

Conversation

kota2and3kan
Copy link
Collaborator

@kota2and3kan kota2and3kan commented Mar 22, 2024

Description

This PR updates the configuration of PostgreSQL for CI.

Recently, bitnami releases a new major version of helm chart for PostgreSQL.
https://github.com/bitnami/charts/tree/main/bitnami/postgresql#to-1500

It includes backward-incompatible updates and it causes error of PostgreSQL.

1. Security configurations

Some security configurations are changed to more strict.

postgresql 07:12:47.96 INFO  ==> Initializing PostgreSQL database...
mkdir: cannot create directory '/bitnami/postgresql/data': Permission denied

Since the security configuration was made more strict, the container cannot create a new directory under the /bitnami/ directory.

So, I update to use /tmp directory instead of /bitnami/.

I think there is no problem if we use the /tmp directory because we use this PostgreSQL temporarily for CI. (I think for the production environment, using the /tmp directory is not good.)

2. Resources configurations

Before there is no resource limitations by default, but in the latest version, the bitnami helm chart set minimum resource configuration by default as follows.

$ kubectl get pod postgresql-scalardb-0 -o json | jq .spec.containers[].resources
{
  "limits": {
    "cpu": "150m",
    "ephemeral-storage": "1Gi",
    "memory": "192Mi"
  },
  "requests": {
    "cpu": "100m",
    "ephemeral-storage": "50Mi",
    "memory": "128Mi"
  }
}

Sometimes, this minimum resource limitation might cause OOM error as follows.

$ kubectl get pod postgresql-scalardb-0 -w
NAME                    READY   STATUS    RESTARTS   AGE

...(omit)...

postgresql-scalardb-0                     0/1     OOMKilled   0          90s

So, I added the configuration primary.resourcesPreset: none (the default value of previous version) explicitly.

Please take a look!

Related issues and/or PRs

Some CI failed by the PostgreSQL failure.

Changes made

  • Use the /tmp directory for the data directory of PostgreSQL.

Checklist

  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation to reflect the changes.
  • Any remaining open issues linked to this PR are documented and up-to-date (Jira, GitHub, etc.).
  • Tests (unit, integration, etc.) have been added for the changes.
  • My changes generate no new warnings.
  • Any dependent changes in other PRs have been merged and published.

Additional notes (optional)

By using this new configuration, I was able to run the PostgreSQL in my local environment.

$ helm install postgresql oci://registry-1.docker.io/bitnamicharts/postgresql -f .github/postgresql.yaml
Pulled: registry-1.docker.io/bitnamicharts/postgresql:15.1.2
Digest: sha256:48e069eb0d4926ca35ea7b864de66a622f29dab37df27c641b8434e66175ef16
NAME: postgresql
LAST DEPLOYED: Fri Mar 22 16:35:18 2024
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
CHART NAME: postgresql
CHART VERSION: 15.1.2
APP VERSION: 16.2.0

...(omit)...
$ kubectl logs postgresql-0

...(omit)...

postgresql 07:37:36.18 INFO  ==> ** PostgreSQL setup finished! **
postgresql 07:37:36.26 INFO  ==> ** Starting PostgreSQL **
2024-03-22 07:37:36.365 GMT [1] LOG:  pgaudit extension initialized
2024-03-22 07:37:36.377 GMT [1] LOG:  starting PostgreSQL 16.2 on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
2024-03-22 07:37:36.377 GMT [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2024-03-22 07:37:36.377 GMT [1] LOG:  listening on IPv6 address "::", port 5432
2024-03-22 07:37:36.388 GMT [1] LOG:  listening on Unix socket "/tmp/.s.PGSQL.5432"
2024-03-22 07:37:36.401 GMT [134] LOG:  database system was shut down at 2024-03-22 07:37:36 GMT
2024-03-22 07:37:36.418 GMT [1] LOG:  database system is ready to accept connections

Release notes

N/A

Copy link
Contributor

@feeblefakie feeblefakie left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you!

@feeblefakie feeblefakie merged commit 19bf85b into main Mar 26, 2024
14 checks passed
@feeblefakie feeblefakie deleted the update-postgresql-config-to-fix-ci-error branch March 26, 2024 05:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants