Browse code

Fix return code detection in plugin list generation

As can be seen in logs of the periodic generation job, our cgit does a
weird thing where sometimes it returns a 404 page with content, and
sometimes a zero response (see [1] for example, the last number is
response size). This appears to be an openstack CI issue; possibly
due to cgit caching or similar (see [2] for manual test). It will
have to be investigated with the host apache logs.

This is resulting in a lot of projects incorrectly being picked up as
having plugins (I7116571d2a2b1fc3a61e5f1ed46ac2cbc244775a). I'm not
sure if this problem is also releated to the original status-code
issues mentioned in the code, but testing shows that cgit is correctly
returning 404's for missing files (you can see in the logs [1]). Thus
switch the logic to examine the return code which avoids this issue.

[1] http://logs.openstack.org/periodic/propose-devstack-plugins-list/e55790c/console.html.gz#_2016-05-04_06_46_51_660
[2] http://paste.openstack.org/show/496434/

Change-Id: I6a06347d91d091441f6f7b70f99aba6d8e9add4b

Ian Wienand authored on 2016/05/09 12:19:09
Showing 1 changed files
... ...
@@ -44,16 +44,10 @@ def is_in_openstack_namespace(proj):
44 44
     # stackforge, etc)
45 45
     return proj.startswith('openstack/')
46 46
 
47
-# Rather than returning a 404 for a nonexistent file, cgit delivers a
48
-# 0-byte response to a GET request.  It also does not provide a
49
-# Content-Length in a HEAD response, so the way we tell if a file exists
50
-# is to check the length of the entire GET response body.
47
+# Check if this project has a plugin file
51 48
 def has_devstack_plugin(proj):
52 49
     r = requests.get("https://git.openstack.org/cgit/%s/plain/devstack/plugin.sh" % proj)
53
-    if len(r.text) > 0:
54
-        return True
55
-    else:
56
-        return False
50
+    return r.status_code == 200
57 51
 
58 52
 logging.debug("Getting project list from %s" % url)
59 53
 r = requests.get(url)