arsenal-devel team mailing list archive
-
arsenal-devel team
-
Mailing list archive
-
Message #00109
Checking Launchpad service availability via a script
I run a heap of various automated scripts to process/measure/update bug
reports and other stuff on launchpad.
So, as you can imagine, whenever Launchpad goes down for maintenance, it
fills my email box with cron error messages like the one below. Bleah!
Unfortunately, it's difficult to easily detect from a cron job whether
or not Launchpad should be up. (I can't just ignore errors entirely,
because an unexpected LP unavailability could be an issue I need to do
something about!)
To solve this, I've dummied up a little script, launchpad-service-status:
http://bazaar.launchpad.net/~arsenal-devel/arsenal/python-launchpadlib-toolkit/view/head:/scripts/launchpad-service-status
The script first checks Launchpad's official outage notice blog to see
if the outage is expected, and then pokes Launchpad's API to see if it
actually works. It then prints one of the following results and exits
with the corresponding error code:
0 UP READWRITE
1 UP READONLY
2 PENDING OFFLINE
3 OFFLINE EXPECTED
9 OFFLINE UNKNOWN
The script is sort of an ugly hack, but seems to work with 4 minutes
worth of testing.
While I've "solved" the problem for myself, it would be sweet if there
was a way to mechanically get this info reliably (i.e. without having to
parse blogs/identica or blindly poke at launchpad itself and
catch and interpret HTTP error codes).
Bryce
----- Forwarded message from Cron Daemon <root@xxxxxxxxxxxxxxxxxxx> -----
Date: Wed, 9 Feb 2011 16:01:47 -0800
From: Cron Daemon <root@xxxxxxxxxxxxxxxxxxx>
To: bryce@localhost6.localdomain6
Subject: Cron <bryce@blumonc> /home/bryce/src/Arsenal/arsenal/hooks/data-patches (failed)
Traceback (most recent call last):
File "/home/bryce/src/Arsenal/arsenal/scripts//collect-patch-bugs", line 33, in <module>
s = d.getSourcePackage(name = source_pkg)
File "/usr/lib/python2.6/dist-packages/lazr/restfulclient/resource.py", line 528, in __call__
url, in_representation, http_method, extra_headers=extra_headers)
File "/usr/lib/python2.6/dist-packages/lazr/restfulclient/_browser.py", line 277, in _request
raise HTTPError(response, content)
lazr.restfulclient.errors.HTTPError: HTTP Error 503: Service Unavailable
Response headers:
---
connection: close
content-length: 5690
content-type: text/html;charset=utf-8
date: Thu, 10 Feb 2011 00:01:47 GMT
server: zope.server.http (HTTP)
status: 503
via: 1.1 wildcard.launchpad.net
x-powered-by: Zope (www.zope.org), Python (www.python.org)
---
Response body:
---
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
lang="en" dir="ltr">
<head>
<title>Error: you can't do this right now</title>
<link rel="shortcut icon" href="/@@/launchpad.png" />
<link type="text/css" rel="stylesheet"
media="screen, print"
href="/+icing/rev12335/combo.css" />
<style type="text/css">
fieldset.collapsed div, fieldset div.collapsed {display: none;}
</style>
<noscript>
<style type="text/css">
fieldset.collapsible div, fieldset div.collapsed {display: block;}
</style>
</noscript>
<script type="text/javascript"
src="/+icing/rev12335/MochiKit.js"></script>
<script type="text/javascript"
src="/+icing/rev12335/build/launchpad.js"></script>
<script type="text/javascript">var cookie_scope = '; Path=/; Secure; Domain=.launchpad.net';</script>
<script type="text/javascript">
// Define a global YUI sandbox that should be used by everyone.
var LPS = YUI({
// Don't try to fetch the loader module.
bootstrap: false,
// Don't try to fetch CSS files.
fetchCSS: false,
// Turn off combo loading.
combine: false,
// For paranoia, set a low timeout to not wait on loading a resource.
timeout: 50
});
</script>
<script id="base-layout-load-scripts" type="text/javascript">
LPS.use('node', 'lp', function(Y) {
Y.on('load', function(e) {
sortables_init();
initInlineHelp();
Y.lp.activate_collapsibles();
activateFoldables();
activateConstrainBugExpiration();
}, window);
// Hook up the function that dismisses the help window if we click
// anywhere outside of it.
Y.on('click', handleClickOnPage, window);
});
LPS.use('lp.app.links',
function(Y) {
Y.on('load', function(e) {
Y.lp.app.links.check_valid_lp_links();
}, window);
});
</script>
</head>
<body id="document"
class="tab-unknown
locationless
public
yui3-skin-sam">
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-12833497-1']);
_gaq.push(['_setDomainName', '.launchpad.net']);
_gaq.push(['_setAllowHash', false]);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);
})();
</script>
<div class="yui-d0">
<div id="locationbar" class="login-logout">
<div id="logincontrol"><a href="https://api.launchpad.net/1.0/ubuntu/+login?name=%22fglrx-installer%22&ws.op=getSourcePackage">Log in / Register</a></div>
</div><!--id="locationbar"-->
<div id="maincontent" class="yui-main">
<div class="yui-b" dir="ltr">
<div class="top-portlet">
<h1 class="exception">Sorry, you can't do this right now</h1>
<p>
You cannot make any changes at this time. Launchpad is
undergoing maintenance and is running in
<strong>read-only</strong> mode.
</p>
<p>Normal service will resume as soon as possible. You can find more
information on the <a href="http://identi.ca/launchpadstatus">
Launchpad system status</a> page.
</p>
</div>
</div><!-- yui-b -->
</div><!-- yui-main -->
<!-- yui-b side -->
<!-- yui-t4 -->
<div id="footer" class="footer">
<div class="lp-arcana">
<div class="lp-branding">
<a href="https://launchpad.net/"><img src="/@@/launchpad-logo-and-name-hierarchy.png" alt="Launchpad" /></a>
•
<a href="https://launchpad.net/+tour">Take the tour</a>
•
<a href="https://help.launchpad.net/">Read the guide</a>
</div>
</div>
<div class="colophon">
© 2004-2011
<a href="http://canonical.com/">Canonical Ltd.</a>
•
<a href="https://launchpad.net/legal">Terms of use</a>
•
<a href="/feedback">Contact Launchpad Support</a>
•
<a href="http://identi.ca/launchpadstatus">System status</a>
<span id="lp-version">
•
r12335
(<a href="https://code.launchpad.net/~launchpad-pqm/launchpad/stable/">get the code</a>)
</span>
</div>
</div>
</div><!-- yui-d0-->
<div id="help-pane" class="invisible">
<div id="help-body">
<iframe id="help-pane-content" class="invisible" src="javascript:void(0);"></iframe>
</div>
<div id="help-footer">
<span id="help-close"></span>
</div>
</div>
</body>
</html>
<!--
Facet name: unknown
Page type: locationless
Has global search: False
Has application tabs: False
Has side portlets: False
At least 2 queries/external actions issued in 0.06 seconds
Features: {}
in scopes {}
r12335
-->
---
Error: (1) Could not create patches.json at /tmp/patchyYNoE5
----- End forwarded message -----