Postgresql reload#54
Postgresql reload#54matelakat wants to merge 2 commits intosap-oc:stable/sap/3.0from matelakat:postgresql-reload
Conversation
| echo "SELECT pg_reload_conf();" | psql | ||
| EOH | ||
| action :nothing | ||
| end No newline at end of file |
There was a problem hiding this comment.
Layout/TrailingBlankLines: Final newline missing. (https://github.com/bbatsov/ruby-style-guide#newline-eof)
| group "postgres" | ||
| mode 0600 | ||
| variables( | ||
| config: config_needs_reload.sort, |
There was a problem hiding this comment.
Style/TrailingCommaInArguments: Avoid comma after the last parameter of a method call. (https://github.com/bbatsov/ruby-style-guide#no-trailing-params-comma)
| source "postgresql_reloadable.conf.erb" | ||
| owner "postgres" | ||
| group "postgres" | ||
| mode 0600 |
There was a problem hiding this comment.
Style/NumericLiteralPrefix: Use 0o for octal literals. (https://github.com/bbatsov/ruby-style-guide#numeric-literal-prefixes)
| notifies change_notify, "service[postgresql]", :immediately | ||
| end | ||
|
|
||
| template "#{node['postgresql']['dir']}/postgresql_reloadable.conf" do |
There was a problem hiding this comment.
Style/StringLiteralsInInterpolation: Prefer double-quoted strings inside interpolations. (https://github.com/SUSE/style-guides/blob/master/Ruby.md#stylestringliteralsininterpolation)
| group "postgres" | ||
| mode 0600 | ||
| variables( | ||
| config: config_needs_restart.sort, |
There was a problem hiding this comment.
Style/TrailingCommaInArguments: Avoid comma after the last parameter of a method call. (https://github.com/bbatsov/ruby-style-guide#no-trailing-params-comma)
| when TrueClass | ||
| 'on' | ||
| when FalseClass | ||
| 'off' |
There was a problem hiding this comment.
Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. (https://github.com/SUSE/style-guides/blob/master/Ruby.md#stylestringliterals)
| "'#{value}'" | ||
| when TrueClass | ||
| 'on' | ||
| when FalseClass |
There was a problem hiding this comment.
Layout/CaseIndentation: Indent when as deep as case. (https://github.com/bbatsov/ruby-style-guide#indent-when-to-case)
| when String | ||
| "'#{value}'" | ||
| when TrueClass | ||
| 'on' |
There was a problem hiding this comment.
Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. (https://github.com/SUSE/style-guides/blob/master/Ruby.md#stylestringliterals)
| formatted_value = case value | ||
| when String | ||
| "'#{value}'" | ||
| when TrueClass |
There was a problem hiding this comment.
Layout/CaseIndentation: Indent when as deep as case. (https://github.com/bbatsov/ruby-style-guide#indent-when-to-case)
| raw_configuration.each do |key, value| | ||
| next if value.nil? | ||
| formatted_value = case value | ||
| when String |
There was a problem hiding this comment.
Layout/CaseIndentation: Indent when as deep as case. (https://github.com/bbatsov/ruby-style-guide#indent-when-to-case)
Move out logic from the template to the cookbook, so it can be re-used later.
This change splits the postgresql configuration file into two pieces. One should contain the options that require a server restart (the main postgresql.conf file) and that is sourcing the other file (postgresql_reloadable.conf) which is the home for reloadable parameters. This way we can use chef's notification mechanism to either reload or restart the server. Please consult postgresql's manual for reloadable configuration options. If you want to be able to gracefuly reload a specific parameter, amend that to `reloadable_parameters`
| EOH | ||
| action :nothing | ||
| end | ||
|
|
There was a problem hiding this comment.
Layout/TrailingBlankLines: 1 trailing blank lines detected. (https://github.com/bbatsov/ruby-style-guide#newline-eof)
cmurphy
left a comment
There was a problem hiding this comment.
This is awesome! Will try to do a more thorough review tomorrow.
| end | ||
|
|
||
| reloadable_parameters = [ | ||
| "log_line_prefix" |
There was a problem hiding this comment.
I think log_truncate_on_ration and log_filename are also reloadable.
Postgresql can be queried for whether a parameter requires a reload or restart with "select context from pg_settings where name = 'log_line_prefix';", maybe at some point in the future we could utilize that.
|
Kicked off another run of the CI |
DavidRabel-b1
left a comment
There was a problem hiding this comment.
Looks good to me and it works(, now that my mysterious logging problem is gone). ;)
| variables( | ||
| config: config_needs_restart.sort | ||
| ) | ||
| notifies change_notify, "service[postgresql]", :immediately |
There was a problem hiding this comment.
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.
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.
I happened to be checking it in non-ha mode.
|
The reload need to be fixed - as per colleen's report. |
Reload postgresql's configuration gracefully. See commit messages for the details