mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 21:13:36 +00:00
[manual] Change references to the humbug user, schema, and database to zulip
This commit must be simultaneously deployed on both staging and prod0. It also requires completely taking down the app. To deploy these changes, do: * check out this commit at /root/zulip on postgres0, postgres1, staging, and prod0 * stop the process_fts_updates job on postgres0 and postgres1 * stop the app on staging and prod0 * do a puppet apply on postgres0, postgres1, staging, and prod0 * move the new client certificates into place on staging and app * move the new server certificates into place on postgres0 and postgres1 * reload the database config on postgres0 and postgres1 (this might actually require a restart) * run tools/migrate-db on postgres0 as root * do a deploy through this commit on staging and prod0 * start the process_fts_updates job on postgres0 and postgres1 * do a puppet apply on nagios (imported from commit 819bdd14326c1425e2d3041a491a8ca3b9716506)
This commit is contained in:
@@ -88,12 +88,12 @@ define command{
|
||||
|
||||
define command{
|
||||
command_name check_postgres
|
||||
command_line /usr/lib/nagios/plugins/check_by_ssh -p $ARG1$ -l zulip -t 30 -i /var/lib/nagios/.ssh/id_rsa -H $HOSTADDRESS$ -C '/usr/lib/nagios/plugins/check_postgres.pl --dbname=humbug --dbuser=humbug --action $ARG2$'
|
||||
command_line /usr/lib/nagios/plugins/check_by_ssh -p $ARG1$ -l zulip -t 30 -i /var/lib/nagios/.ssh/id_rsa -H $HOSTADDRESS$ -C '/usr/lib/nagios/plugins/check_postgres.pl --dbname=zulip --dbuser=zulip --action $ARG2$'
|
||||
}
|
||||
|
||||
define command{
|
||||
command_name check_postgres_alert_args
|
||||
command_line /usr/lib/nagios/plugins/check_by_ssh -p $ARG1$ -l zulip -t 30 -i /var/lib/nagios/.ssh/id_rsa -H $HOSTADDRESS$ -C '/usr/lib/nagios/plugins/check_postgres.pl --dbname=humbug --dbuser=humbug --action $ARG2$ --warning="$ARG3$" --critical="$ARG4$"'
|
||||
command_line /usr/lib/nagios/plugins/check_by_ssh -p $ARG1$ -l zulip -t 30 -i /var/lib/nagios/.ssh/id_rsa -H $HOSTADDRESS$ -C '/usr/lib/nagios/plugins/check_postgres.pl --dbname=zulip --dbuser=zulip --action $ARG2$ --warning="$ARG3$" --critical="$ARG4$"'
|
||||
}
|
||||
|
||||
define command{
|
||||
|
||||
@@ -17,7 +17,7 @@ def report(state, num):
|
||||
print "%s: %s rows in fts_update_log table" % (state, num)
|
||||
exit(states[state])
|
||||
|
||||
conn = psycopg2.connect("host=localhost user=humbug")
|
||||
conn = psycopg2.connect("host=localhost user=zulip")
|
||||
cursor = conn.cursor()
|
||||
|
||||
cursor.execute("SELECT count(*) FROM fts_update_log")
|
||||
|
||||
@@ -22,7 +22,7 @@ def report(state, msg):
|
||||
def get_loc_over_ssh(host, func):
|
||||
try:
|
||||
return subprocess.check_output(['ssh', host, '-l', 'zulip',
|
||||
'psql -U humbug -t -c "SELECT %s()"' % (func,)],
|
||||
'psql -t -c "SELECT %s()"' % (func,)],
|
||||
stderr=subprocess.STDOUT)
|
||||
except subprocess.CalledProcessError as e:
|
||||
report('CRITICAL', 'ssh failed: %s: %s' % (str(e),e.output))
|
||||
|
||||
@@ -16,7 +16,7 @@ def report(state, msg):
|
||||
print "%s: %s" % (state, msg)
|
||||
exit(states[state])
|
||||
|
||||
if subprocess.check_output(['psql', '-h', 'localhost', 'humbug', 'humbug', '-t', '-c',
|
||||
if subprocess.check_output(['psql', '-h', 'localhost', 'zulip', 'zulip', '-t', '-c',
|
||||
'SELECT pg_is_in_recovery()']).strip() != 'f':
|
||||
report('OK', 'this is not the primary')
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ local all postgres peer
|
||||
|
||||
# TYPE DATABASE USER ADDRESS METHOD
|
||||
|
||||
local humbug humbug md5
|
||||
local zulip zulip md5
|
||||
|
||||
# "local" is for Unix domain socket connections only
|
||||
local all all peer
|
||||
@@ -100,9 +100,10 @@ host all all ::1/128 md5
|
||||
#host replication postgres 127.0.0.1/32 md5
|
||||
#host replication postgres ::1/128 md5
|
||||
|
||||
hostssl humbug humbug 10.252.136.89/32 cert # staging
|
||||
hostssl humbug humbug 10.254.4.7/32 cert # prod0
|
||||
hostssl humbug humbug 10.0.202.11/32 cert # test1
|
||||
hostssl zulip zulip 10.252.136.89/32 cert # staging
|
||||
hostssl zulip zulip 10.254.4.7/32 cert # prod0
|
||||
hostssl zulip zulip 10.0.202.11/32 cert # test1
|
||||
|
||||
|
||||
# TODO: use certs
|
||||
hostssl replication replicator 10.244.48.12/32 md5 # postgres1
|
||||
|
||||
@@ -564,7 +564,7 @@ shared_buffers = 7680MB # pgtune wizard 2013-04-12
|
||||
max_connections = 200 # pgtune wizard 2013-04-12
|
||||
|
||||
timezone = 'UTC'
|
||||
default_text_search_config = 'humbug.english_us_search'
|
||||
default_text_search_config = 'zulip.english_us_search'
|
||||
# From http://www.databasesoup.com/2012/05/random-page-cost-revisited.html
|
||||
# This needs actual measurement, as bonnie++ random seek latency is
|
||||
# actually a read/write test
|
||||
|
||||
@@ -564,7 +564,7 @@ shared_buffers = 1792MB # pgtune wizard 2012-12-12
|
||||
max_connections = 200 # pgtune wizard 2012-12-12
|
||||
|
||||
timezone = 'UTC'
|
||||
default_text_search_config = 'humbug.english_us_search'
|
||||
default_text_search_config = 'zulip.english_us_search'
|
||||
# EBS supposedly has very similar sequential and random access performance
|
||||
random_page_cost = 1.1
|
||||
listen_addresses = '*'
|
||||
|
||||
@@ -10,7 +10,7 @@ def update_fts_columns(cursor):
|
||||
ids = []
|
||||
for (id, message_id) in cursor.fetchall():
|
||||
cursor.execute("UPDATE zerver_message SET "
|
||||
"search_tsvector = to_tsvector('humbug.english_us_search', "
|
||||
"search_tsvector = to_tsvector('zulip.english_us_search', "
|
||||
"subject || rendered_content) "
|
||||
"WHERE id = %s", (message_id,))
|
||||
ids.append(id)
|
||||
@@ -27,7 +27,7 @@ logger.setLevel(logging.DEBUG)
|
||||
|
||||
logger.info("process_fts_updates starting")
|
||||
|
||||
conn = psycopg2.connect("host=localhost user=humbug")
|
||||
conn = psycopg2.connect("host=localhost user=zulip")
|
||||
cursor = conn.cursor()
|
||||
|
||||
conn.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT)
|
||||
|
||||
@@ -42,13 +42,13 @@ class zulip::local_server {
|
||||
source => 'puppet:///modules/zulip/humbug-server',
|
||||
}
|
||||
|
||||
file { "/usr/share/postgresql/9.1/tsearch_data/humbug_english.stop":
|
||||
file { "/usr/share/postgresql/9.1/tsearch_data/zulip_english.stop":
|
||||
require => Package["postgresql-9.1"],
|
||||
ensure => file,
|
||||
owner => "root",
|
||||
group => "root",
|
||||
mode => 644,
|
||||
source => "puppet:///modules/zulip/postgresql/humbug_english.stop",
|
||||
source => "puppet:///modules/zulip/postgresql/zulip_english.stop",
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,13 +32,13 @@ class zulip::postgres-appdb {
|
||||
source => "puppet:///modules/zulip/postgresql/pg_hba.conf",
|
||||
}
|
||||
|
||||
file { "/usr/share/postgresql/9.1/tsearch_data/humbug_english.stop":
|
||||
file { "/usr/share/postgresql/9.1/tsearch_data/zulip_english.stop":
|
||||
require => Package["postgresql-9.1"],
|
||||
ensure => file,
|
||||
owner => "root",
|
||||
group => "root",
|
||||
mode => 644,
|
||||
source => "puppet:///modules/zulip/postgresql/humbug_english.stop",
|
||||
source => "puppet:///modules/zulip/postgresql/zulip_english.stop",
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh -xe
|
||||
|
||||
echo "DROP SCHEMA humbug CASCADE; CREATE SCHEMA humbug;" | python manage.py dbshell
|
||||
echo "DROP SCHEMA zulip CASCADE; CREATE SCHEMA zulip;" | python manage.py dbshell
|
||||
|
||||
python manage.py syncdb --noinput
|
||||
python manage.py migrate
|
||||
|
||||
@@ -8,9 +8,9 @@ if [ "$(uname)" = "Darwin" ]; then
|
||||
fi
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
USERNAME=humbug
|
||||
USERNAME=zulip
|
||||
PASSWORD=xxxxxxxxxxxx
|
||||
DBNAME=humbug
|
||||
DBNAME=zulip
|
||||
SEARCH_PATH="$USERNAME",public
|
||||
elif [[ $# == 4 ]]; then
|
||||
USERNAME=$1
|
||||
@@ -19,7 +19,7 @@ elif [[ $# == 4 ]]; then
|
||||
SEARCH_PATH=$4
|
||||
else
|
||||
echo "Usage Instructions"
|
||||
echo "Run with either no arguments (sets up devel db for local deploy--humbug with user humbug)"
|
||||
echo "Run with either no arguments (sets up devel db for local deploy--zulip with user zulip)"
|
||||
echo "or specify <db-username> <password> <db-name> <user-schema-search-path>"
|
||||
exit
|
||||
fi
|
||||
|
||||
@@ -13,8 +13,8 @@ class Migration(SchemaMigration):
|
||||
|
||||
db.execute("""CREATE TEXT SEARCH DICTIONARY english_us_hunspell (template = ispell,
|
||||
DictFile = en_us, AffFile = en_us, StopWords = english)""")
|
||||
db.execute("CREATE TEXT SEARCH CONFIGURATION humbug.english_us_search (COPY=pg_catalog.english)")
|
||||
db.execute("""ALTER TEXT SEARCH CONFIGURATION humbug.english_us_search ALTER MAPPING FOR
|
||||
db.execute("CREATE TEXT SEARCH CONFIGURATION zulip.english_us_search (COPY=pg_catalog.english)")
|
||||
db.execute("""ALTER TEXT SEARCH CONFIGURATION zulip.english_us_search ALTER MAPPING FOR
|
||||
asciiword, asciihword, hword_asciipart, word, hword, hword_part
|
||||
WITH english_us_hunspell, english_stem""")
|
||||
|
||||
@@ -22,7 +22,7 @@ class Migration(SchemaMigration):
|
||||
if "postgres" not in settings.DATABASES["default"]["ENGINE"]:
|
||||
return
|
||||
|
||||
db.execute("DROP TEXT SEARCH CONFIGURATION humbug.english_us_search")
|
||||
db.execute("DROP TEXT SEARCH CONFIGURATION zulip.english_us_search")
|
||||
db.execute("DROP TEXT SEARCH DICTIONARY english_us_hunspell")
|
||||
|
||||
models = {
|
||||
|
||||
@@ -17,12 +17,12 @@ class Migration(DataMigration):
|
||||
db.execute("""CREATE TRIGGER zephyr_message_update_search_tsvector
|
||||
BEFORE INSERT OR UPDATE OF subject, rendered_content ON zephyr_message
|
||||
FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger(search_tsvector,
|
||||
'humbug.english_us_search', subject, rendered_content)""")
|
||||
'zulip.english_us_search', subject, rendered_content)""")
|
||||
db.commit_transaction()
|
||||
|
||||
(min_id, max_id) = db.execute("SELECT MIN(id), MAX(id) FROM zephyr_message")[0]
|
||||
if min_id is not None:
|
||||
self.set_search_tsvector('humbug.english_us_search', 'rendered_content',
|
||||
self.set_search_tsvector('zulip.english_us_search', 'rendered_content',
|
||||
min_id, max_id)
|
||||
|
||||
def set_search_tsvector(self, config, column, min_id, max_id):
|
||||
|
||||
@@ -8,7 +8,7 @@ from django.conf import settings
|
||||
class Migration(SchemaMigration):
|
||||
|
||||
def forwards(self, orm):
|
||||
db.execute("ALTER TEXT SEARCH DICTIONARY english_us_hunspell (StopWords = humbug_english)")
|
||||
db.execute("ALTER TEXT SEARCH DICTIONARY english_us_hunspell (StopWords = zulip_english)")
|
||||
|
||||
def backwards(self, orm):
|
||||
db.execute("ALTER TEXT SEARCH DICTIONARY english_us_hunspell (StopWords = english)")
|
||||
|
||||
@@ -40,7 +40,7 @@ class Migration(SchemaMigration):
|
||||
db.execute("CREATE TRIGGER zephyr_message_update_search_tsvector "
|
||||
"BEFORE INSERT OR UPDATE OF subject, rendered_content ON zephyr_message "
|
||||
"FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger(search_tsvector, "
|
||||
"'humbug.english_us_search', subject, rendered_content)")
|
||||
"'zulip.english_us_search', subject, rendered_content)")
|
||||
|
||||
db.execute("DROP TRIGGER zephyr_message_update_search_tsvector_async ON zephyr_message")
|
||||
db.execute("DROP FUNCTION append_to_fts_update_log()")
|
||||
|
||||
@@ -912,13 +912,13 @@ class NarrowBuilder(object):
|
||||
|
||||
def do_search(self, query, operand):
|
||||
if "postgres" in settings.DATABASES["default"]["ENGINE"]:
|
||||
tsquery = "plainto_tsquery('humbug.english_us_search', %s)"
|
||||
tsquery = "plainto_tsquery('zulip.english_us_search', %s)"
|
||||
where = "search_tsvector @@ " + tsquery
|
||||
match_content = "ts_headline('humbug.english_us_search', rendered_content, " \
|
||||
match_content = "ts_headline('zulip.english_us_search', rendered_content, " \
|
||||
+ tsquery + ", 'StartSel=\"<span class=\"\"highlight\"\">\", StopSel=</span>, " \
|
||||
"HighlightAll=TRUE')"
|
||||
# We HTML-escape the subject in Postgres to avoid doing a server round-trip
|
||||
match_subject = "ts_headline('humbug.english_us_search', escape_html(subject), " \
|
||||
match_subject = "ts_headline('zulip.english_us_search', escape_html(subject), " \
|
||||
+ tsquery + ", 'StartSel=\"<span class=\"\"highlight\"\">\", StopSel=</span>, " \
|
||||
"HighlightAll=TRUE')"
|
||||
|
||||
|
||||
@@ -62,11 +62,11 @@ MANAGERS = ADMINS
|
||||
|
||||
DATABASES = {"default": {
|
||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
||||
'NAME': 'humbug',
|
||||
'USER': 'humbug',
|
||||
'NAME': 'zulip',
|
||||
'USER': 'zulip',
|
||||
'PASSWORD': '', # Authentication done via certificates
|
||||
'HOST': 'postgres.humbughq.com',
|
||||
'SCHEMA': 'humbug',
|
||||
'HOST': 'postgres.zulip.net',
|
||||
'SCHEMA': 'zulip',
|
||||
'OPTIONS': {
|
||||
'sslmode': 'verify-full',
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user