pld-builder.new: PLD_Builder/rpm_builder.py New way of skipping requests.

arekm arekm at pld-linux.org
Wed Jul 15 14:35:20 CEST 2009


Author: arekm                        Date: Wed Jul 15 12:35:20 2009 GMT
Module: pld-builder.new               Tag: HEAD
---- Log message:
New way of skipping requests.

---- Files affected:
pld-builder.new/PLD_Builder:
   rpm_builder.py (1.86 -> 1.87) 

---- Diffs:

================================================================
Index: pld-builder.new/PLD_Builder/rpm_builder.py
diff -u pld-builder.new/PLD_Builder/rpm_builder.py:1.86 pld-builder.new/PLD_Builder/rpm_builder.py:1.87
--- pld-builder.new/PLD_Builder/rpm_builder.py:1.86	Wed Jul 15 14:24:54 2009
+++ pld-builder.new/PLD_Builder/rpm_builder.py	Wed Jul 15 14:35:14 2009
@@ -51,6 +51,26 @@
     ret = q.requests[0]
     return ret
 
+def check_skip_build(r):
+    src_url = config.control_url + "/srpms/" + r.id + "/skipme"
+    good  = True
+    while not good:
+        try:
+            good=True
+            f = urllib.urlopen(src_url)
+        except IOError, error:
+            if error[1][0] == 60 or error[1][0] == 110 or error[1][0] == -3 or error[1][0] == 111 or error[1][0] == 61:
+                good=False
+                b.log_line("unable to connect... trying again")
+                continue
+            else:
+                return False
+        http_code = f.getcode()
+        if http_code == 200:
+            f.close()
+            return True
+    return False
+
 def fetch_src(r, b):
     src_url = config.control_url + "/srpms/" + r.id + "/" + b.src_rpm
     b.log_line("fetching %s" % src_url)
@@ -69,28 +89,11 @@
                 raise
         http_code = f.getcode()
         if http_code != 200:
-            # if .uploadinfo also doesn't exist this means that someone
-            # deleted files at src builder side and we should fail then
-            try:
-                fui = urllib.urlopen(src_url + '.uploadinfo')
-            except IOError, error:
-                f.close()
-                # cron job will retry then
-                raise
-            if fui.getcode() != 200:
-                # no uploadinfo, so we can fail with this job in a way
-                # that it will be skipped from queue
-                b.log_line("uploadinfo file doesn't exists or is inaccesible - failing to skip this build (http code: %d)" % http_code)
+                # fail in a way where cron job will retry
+                msg = "unable to fetch file, http code: %d" % http_code
+                b.log_line(msg)
                 f.close()
-                fui.close()
-                return False
-            else:
-                # uploadinfo file exists but we weren't able to fetch original file,
-                # so we fail in a way where cron job will retry
-                b.log_line("unable to fetch file, http code: %d" % http_code)
-                f.close()
-                fui.close()
-                raise IOError, "unable to fetch file, http code: %d" % http_code
+                raise IOError, msg
 
     o = chroot.popen("cat > %s" % b.src_rpm, mode = "w")
 
@@ -121,6 +124,12 @@
 def build_rpm(r, b):
     status.push("building %s" % b.spec)
     b.log_line("request from: %s" % r.requester)
+
+    if check_skip_build(r):
+        b.log_line("build skipped due to src builder request")
+        res = "SKIP_REQUESTED"
+        return res
+
     b.log_line("started at: %s" % time.asctime())
     fetch_src(r, b)
     b.log_line("installing srpm: %s" % b.src_rpm)
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/pld-builder.new/PLD_Builder/rpm_builder.py?r1=1.86&r2=1.87&f=u



More information about the pld-cvs-commit mailing list