mirror of
https://github.com/xcat2/confluent.git
synced 2024-11-25 11:01:09 +00:00
Migrate DB on start
If python2 db format detected, use python2 to dump to text, then python3 to restore to get the python3 native version
This commit is contained in:
parent
6f484aab53
commit
db5c31030d
@ -69,6 +69,7 @@ if args[0] == 'restore':
|
||||
if options.interactivepassword:
|
||||
password = getpass.getpass('Enter password to restore backup: ')
|
||||
try:
|
||||
cfm.init(True)
|
||||
cfm.statelessmode = True
|
||||
cfm.restore_db_from_directory(dumpdir, password)
|
||||
cfm.statelessmode = False
|
||||
|
@ -565,6 +565,8 @@ def _load_dict_from_dbm(dpath, tdb):
|
||||
currdict[tks] = cPickle.loads(dbe[tk]) # nosec
|
||||
tk = dbe.nextkey(tk)
|
||||
except dbm.error:
|
||||
if os.path.exists(tdb):
|
||||
raise
|
||||
return
|
||||
|
||||
|
||||
|
@ -29,6 +29,10 @@ import atexit
|
||||
import confluent.auth as auth
|
||||
import confluent.config.conf as conf
|
||||
import confluent.config.configmanager as configmanager
|
||||
try:
|
||||
import anydbm as dbm
|
||||
except ModuleNotFoundError:
|
||||
import dbm
|
||||
import confluent.consoleserver as consoleserver
|
||||
import confluent.core as confluentcore
|
||||
import confluent.httpapi as httpapi
|
||||
@ -62,8 +66,10 @@ import os
|
||||
import glob
|
||||
import signal
|
||||
import socket
|
||||
import subprocess
|
||||
import time
|
||||
import traceback
|
||||
import tempfile
|
||||
import uuid
|
||||
|
||||
|
||||
@ -232,8 +238,20 @@ def sanity_check():
|
||||
assure_ownership('/etc/confluent/srvcert.pem')
|
||||
|
||||
|
||||
def migrate_db():
|
||||
tdir = tempfile.mkdtemp()
|
||||
subprocess.check_call(['python2', '/opt/confluent/bin/confluentdbutil', 'dump', '-u', tdir])
|
||||
subprocess.check_call(['python3', '/opt/confluent/bin/confluentdbutil', 'restore', '-u', tdir])
|
||||
subprocess.check_call(['rm', '-rf', tdir])
|
||||
configmanager.init()
|
||||
|
||||
|
||||
def run(args):
|
||||
setlimits()
|
||||
try:
|
||||
configmanager.ConfigManager(None)
|
||||
except dbm.error:
|
||||
migrate_db()
|
||||
try:
|
||||
signal.signal(signal.SIGUSR1, dumptrace)
|
||||
except AttributeError:
|
||||
|
Loading…
Reference in New Issue
Block a user