Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

postgresql: Decouple wal_g from streaming replication.

Alex Vandiver92121a06262d
diff --git a/puppet/zulip/manifests/profile/postgresql.pp b/puppet/zulip/manifests/profile/postgresql.pp
index c675f196047..614d7d8996d 100644
--- a/puppet/zulip/manifests/profile/postgresql.pp
+++ b/puppet/zulip/manifests/profile/postgresql.pp
@@ -55,13 +55,6 @@ class zulip::profile::postgresql {
}
if $replication_primary != undef and $replication_user != undef {
- if $s3_backups_bucket == '' {
- $message = @(EOT/L)
- Replication is enabled, but s3_backups_bucket is not set in zulip-secrets.conf! \
- Streaming replication requires wal-g backups be configured.
- |-EOT
- warning($message)
- }
# The presence of a standby.signal file triggers replication
file { "${zulip::postgresql_base::postgresql_datadir}/standby.signal":
ensure => file,
diff --git a/puppet/zulip/templates/postgresql/12/postgresql.conf.template.erb b/puppet/zulip/templates/postgresql/12/postgresql.conf.template.erb
index 67c861248d0..7c0fea8fd0a 100644
--- a/puppet/zulip/templates/postgresql/12/postgresql.conf.template.erb
+++ b/puppet/zulip/templates/postgresql/12/postgresql.conf.template.erb
@@ -788,17 +788,18 @@ listen_addresses = <%= @listen_addresses %>
<% end -%>
<% if @s3_backups_bucket != '' -%>
-# Streaming backups and replication
+# WAL backups to S3 (may also be used for replication)
archive_mode = on
archive_command = '/usr/bin/timeout 10m /usr/local/bin/env-wal-g wal-push %p'
restore_command = '/usr/local/bin/env-wal-g wal-fetch "%f" "%p"'
+<% end -%>
<% unless @replication_primary.nil? || @replication_user.nil? -%>
+# Streaming replication
primary_conninfo = 'host=<%= @replication_primary %> user=<%= @replication_user -%>
<% if @replication_password != '' %> password=<%= @replication_password %><% end -%>
<% unless @ssl_mode.nil? %> sslmode=<%= @ssl_mode %><% end -%>
'
<% end -%>
-<% end -%>
<% unless @ssl_cert_file.nil? -%>
ssl_cert_file = '<%= @ssl_cert_file %>' # (change requires restart)
diff --git a/puppet/zulip/templates/postgresql/13/postgresql.conf.template.erb b/puppet/zulip/templates/postgresql/13/postgresql.conf.template.erb
index 111eabb1ebe..45e63c4feab 100644
--- a/puppet/zulip/templates/postgresql/13/postgresql.conf.template.erb
+++ b/puppet/zulip/templates/postgresql/13/postgresql.conf.template.erb
@@ -819,17 +819,18 @@ listen_addresses = <%= @listen_addresses %>
<% end -%>
<% if @s3_backups_bucket != '' -%>
-# Streaming backups and replication
+# WAL backups to S3 (may also be used for replication)
archive_mode = on
archive_command = '/usr/bin/timeout 10m /usr/local/bin/env-wal-g wal-push %p'
restore_command = '/usr/local/bin/env-wal-g wal-fetch "%f" "%p"'
+<% end -%>
<% unless @replication_primary.nil? || @replication_user.nil? -%>
+# Streaming replication
primary_conninfo = 'host=<%= @replication_primary %> user=<%= @replication_user -%>
<% if @replication_password != '' %> password=<%= @replication_password %><% end -%>
<% unless @ssl_mode.nil? %> sslmode=<%= @ssl_mode %><% end -%>
'
<% end -%>
-<% end -%>
<% unless @ssl_cert_file.nil? -%>
ssl_cert_file = '<%= @ssl_cert_file %>' # (change requires restart)
diff --git a/puppet/zulip/templates/postgresql/14/postgresql.conf.template.erb b/puppet/zulip/templates/postgresql/14/postgresql.conf.template.erb
index cf3d7ff6c12..3a681009244 100644
--- a/puppet/zulip/templates/postgresql/14/postgresql.conf.template.erb
+++ b/puppet/zulip/templates/postgresql/14/postgresql.conf.template.erb
@@ -840,17 +840,18 @@ listen_addresses = <%= @listen_addresses %>
<% end -%>
<% if @s3_backups_bucket != '' -%>
-# Streaming backups and replication
+# WAL backups to S3 (may also be used for replication)
archive_mode = on
archive_command = '/usr/bin/timeout 10m /usr/local/bin/env-wal-g wal-push %p'
restore_command = '/usr/local/bin/env-wal-g wal-fetch "%f" "%p"'
+<% end -%>
<% unless @replication_primary.nil? || @replication_user.nil? -%>
+# Streaming replication
primary_conninfo = 'host=<%= @replication_primary %> user=<%= @replication_user -%>
<% if @replication_password != '' %> password=<%= @replication_password %><% end -%>
<% unless @ssl_mode.nil? %> sslmode=<%= @ssl_mode %><% end -%>
'
<% end -%>
-<% end -%>
<% unless @ssl_cert_file.nil? -%>
ssl_cert_file = '<%= @ssl_cert_file %>' # (change requires restart)
diff --git a/puppet/zulip/templates/postgresql/zulip.conf.template.erb b/puppet/zulip/templates/postgresql/zulip.conf.template.erb
index 943c12a2693..ca5fc7b0018 100644
--- a/puppet/zulip/templates/postgresql/zulip.conf.template.erb
+++ b/puppet/zulip/templates/postgresql/zulip.conf.template.erb
@@ -40,17 +40,18 @@ effective_io_concurrency = <%= @effective_io_concurrency %>
<% end -%>
<% if @s3_backups_bucket != '' -%>
-# Streaming backups and replication
+# WAL backups to S3 (may also be used for replication)
archive_mode = on
archive_command = '/usr/bin/timeout 10m /usr/local/bin/env-wal-g wal-push %p'
restore_command = '/usr/local/bin/env-wal-g wal-fetch "%f" "%p"'
+<% end -%>
<% unless @replication_primary.nil? || @replication_user.nil? -%>
+# Streaming replication
primary_conninfo = 'host=<%= @replication_primary %> user=<%= @replication_user -%>
<% if @replication_password != '' %> password=<%= @replication_password %><% end -%>
<% unless @ssl_mode.nil? %> sslmode=<%= @ssl_mode %><% end -%>
'
<% end -%>
-<% end -%>
<% unless @ssl_cert_file.nil? -%>
ssl_cert_file = '<%= @ssl_cert_file %>' # (change requires restart)