Skip to content

Commit

Permalink
Update deployment script to check for indexes in advance. (oppia#6300)
Browse files Browse the repository at this point in the history
* Update deployment script to check for indexes in advance.

* Address review comments.
  • Loading branch information
seanlip authored and apb7 committed Feb 21, 2019
1 parent 545664d commit 2bba36e
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
10 changes: 10 additions & 0 deletions scripts/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ def open_new_tab_in_browser_if_possible(url):
if subprocess.call(['which', cmd]) == 0:
subprocess.call([cmd, url])
return
print '******************************************************************'
print 'WARNING: Unable to open browser. Please manually open the following '
print 'URL in a browser window, then press Enter to confirm.'
print ''
print ' %s' % url
print ''
print 'NOTE: To get rid of this message, open scripts/common.py and fix'
print 'the function open_new_tab_in_browser_if_possible() to work on your'
print 'system.'
raw_input()


def get_remote_alias(remote_url):
Expand Down
33 changes: 30 additions & 3 deletions scripts/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
'appcfg.py')

LOG_FILE_PATH = os.path.join('..', 'deploy.log')
INDEX_YAML_PATH = os.path.join('.', 'index.yaml')
THIRD_PARTY_DIR = os.path.join('.', 'third_party')
DEPLOY_DATA_PATH = os.path.join(
os.getcwd(), os.pardir, 'release-scripts', 'deploy_data', APP_NAME)
Expand Down Expand Up @@ -245,6 +246,32 @@ def _execute_deployment():
print 'Preprocessing release...'
preprocess_release()

# Update indexes, then prompt for a check that they are all serving
# before continuing with the deployment.
# NOTE: This assumes that the build process does not modify the
# index.yaml file or create a different version of it to use in
# production.
assert os.path.isfile(INDEX_YAML_PATH)
subprocess.check_output([
common.GCLOUD_PATH, '--quiet', 'datastore', 'indexes', 'create',
INDEX_YAML_PATH, '--project=%s' % APP_NAME])
datastore_indexes_url = (
'https://console.cloud.google.com/datastore/indexes?project=%s' %
APP_NAME)
common.open_new_tab_in_browser_if_possible(datastore_indexes_url)
while True:
print '******************************************************'
print (
'PLEASE CONFIRM: are all datastore indexes serving? See %s '
'(y/n)' % datastore_indexes_url)
answer = raw_input().lower()
if answer in ['y', 'ye', 'yes']:
break
elif answer:
raise Exception(
'Please wait for all indexes to serve, then run this '
'script again to complete the deployment. Exiting.')

# Do a build, while outputting to the terminal.
print 'Building and minifying scripts...'
build_process = subprocess.Popen(
Expand All @@ -263,7 +290,7 @@ def _execute_deployment():

# Deploy export service to GAE.
subprocess.check_output([
common.GCLOUD_PATH, 'app', 'deploy', 'export/app.yaml',
common.GCLOUD_PATH, '--quiet', 'app', 'deploy', 'export/app.yaml',
'--project=%s' % APP_NAME])

# Deploy app to GAE.
Expand All @@ -284,12 +311,12 @@ def _execute_deployment():
# error logs.
if (APP_NAME == APP_NAME_OPPIATESTSERVER or 'migration' in APP_NAME) and (
_get_served_version() == _get_current_release_version()):
common.open_new_tab_in_browser_if_possible(
'https://%s.appspot.com/library' % APP_NAME_OPPIATESTSERVER)
common.open_new_tab_in_browser_if_possible(
'https://console.cloud.google.com/logs/viewer?'
'project=%s&key1=default&minLogLevel=500'
% APP_NAME_OPPIATESTSERVER)
common.open_new_tab_in_browser_if_possible(
'https://%s.appspot.com/library' % APP_NAME_OPPIATESTSERVER)

print 'Done!'

Expand Down

0 comments on commit 2bba36e

Please sign in to comment.