Skip to content

Commit

Permalink
Merge pull request #1985 from phillxnet/1983_regression_-_source_buil…
Browse files Browse the repository at this point in the history
…d_fails_to_fully_initialise_db

regression - source build fails to fully initialise db. Fixes #1983
  • Loading branch information
schakrava authored Nov 10, 2018
2 parents 8ceef40 + cee4cdf commit 71f6657
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 9 deletions.
30 changes: 22 additions & 8 deletions buildout.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ parts =
stop-rockstor
django
scripts
postgres-setup
postgres-conf
# postgres-setup
# postgres-conf
gunicorn
nginx-conf
shellinabox-conf
Expand All @@ -35,14 +35,15 @@ parts =
js-libraries
js-sync
collectstatic
gulp-install
supervisor
supervisord-conf
create-cert
docker-conf
rockstor-pre-systemd-conf
rockstor-systemd-conf
bootstrap-systemd-conf
# Note the following systemd links are checked / updated in turn by '.initrock'
setup-systemd-links
def-kernel
start-rockstor

Expand Down Expand Up @@ -73,13 +74,26 @@ recipe = plone.recipe.command
command = systemctl stop rockstor
update-command = ${stop-rockstor:command}

[setup-systemd-links]
recipe = plone.recipe.command
command =
cp -f ${buildout:directory}/conf/rockstor-pre.service /etc/systemd/system/rockstor-pre.service &&
systemctl enable rockstor-pre.service &&
cp -f ${buildout:directory}/conf/rockstor.service /etc/systemd/system/rockstor.service &&
systemctl enable rockstor.service &&
cp -f ${buildout:directory}/conf/rockstor-bootstrap.service /etc/systemd/system/rockstor-bootstrap.service &&
systemctl enable rockstor-bootstrap.service &&
systemctl daemon-reload
update-command = ${setup-systemd-links:command}

[start-rockstor]
recipe = plone.recipe.command
command = cp -f ${buildout:directory}/conf/rockstor-pre.service /etc/systemd/system/rockstor-pre.service &&
systemctl enable rockstor-pre.service &&
systemctl daemon-reload &&
systemctl restart rockstor-pre
systemctl start rockstor
# We stop rockstor-pre, just in case, to invoke a re-run via start of rockstor.
command =
systemctl stop rockstor-pre &&
# Following rockstor start will in turn start rockstor-pre if found stopped.
# We then follow / test the usual systemd execution chain.
systemctl start rockstor
update-command = ${start-rockstor:command}


Expand Down
11 changes: 10 additions & 1 deletion src/rockstor/scripts/initrock.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ def main():
logging.debug('Progresql enabled')
pg_data = '/var/lib/pgsql/data'
if (os.path.isdir(pg_data)):
logger.debug('Deleting /var/lib/pgsql/data')
shutil.rmtree('/var/lib/pgsql/data')
logging.info('initializing Postgresql...')
run_command(['/usr/bin/postgresql-setup', 'initdb'])
Expand Down Expand Up @@ -382,8 +383,14 @@ def main():
logging.info('Running app database migrations...')
migration_cmd = [DJANGO, 'migrate', '--noinput', ]
fake_migration_cmd = migration_cmd + ['--fake']
fake_initial_migration_cmd = migration_cmd + ['--fake-initial']
smartdb_opts = ['--database=smart_manager', 'smart_manager']

# Migrate Content types before individual apps
logger.debug('migrate (--fake-initial) contenttypes')
run_command(
fake_initial_migration_cmd + ['--database=default', 'contenttypes'])

for app in ('storageadmin', 'smart_manager'):
db = 'default'
if app == 'smart_manager':
Expand All @@ -397,11 +404,13 @@ def main():
break
if not initial_faked:
db_arg = '--database=%s' % db
logger.debug('migrate (--fake) db=({}) app=({}) 0001_initial'
.format(db, app))
run_command(fake_migration_cmd + [db_arg, app, '0001_initial'])

run_command(migration_cmd + ['auth'])
run_command(migration_cmd + ['storageadmin'])
run_command(migration_cmd + smartdb_opts)
run_command(migration_cmd + ['auth'])
run_command(migration_cmd + ['django_ztask'])
logging.info('Done')
logging.info('Running prepdb...')
Expand Down

0 comments on commit 71f6657

Please sign in to comment.