-
Notifications
You must be signed in to change notification settings - Fork 282
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
Makes postgres-reload-modules conditional #216
Conversation
postgres/codenamemap.yaml
Outdated
@@ -70,6 +70,7 @@ | |||
{{ debian_codename('vivid', '9.4') }} | |||
{{ debian_codename('wily', '9.4') }} | |||
{{ debian_codename('xenial', '9.5') }} | |||
{{ debian_codename('bionic', '10') }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adds codename for Ubuntu 18.04 "bionic". This was all I needed to change to get Postgres 10 working for Ubuntu 18.04.
postgres/defaults.yaml
Outdated
@@ -57,6 +57,8 @@ postgres: | |||
|
|||
bake_image: False | |||
|
|||
manage_force_reload_modules: True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New config setting defaults to True
to preserve existing behavior.
postgres/manage.sls
Outdated
@@ -15,12 +17,16 @@ include: | |||
|
|||
{%- endif %} | |||
|
|||
{%- if needs_client_binaries or postgres.manage_force_reload_modules %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was getting tired of postgres-reload-modules
running even when nothing had changed. I hid the state behind a conditional that checks if any new client binaries were installed, or if manage_force_reload_modules
was set to True
.
NOTE: manage_force_reload_modules
defaults to True
to preserve the existing behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybemange_force_reload_modules
should default to False to fix #214 @vunty what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm totally fine with setting mange_force_reload_modules
to False
by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I have just one outstanding query.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RobRuana Thanks for your PR!
Since we already have a PR submitted to add support for Ubuntu 18, I propose to separate concerns and focus on fixing issue #214 here. I found it really annoys people 😃
Also I think you need to add conditional to macros.jinja
file, as each state produced by format_state
macro has explicit requirement on the postgres-reload-modules
.
Okay, I merged the codename changes from Furthermore, I repositioned the conditional so |
test.succeed_with_changes: | ||
{%- else %} | ||
test.succeed_without_changes: | ||
{%- endif %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RobRuana This seems like an obvious fix, but that wouldn't work.
Each state generated below explicitly subscribed on changes in postgres-reload-modules
. So if you later change PG entities in the Pillar, it will not have any effect.
The only way I see to overcome this: you need to put conditional in format_state
macro to depend on modules reload only when postgres.manage_force_reload_modules
set True
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vutny, yes, you are correct that this breaks any state using the format_state()
macro.
At first I couldn't understand why onchanges: postgres-reload-modules
was being used instead of require: postgres-reload-modules
. But then I realized that many instances of format_state()
are already using the require
conditional, so there would be conflicting require
keys when the state is rendered.
Correct me if I'm wrong, but I believe onchanges
is being used to force correct ordering of the states, not because we want every format_state()
to run when there are changes in postgres-reload-modules
.
If that's correct, then we should be able to achieve the same result by using watch
instead of onchanges
in format_state()
. I've made that change. Please let me know if you think that works.
postgres/server/init.sls
Outdated
@@ -184,9 +184,6 @@ postgresql-running: | |||
service.running: | |||
- name: {{ postgres.service }} | |||
- enable: True | |||
{% if grains.os not in ('MacOS',) %} | |||
- reload: True | |||
{% endif %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RobRuana This has already been resolved by 79ab1a2 during #218:
postgres-formula/postgres/server/init.sls
Lines 141 to 151 in 332fe7b
- watch_in: | |
- module: postgresql-service-restart | |
{%- endif %} | |
# Restart the service where reloading is not sufficient | |
# Currently when the cluster is created or changes made to `postgresql.conf` | |
postgresql-service-restart: | |
module.wait: | |
- name: service.restart | |
- m_name: {{ postgres.service }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the notice! I'm scrambling to get everything working at the moment, and this was my quick and dirty fix. I've synced with upstream.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RobRuana You're welcome.
@vutny could you take another look and ping me if it's ok? |
@aboe76 @RobRuana My in-line comment above still applies. All latter states in |
@@ -176,6 +169,15 @@ postgresql-pg_hba: | |||
{%- endif %} | |||
- require: | |||
- file: postgresql-config-dir | |||
- watch_in: | |||
- module: postgresql-service-restart |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've found that simply reloading the postgres service is not enough to pick up ACL changes in pg_hba.conf. A full restart is required.
This is on ubuntu 18.04 with postgres 10.
I'm going to close this pull request for now. I may revisit this issue, but for now I am okay with the |
…formulas#214 Based on the great work of @RobRuana in saltstack-formulas#216.
…formulas#214 Based on the great work of @RobRuana in saltstack-formulas#216.
This pull request makes the
postgres-reload-modules
conditional so it doesn't report changes during every run.