-
Notifications
You must be signed in to change notification settings - Fork 1
Postgresql reload #54
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
base: stable/sap/3.0
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -98,14 +98,57 @@ | |
|
|
||
| change_notify = node["postgresql"]["server"]["config_change_notify"] | ||
|
|
||
| raw_configuration = node["postgresql"]["config"] | ||
| postgresql_configuration = {} | ||
| raw_configuration.each do |key, value| | ||
| next if value.nil? | ||
| formatted_value = case value | ||
| when String | ||
| "'#{value}'" | ||
| when TrueClass | ||
| "on" | ||
| when FalseClass | ||
| "off" | ||
| else | ||
| value | ||
| end | ||
| postgresql_configuration[key] = formatted_value | ||
| end | ||
|
|
||
| reloadable_parameters = [ | ||
| "log_line_prefix" | ||
| ] | ||
|
|
||
| config_needs_restart = postgresql_configuration.reject do |key, value| | ||
| reloadable_parameters.include? key | ||
| end | ||
|
|
||
| config_needs_reload = postgresql_configuration.select do |key, value| | ||
| reloadable_parameters.include? key | ||
| end | ||
|
|
||
| template "#{node['postgresql']['dir']}/postgresql.conf" do | ||
| source "postgresql.conf.erb" | ||
| owner "postgres" | ||
| group "postgres" | ||
| mode 0600 | ||
| variables( | ||
| config: config_needs_restart.sort | ||
| ) | ||
| notifies change_notify, "service[postgresql]", :immediately | ||
| end | ||
|
|
||
| template "#{node['postgresql']['dir']}/postgresql_reloadable.conf" do | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style/StringLiteralsInInterpolation: Prefer double-quoted strings inside interpolations. (https://github.com/SUSE/style-guides/blob/master/Ruby.md#stylestringliteralsininterpolation) |
||
| source "postgresql_reloadable.conf.erb" | ||
| owner "postgres" | ||
| group "postgres" | ||
| mode "0600" | ||
| variables( | ||
| config: config_needs_reload.sort | ||
| ) | ||
| notifies :run, "bash[reload-postgresql-configuration]", :immediately | ||
| end | ||
|
|
||
| template "#{node['postgresql']['dir']}/pg_hba.conf" do | ||
| source "pg_hba.conf.erb" | ||
| owner "postgres" | ||
|
|
@@ -164,3 +207,16 @@ | |
| only_if only_if_command if ha_enabled | ||
| action :run | ||
| end | ||
|
|
||
| # Reload the configuration file | ||
| # We use the SQL interface for that. This way it will work | ||
| # in clustered mode as well, no matter which node runs it | ||
| # first | ||
| bash "reload-postgresql-configuration" do | ||
| user "postgres" | ||
| code <<-EOH | ||
| echo "SELECT pg_reload_conf();" | psql | ||
| EOH | ||
| action :nothing | ||
| end | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Layout/TrailingBlankLines: 1 trailing blank lines detected. (https://github.com/bbatsov/ruby-style-guide#newline-eof) |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| <% @config.each do |key, value| %> | ||
| <%= key %> = <%= value %> | ||
| <% end %> |
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.
This is causing an issue for me, it seems that this causes the service to be immediately reloaded after the template change, but before the postgresql_reloadable.conf exists, so postgresql fails due to a syntax error because the incuded file doesn't exist yet.
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.
Ah, that could be true indeed. I did not run into that trouble, as the HA restart was still broken on my branch.
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 happened to be checking it in non-ha mode.
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.
Let me add a fix for that.