From 83d4c2151c25d3e3fc03f59315ddad864051bbd7 Mon Sep 17 00:00:00 2001 From: Navraj Chohan Date: Wed, 24 Oct 2012 13:09:28 -0700 Subject: [PATCH 01/11] Fixes from code review --- AppController/lib/custom_exceptions.rb | 8 +++ AppController/lib/error_app.rb | 78 ++++++++++++++++++++++++++ AppController/test/tc_error_app.rb | 34 +++++++++++ 3 files changed, 120 insertions(+) create mode 100644 AppController/lib/custom_exceptions.rb create mode 100644 AppController/lib/error_app.rb create mode 100644 AppController/test/tc_error_app.rb diff --git a/AppController/lib/custom_exceptions.rb b/AppController/lib/custom_exceptions.rb new file mode 100644 index 0000000000..a92fce71ca --- /dev/null +++ b/AppController/lib/custom_exceptions.rb @@ -0,0 +1,8 @@ +# Programmer: Navraj Chohan + +class AppScaleException < Exception +end + +class FailedShellExec < Exception +end + diff --git a/AppController/lib/error_app.rb b/AppController/lib/error_app.rb new file mode 100644 index 0000000000..395a423f45 --- /dev/null +++ b/AppController/lib/error_app.rb @@ -0,0 +1,78 @@ +#!/usr/bin/ruby -w + +require 'fileutils' + +$:.unshift File.join(File.dirname(__FILE__)) +require 'custom_exceptions' +require 'helperfunctions' + +$:.unshift File.join(File.dirname(__FILE__), "..") +require 'djinn' + + +# This class generates a Python Google App Engine application that +# relays an error message to the user as to why their app failed to come up +class ErrorApp + + def initialize(app_name, error_msg) + @app_name = app_name + @error_msg = error_msg + @dir_path = "/var/apps/#{app_name}/app/" + end + + # This function places an updated app.yaml and error.py into the application + # and retars the application file + def generate() + app_yaml = <') + self.response.out.write("""

Your application failed to start

""") + self.response.out.write("""

#{@error_msg}

""") + self.response.out.write("""

If this is an AppScale issue please report it on http://github.com/AppScale/appscale/issues

""") + self.response.out.write('') + +application = webapp.WSGIApplication([ + ('/', MainPage), +], debug=True) + + +def main(): + wsgiref.handlers.CGIHandler().run(application) + + +if __name__ == '__main__': + main() + +SCRIPT + + HelperFunctions.write_file(@dir_path + 'app.yaml', app_yaml) + HelperFunctions.write_file(@dir_path + "#{@app_name}.py", script) + + Djinn.log_run("rm #{@dir_path}/#{@app_name}.tar.gz") + ret = 0 + Dir.chdir(@dir_path) do + Djinn.log_debug("Running: tar zcvf #{@dir_path}/#{@app_name}.tar.gz #{@dir_path}") + Djinn.log_run("tar zcvf #{@app_name}.tar.gz app.yaml #{@app_name}.py") + end + + return true + end + +end + diff --git a/AppController/test/tc_error_app.rb b/AppController/test/tc_error_app.rb new file mode 100644 index 0000000000..d3486d5607 --- /dev/null +++ b/AppController/test/tc_error_app.rb @@ -0,0 +1,34 @@ +# Programmer: Navraj Chohan + +$:.unshift File.join(File.dirname(__FILE__), "..") +require 'djinn' + +$:.unshift File.join(File.dirname(__FILE__), "../..", "lib") +require 'error_app' +require 'helperfunctions' + +require 'rubygems' +require 'flexmock/test_unit' + + +class TestErrorApp < Test::Unit::TestCase + def setup + djinn = flexmock(Djinn) + djinn.should_receive(:log_run).and_return() + djinn.should_receive(:log_debug).and_return() + + dir = flexmock(Dir) + dir.should_receive(:chdir).and_return() + + helper_functions = flexmock(HelperFunctions) + helper_functions.should_receive(:write_file).and_return() + end + + def test_creation + errorapp = flexmock(ErrorApp) + assert_nothing_raised(Exception) { + ea_class = ErrorApp.new("testapp", "ERROR") + ea_class.generate() + } + end +end From ac8b0aa613bf269ee6d6501c772222ff1650d7d8 Mon Sep 17 00:00:00 2001 From: Navraj Chohan Date: Wed, 24 Oct 2012 13:11:27 -0700 Subject: [PATCH 02/11] Fixes from code review --- AppController/djinnServer.rb | 2 ++ AppController/test/ts_all.rb | 1 + debian/appscale_build.sh | 2 +- debian/appscale_install_functions.sh | 10 ++++++++++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/AppController/djinnServer.rb b/AppController/djinnServer.rb index 9ec4daa8b4..228751bc58 100644 --- a/AppController/djinnServer.rb +++ b/AppController/djinnServer.rb @@ -70,6 +70,8 @@ def on_init `rm -f #{APPSCALE_HOME}/.appscale/status-*` `rm -f #{APPSCALE_HOME}/.appscale/database_info` `rm -f /tmp/mysql.sock` + + Nginx.clear_sites_enabled Collectd.clear_sites_enabled HAProxy.clear_sites_enabled diff --git a/AppController/test/ts_all.rb b/AppController/test/ts_all.rb index 532c03d5c8..58d7dcc345 100644 --- a/AppController/test/ts_all.rb +++ b/AppController/test/ts_all.rb @@ -3,6 +3,7 @@ $:.unshift File.join(File.dirname(__FILE__)) # AppController library tests +require 'tc_error_app' require 'tc_infrastructure_manager_client' require 'tc_repo' require 'tc_zkinterface' diff --git a/debian/appscale_build.sh b/debian/appscale_build.sh index dc09139b9c..42ddfcee9c 100755 --- a/debian/appscale_build.sh +++ b/debian/appscale_build.sh @@ -130,7 +130,7 @@ fi # remove conflict package apt-get -y purge haproxy -#apt-get -y remove consolekit +apt-get -y remove consolekit bash debian/appscale_install.sh all mkdir -p $APPSCALE_HOME_RUNTIME/.appscale/certs diff --git a/debian/appscale_install_functions.sh b/debian/appscale_install_functions.sh index 4fa6903d57..a3a6014ced 100644 --- a/debian/appscale_install_functions.sh +++ b/debian/appscale_install_functions.sh @@ -258,6 +258,11 @@ installtornado() fi } +installflexmock() +{ + easy_install flexmock || exit 1 +} + postinstalltornado() { # just enable tornado @@ -471,6 +476,11 @@ installgems() # This is for the LogManager, which will rotate logs on a daily basis. gem install -v=1.2.1 logrotate ${GEMOPT} || exit 1 + + # This is for the unit testing framework + gem install -v=1.0.4 flexmock ${GEMOPT} || exit 1 + gem install -v=1.0.0 rcov ${GEMOPT} || exit 1 + } postinstallgems() From 1031ddd25f70a373324239c8117f954212cb0f4d Mon Sep 17 00:00:00 2001 From: Navraj Chohan Date: Wed, 24 Oct 2012 13:11:43 -0700 Subject: [PATCH 03/11] Fixes from code review --- AppController/djinn.rb | 105 ++++++++++++++++++++++++++--------------- 1 file changed, 66 insertions(+), 39 deletions(-) diff --git a/AppController/djinn.rb b/AppController/djinn.rb index 88892ce31a..bdec1f3668 100644 --- a/AppController/djinn.rb +++ b/AppController/djinn.rb @@ -20,27 +20,26 @@ # Imports for AppController libraries $:.unshift File.join(File.dirname(__FILE__), "lib") -require 'helperfunctions' +require 'app_controller_client' +require 'blobstore' +require 'custom_exceptions' +require 'ejabberd' +require 'error_app' +require 'collectd' require 'cron_helper' +require 'godinterface' require 'haproxy' -require 'collectd' -require 'nginx' +require 'helperfunctions' +require 'infrastructure_manager_client' +require 'neptune_manager_client' require 'pbserver' -require 'blobstore' +require 'nginx' require 'rabbitmq' -require 'app_controller_client' -require 'user_app_client' -require 'ejabberd' require 'repo' +require 'user_app_client' require 'zkinterface' -require 'godinterface' -require 'infrastructure_manager_client' -require 'neptune_manager_client' -class AppScaleException < Exception -end - WANT_OUTPUT = true @@ -1543,7 +1542,6 @@ def write_zookeeper_locations def update_api_status() - return if my_node.is_appengine? repo_host = my_node.private_ip else @@ -2129,7 +2127,7 @@ def change_job() retval = 0 while retries > 0 replication = @creds["replication"] - Djinn.log_run("MASTER_IP='localhost' LOCAL_DB_IP='localhost' python2.6 #{prime_script} #{replication}; echo $? > /tmp/retval") + Djinn.log_run("APPSCALE_HOME='#{APPSCALE_HOME}' MASTER_IP='localhost' LOCAL_DB_IP='localhost' python2.6 #{prime_script} #{replication}; echo $? > /tmp/retval") retval = `cat /tmp/retval`.to_i break if retval == 0 Djinn.log_debug("Fail to create initial table. Retry #{retries} times.") @@ -2245,7 +2243,7 @@ def start_pbserver zoo_connection = get_zk_connection_string(@nodes) PbServer.start(db_master_ip, @userappserver_private_ip, my_ip, table, zoo_connection) HAProxy.create_pbserver_config(my_node.private_ip, PbServer::PROXY_PORT, table) - Nginx.create_pbserver_config(my_ip, PbServer::PROXY_PORT) + Nginx.create_pbserver_config(my_node.private_ip, PbServer::PROXY_PORT) Nginx.restart() # TODO check the return value @@ -2741,6 +2739,16 @@ def stop_shadow() Djinn.log_debug("Stopping Shadow role") end + # Swaps out an application with one that relays an error message to the + # developer. It will take the application that currently exists in the + # application folder, delete it, and place templated app that prints out the + # given error message. + def place_error_app(app_name, err_msg) + Djinn.log_debug("Placing error application for #{app_name} because of: #{err_msg}") + ea = ErrorApp.new(app_name, err_msg) + ea.generate() + end + def start_appengine() @state = "Preparing to run AppEngine apps if needed" Djinn.log_debug("Starting appengine - pbserver is at [#{@userappserver_private_ip}]") @@ -2803,7 +2811,10 @@ def start_appengine() app_path = "#{app_dir}/#{app}.tar.gz" FileUtils.mkdir_p(app_dir) - copy_app_to_local(app) + if !copy_app_to_local(app) + place_error_app(app, "ERROR: Failed to copy app: #{app}") + next + end HelperFunctions.setup_app(app) @@ -2813,14 +2824,16 @@ def start_appengine() end app_number = @nginx_port - Nginx::START_PORT proxy_port = HAProxy.app_listen_port(app_number) - login_ip = get_login.public_ip + login_ip = get_login.private_ip if my_node.is_login? and !my_node.is_appengine? success = Nginx.write_fullproxy_app_config(app, app_number, my_public, my_private, proxy_port, login_ip, get_all_appengine_nodes()) if success Nginx.reload else - Djinn.log_debug("ERROR: Failure to create valid nginx config file for application #{app} full proxy.") + err_msg = "ERROR: Failure to create valid nginx config file"\ + " for application #{app} full proxy." + place_error_app(app, err_msg) next end @nginx_port += 1 @@ -2831,13 +2844,21 @@ def start_appengine() if my_node.is_appengine? app_number = @nginx_port - Nginx::START_PORT start_port = HelperFunctions::APP_START_PORT - static_handlers = HelperFunctions.parse_static_data(app) + begin + static_handlers = HelperFunctions.parse_static_data(app) + rescue Exception + error_msg = "ERROR: Unable to parse app.yaml file for #{app}.") + place_error_app(app, error_msg) + next + end proxy_port = HAProxy.app_listen_port(app_number) - login_ip = get_login.public_ip - success = Nginx.write_app_config(app, app_number, my_public, + login_ip = get_login.private_ip + success = Nginx.write_app_config(app, app_number, my_public, my_private, proxy_port, static_handlers, login_ip) - if not success - Djinn.log_debug("ERROR: Failure to create valid nginx config file for application #{app}.") + if !success + error_msg = "ERROR: Failure to create valid nginx config file " + \ + "for application #{app}." + place_error_app(app, error_msg) next end Collectd.write_app_config(app) @@ -2859,14 +2880,14 @@ def start_appengine() @userappserver_private_ip, get_load_balancer_ip(), my_private, app_version, app_language, @nginx_port, xmpp_ip) if pid == -1 - Djinn.log_debug("ERROR: Unable to start application #{app}.") + place_error_app(app, "ERROR: Unable to start application #{app}. Please check the application logs.") next end pid_file_name = "/etc/appscale/#{app}-#{@appengine_port}.pid" HelperFunctions.write_file(pid_file_name, pid) - location = "http://#{my_public}:#{@appengine_port}#{warmup_url}" + location = "http://#{my_private}:#{@appengine_port}#{warmup_url}" wget_cmd = "wget #{WGET_OPTIONS} #{location}" Djinn.log_run(wget_cmd) @@ -2875,7 +2896,7 @@ def start_appengine() } HAProxy.update_app_config(app, app_number, - @app_info_map[app][:appengine], my_public) + @app_info_map[app][:appengine], my_private) Nginx.reload HAProxy.reload Collectd.restart @@ -2903,7 +2924,7 @@ def start_appengine() login_ip = get_login.public_ip Thread.new { - haproxy_location = "http://#{my_public}:#{haproxy}#{warmup_url}" + haproxy_location = "http://#{my_private}:#{haproxy}#{warmup_url}" nginx_location = "http://#{my_public}:#{nginx}#{warmup_url}" wget_haproxy = "wget #{WGET_OPTIONS} #{haproxy_location}" @@ -3209,7 +3230,7 @@ def add_appserver_process(app) my_private = my_node.private_ip Djinn.log_debug("port apps error contains - #{@app_info_map[app][:appengine]}") HAProxy.update_app_config(app, app_number, @app_info_map[app][:appengine], - my_public) + my_private) Djinn.log_debug("Adding #{app_language} app #{app} on #{HelperFunctions.local_ip}:#{@appengine_port} ") xmpp_ip = get_login.public_ip @@ -3221,7 +3242,7 @@ def add_appserver_process(app) pid_file_name = "#{APPSCALE_HOME}/.appscale/#{app}-#{@appengine_port}.pid" HelperFunctions.write_file(pid_file_name, pid) - location = "http://#{my_public}:#{@appengine_port}#{warmup_url}" + location = "http://#{my_private}:#{@appengine_port}#{warmup_url}" wget_cmd = "wget #{WGET_OPTIONS} #{location}" Djinn.log_run(wget_cmd) @@ -3234,10 +3255,8 @@ def add_appserver_process(app) # add_instance_info = uac.add_instance(app, my_public, @nginx_port) - login_ip = get_login.public_ip - Thread.new { - haproxy_location = "http://#{my_public}:#{haproxy_port}#{warmup_url}" + haproxy_location = "http://#{my_private}:#{haproxy_port}#{warmup_url}" nginx_location = "http://#{my_public}:#{nginx_port}#{warmup_url}" wget_haproxy = "wget #{WGET_OPTIONS} #{haproxy_location}" @@ -3294,7 +3313,7 @@ def remove_appserver_process(app) @app_info_map[app][:appengine].delete(port) HAProxy.update_app_config(app, app_number, @app_info_map[app][:appengine], - my_public) + my_private) HAProxy.reload end @@ -3441,11 +3460,19 @@ def start_sisyphus my_public = my_node.public_ip my_private = my_node.private_ip - login_ip = get_login.public_ip - - static_handlers = HelperFunctions.parse_static_data(app) + public_login_ip = get_login.public_ip + private_login_ip = get_login.private_ip + + begin + static_handlers = HelperFunctions.parse_static_data(app) + rescue Exception => e + error_msg = "ERROR: Unable to parse app.yaml file for #{app}." + \ + " Exception of type #{e.class}" + place_error_app(app, error_msg) + next + end proxy_port = HAProxy.app_listen_port(app_number) - Nginx.write_app_config(app, app_number, my_public, proxy_port, static_handlers, login_ip) + Nginx.write_app_config(app, app_number, my_public, my_private, proxy_port, static_handlers, private_login_ip) HAProxy.write_app_config(app, app_number, num_servers, my_private) Collectd.write_app_config(app) @@ -3453,7 +3480,7 @@ def start_sisyphus Djinn.log_debug("Starting #{app_language} app #{app} on " + "#{HelperFunctions.local_ip}:#{port}") pid = HelperFunctions.run_app(app, port, @userappserver_private_ip, - my_public, my_private, app_version, app_language, nginx_port, login_ip) + my_public, my_private, app_version, app_language, nginx_port, public_login_ip) pid_file_name = "#{APPSCALE_HOME}/.appscale/#{app}-#{port}.pid" HelperFunctions.write_file(pid_file_name, pid) } From 7501e4b3a02f31c78819a16b336e043856cf82f6 Mon Sep 17 00:00:00 2001 From: Navraj Chohan Date: Wed, 24 Oct 2012 13:23:46 -0700 Subject: [PATCH 04/11] Fixes syntax error --- AppController/djinn.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/AppController/djinn.rb b/AppController/djinn.rb index bdec1f3668..8abfe54342 100644 --- a/AppController/djinn.rb +++ b/AppController/djinn.rb @@ -2847,7 +2847,7 @@ def start_appengine() begin static_handlers = HelperFunctions.parse_static_data(app) rescue Exception - error_msg = "ERROR: Unable to parse app.yaml file for #{app}.") + error_msg = "ERROR: Unable to parse app.yaml file for #{app}." place_error_app(app, error_msg) next end @@ -2880,7 +2880,8 @@ def start_appengine() @userappserver_private_ip, get_load_balancer_ip(), my_private, app_version, app_language, @nginx_port, xmpp_ip) if pid == -1 - place_error_app(app, "ERROR: Unable to start application #{app}. Please check the application logs.") + place_error_app(app, "ERROR: Unable to start application " + \ + "#{app}. Please check the application logs.") next end From b0c8cd7106ff69bcf90cefd581ba32ac602325f5 Mon Sep 17 00:00:00 2001 From: Navraj Chohan Date: Wed, 24 Oct 2012 13:45:02 -0700 Subject: [PATCH 05/11] Added useful comments for exceptions --- AppController/lib/custom_exceptions.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/AppController/lib/custom_exceptions.rb b/AppController/lib/custom_exceptions.rb index a92fce71ca..bf3c23b90d 100644 --- a/AppController/lib/custom_exceptions.rb +++ b/AppController/lib/custom_exceptions.rb @@ -1,8 +1,14 @@ # Programmer: Navraj Chohan +# A class of exceptions that can be thrown if the AppController is put into an +# unrecoverable state, or a state that we would not normally expect a perfectly +# working AppScale system to get into. class AppScaleException < Exception end +# A class of exceptions that can be thrown if the AppController +# (or its associated libraries) attempts to execute shell commands which +# do not return properly (specifically, not having a return value of zero). class FailedShellExec < Exception end From 68e82dfc0fb74c10facb736e155001703c77d22f Mon Sep 17 00:00:00 2001 From: Navraj Chohan Date: Wed, 24 Oct 2012 13:51:10 -0700 Subject: [PATCH 06/11] Added comments and removed useless line --- AppController/djinn.rb | 1 + AppController/lib/error_app.rb | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/AppController/djinn.rb b/AppController/djinn.rb index 8abfe54342..e7fadada9b 100644 --- a/AppController/djinn.rb +++ b/AppController/djinn.rb @@ -2847,6 +2847,7 @@ def start_appengine() begin static_handlers = HelperFunctions.parse_static_data(app) rescue Exception + # This specific exception may be a json parse error error_msg = "ERROR: Unable to parse app.yaml file for #{app}." place_error_app(app, error_msg) next diff --git a/AppController/lib/error_app.rb b/AppController/lib/error_app.rb index 395a423f45..21bb2650e1 100644 --- a/AppController/lib/error_app.rb +++ b/AppController/lib/error_app.rb @@ -65,7 +65,6 @@ def main(): HelperFunctions.write_file(@dir_path + "#{@app_name}.py", script) Djinn.log_run("rm #{@dir_path}/#{@app_name}.tar.gz") - ret = 0 Dir.chdir(@dir_path) do Djinn.log_debug("Running: tar zcvf #{@dir_path}/#{@app_name}.tar.gz #{@dir_path}") Djinn.log_run("tar zcvf #{@app_name}.tar.gz app.yaml #{@app_name}.py") From 5d5aa39cbdd088ca0bfafc6b8b73e66b9e0615ed Mon Sep 17 00:00:00 2001 From: Navraj Chohan Date: Thu, 25 Oct 2012 20:32:51 +0000 Subject: [PATCH 07/11] Updated doc for function --- AppController/djinn.rb | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/AppController/djinn.rb b/AppController/djinn.rb index f3417fdfaa..792638b022 100644 --- a/AppController/djinn.rb +++ b/AppController/djinn.rb @@ -2739,10 +2739,19 @@ def stop_shadow() Djinn.log_debug("Stopping Shadow role") end + # # Swaps out an application with one that relays an error message to the # developer. It will take the application that currently exists in the - # application folder, delete it, and place templated app that prints out the - # given error message. + # application folder, deletes it, and places a templated app that prints out the + # given error message. + # + # Args: + # app_name: Name of application + # err_msg: Message to relay to developer + # + # Returns: + # Returns: Nothing + # def place_error_app(app_name, err_msg) Djinn.log_debug("Placing error application for #{app_name} because of: #{err_msg}") ea = ErrorApp.new(app_name, err_msg) From a01e251acb6604c0bea9e309b3a039cd5ec9e071 Mon Sep 17 00:00:00 2001 From: Navraj Chohan Date: Thu, 25 Oct 2012 22:56:37 +0000 Subject: [PATCH 08/11] Commenting fixes --- AppController/djinn.rb | 14 ++++---------- AppController/lib/error_app.rb | 16 +++++++++++++--- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/AppController/djinn.rb b/AppController/djinn.rb index 721573bd35..ee3f07c137 100644 --- a/AppController/djinn.rb +++ b/AppController/djinn.rb @@ -2746,8 +2746,9 @@ def stop_shadow() # given error message. # # Args: - # app_name: Name of application - # err_msg: Message to relay to developer + # app_name: Name of application to construct an error application for + # err_msg: A String message that will be displayed as + # the reason why we couldn't start their application. # # Returns: # Returns: Nothing @@ -2822,7 +2823,6 @@ def start_appengine() if !copy_app_to_local(app) place_error_app(app, "ERROR: Failed to copy app: #{app}") - next end HelperFunctions.setup_app(app) @@ -2843,7 +2843,6 @@ def start_appengine() err_msg = "ERROR: Failure to create valid nginx config file"\ " for application #{app} full proxy." place_error_app(app, err_msg) - next end @nginx_port += 1 @haproxy_port += 1 @@ -2859,7 +2858,6 @@ def start_appengine() # This specific exception may be a json parse error error_msg = "ERROR: Unable to parse app.yaml file for #{app}." place_error_app(app, error_msg) - next end proxy_port = HAProxy.app_listen_port(app_number) login_ip = get_login.private_ip @@ -2869,7 +2867,6 @@ def start_appengine() error_msg = "ERROR: Failure to create valid nginx config file " + \ "for application #{app}." place_error_app(app, error_msg) - next end Collectd.write_app_config(app) @@ -2892,7 +2889,6 @@ def start_appengine() if pid == -1 place_error_app(app, "ERROR: Unable to start application " + \ "#{app}. Please check the application logs.") - next end pid_file_name = "/etc/appscale/#{app}-#{@appengine_port}.pid" @@ -3480,11 +3476,9 @@ def start_sisyphus error_msg = "ERROR: Unable to parse app.yaml file for #{app}." + \ " Exception of type #{e.class}" place_error_app(app, error_msg) - next end proxy_port = HAProxy.app_listen_port(app_number) - Nginx.write_app_config(app, app_number, my_public, my_private, - proxy_port, static_handlers, login_ip) + Nginx.write_app_config(app, app_number, my_public, my_private, proxy_port, static_handlers, private_login_ip) HAProxy.write_app_config(app, app_number, num_servers, my_private) Collectd.write_app_config(app) diff --git a/AppController/lib/error_app.rb b/AppController/lib/error_app.rb index 21bb2650e1..7c6dd81092 100644 --- a/AppController/lib/error_app.rb +++ b/AppController/lib/error_app.rb @@ -11,17 +11,27 @@ # This class generates a Python Google App Engine application that -# relays an error message to the user as to why their app failed to come up +# relays an error message to the user as to why their app failed to come up. class ErrorApp - + + # + # Constructor + # + # Args: + # app_name: Name of the application to construct an error application for. + # error_msg: A String message that will be displayed as the reason + # why we couldn't start their application. def initialize(app_name, error_msg) @app_name = app_name @error_msg = error_msg @dir_path = "/var/apps/#{app_name}/app/" end + # # This function places an updated app.yaml and error.py into the application - # and retars the application file + # and retars the application file. + # + # Args: None def generate() app_yaml = < Date: Thu, 25 Oct 2012 23:13:50 +0000 Subject: [PATCH 09/11] Print exception class for bad parsing of yaml --- AppController/djinn.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/AppController/djinn.rb b/AppController/djinn.rb index ee3f07c137..78f529d1e8 100644 --- a/AppController/djinn.rb +++ b/AppController/djinn.rb @@ -2840,7 +2840,7 @@ def start_appengine() if success Nginx.reload else - err_msg = "ERROR: Failure to create valid nginx config file"\ + err_msg = "ERROR: Failure to create valid nginx config file" + \ " for application #{app} full proxy." place_error_app(app, err_msg) end @@ -2854,9 +2854,10 @@ def start_appengine() start_port = HelperFunctions::APP_START_PORT begin static_handlers = HelperFunctions.parse_static_data(app) - rescue Exception + rescue Exception => e # This specific exception may be a json parse error - error_msg = "ERROR: Unable to parse app.yaml file for #{app}." + error_msg = "ERROR: Unable to parse app.yaml file for #{app}." + \ + " Exception of #{e.class}" place_error_app(app, error_msg) end proxy_port = HAProxy.app_listen_port(app_number) From e9f60437ad35c5eddc2f2cb97b441e70dd087447 Mon Sep 17 00:00:00 2001 From: Navraj Chohan Date: Thu, 25 Oct 2012 23:19:14 +0000 Subject: [PATCH 10/11] Print exception message for bad parsing of yaml --- AppController/djinn.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AppController/djinn.rb b/AppController/djinn.rb index 78f529d1e8..2c9a89457d 100644 --- a/AppController/djinn.rb +++ b/AppController/djinn.rb @@ -2857,7 +2857,7 @@ def start_appengine() rescue Exception => e # This specific exception may be a json parse error error_msg = "ERROR: Unable to parse app.yaml file for #{app}." + \ - " Exception of #{e.class}" + " Exception of #{e.class} with message #{e.message}" place_error_app(app, error_msg) end proxy_port = HAProxy.app_listen_port(app_number) From 1b0ffb8f99db103ae23df55c65bd08741ead3a1c Mon Sep 17 00:00:00 2001 From: Navraj Chohan Date: Thu, 25 Oct 2012 23:21:11 +0000 Subject: [PATCH 11/11] Print exception message for bad parsing of yaml --- AppController/djinn.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AppController/djinn.rb b/AppController/djinn.rb index 2c9a89457d..388f4823d2 100644 --- a/AppController/djinn.rb +++ b/AppController/djinn.rb @@ -3475,7 +3475,7 @@ def start_sisyphus static_handlers = HelperFunctions.parse_static_data(app) rescue Exception => e error_msg = "ERROR: Unable to parse app.yaml file for #{app}." + \ - " Exception of type #{e.class}" + " Exception of type #{e.class}. Exception message #{e.message}" place_error_app(app, error_msg) end proxy_port = HAProxy.app_listen_port(app_number)