Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

regression - source build fails to fully initialise db. Fixes #1983 #1985

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 22 additions & 8 deletions buildout.cfg
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
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