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

Allow MIQ PG config overrides to be included #2

Merged
merged 3 commits into from
Jul 25, 2017

Conversation

fbladilo
Copy link
Contributor

@fbladilo fbladilo commented Jul 21, 2017

@carbonin @bdunne Please review, I have another PR coming with the corresponding configmaps and corresponding template modifications going to pods.

We stack after the default customs from SCL, this is how it looks on config :

bash-4.2$ tail -4 /var/lib/pgsql/data/userdata/postgresql.conf 
# Custom OpenShift configuration:
include '/var/lib/pgsql/openshift-custom-postgresql.conf'
# Begin ManageIQ configuration overrides:
include_dir '/etc/manageiq/postgresql.conf.d'

- Check for the existance of MIQ PG overrides, if available, include them in postgresql.conf
- Defaults taken from https://github.com/ManageIQ/manageiq-appliance/blob/master/COPY/etc/manageiq/postgresql.conf.d/01_miq_overrides.conf
- We use include_dir , so more configs can be stacked, PG will process *.conf in a given dir
- POSTGRESQL_CONFIG_DIR is set via environment variable and can be customized at users convenience
- Can be backported to euwe/4.5 builds to allow functionality to existing users
fbladilo added a commit to fbladilo/manageiq-pods that referenced this pull request Jul 21, 2017
- Configmap object created with MIQ default overrides settings
- Configmap is injected as a volume into /etc/manageiq/postgresql.conf.d by default
- POSTGRESQL_CONFIG_DIR supplied to on template to allow flexibility on location
- Related to PR : ManageIQ/container-postgresql#2
- PG image will pickup and do an include_dir if the directory is found

The most important piece is that the configuration is externalized and parametized.
@fbladilo fbladilo requested a review from carbonin July 21, 2017 19:08
Copy link
Member

@carbonin carbonin left a comment

Choose a reason for hiding this comment

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

This looks good to me as long as the /etc/manageiq/postgresql.conf.d directory exists.

I don't think we explicitly create that anywhere so if the configmap mount creates parent directories, then this is fine.

if [ -d "${POSTGRESQL_CONFIG_DIR}" ]; then
cat >> "$PGDATA/postgresql.conf" <<EOF
# Begin ManageIQ configuration overrides:
include_dir '${POSTGRESQL_CONFIG_DIR}'
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to check if this is already here to avoid having multiple entries in the config?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bdunne Yep, working on another commit with slightly different logic for safety.

- Added a check to avoid creating multiple entries of the same config during reschedules
- Create default directory location for PG_CONFIG_DIR on image not on scripts
- Change default location for PG_CONFIG_DIR to a known writable location (avoid /etc)
@fbladilo
Copy link
Contributor Author

fbladilo commented Jul 24, 2017

@bdunne @carbonin A few changes :

  • Added a check for the existence of the include_dir entry on postgresql.conf, skip if found.
  • Create the default PG_CONF_DIR directory on image, this is safer and guarantees that even if the configmap is removed/missing/non-existant, PG will attempt to come online instead of failing immediately.
  • Changed default location of MIQ PG conf.d directory to /var/lib/pgsql (always writable and safer), we want to avoid permissions and related issues by having a default conf.d on /etc.


# Check for POSTGRESQL_CONFIG_DIR presence in postgresql.conf, if already there skip.
[[ $(grep ${POSTGRESQL_CONFIG_DIR} ${PGDATA}/postgresql.conf) ]] && RET=$? || RET=$?
if [[ $RET == "0" ]]; then
Copy link
Member

Choose a reason for hiding this comment

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

I think if [[ $? -eq 0 ]] would be simpler

Copy link
Contributor Author

@fbladilo fbladilo Jul 24, 2017

Choose a reason for hiding this comment

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

I tried to avoid checking straight on $? , too many times things get in the middle by accident. That's why I chose to save status on a VAR. Script is run with set -eu and and very picky, will probably quit immediately on a false test.

Copy link
Member

@bdunne bdunne left a comment

Choose a reason for hiding this comment

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

👍

@carbonin carbonin self-assigned this Jul 25, 2017
@carbonin carbonin added this to the Sprint 66 Ending Aug 7, 2017 milestone Jul 25, 2017
@carbonin carbonin merged commit 0d179f3 into ManageIQ:master Jul 25, 2017
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.

3 participants