extras-buildsys/builder Builder.py, 1.13, 1.14 BuilderMock.py, 1.7, 1.8

Daniel Williams (dcbw) fedora-extras-commits at redhat.com
Tue May 16 15:49:58 UTC 2006


Author: dcbw

Update of /cvs/fedora/extras-buildsys/builder
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv26625/builder

Modified Files:
	Builder.py BuilderMock.py 
Log Message:
2006-05-16  Dan Williams  <dcbw at redhat.com>

    * Make passive builders work somewhat more; there are still some bugs
        in command processing though.




Index: Builder.py
===================================================================
RCS file: /cvs/fedora/extras-buildsys/builder/Builder.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- Builder.py	15 May 2006 17:26:45 -0000	1.13
+++ Builder.py	16 May 2006 15:49:50 -0000	1.14
@@ -235,7 +235,9 @@
     def _dispatch_server_command(self, cmd):
         """Process a single command from the server."""
 
-        if isinstance(cmd, Commands.PlgCommandNewJobReq):
+        if isinstance(cmd, Commands.PlgCommandKillJob):
+            self._handle_kill_job_command(cmd)
+        elif isinstance(cmd, Commands.PlgCommandNewJobReq):
             (uniqid, msg) = self._start_new_job(cmd)
             ack = Commands.PlgCommandNewJobAck(uniqid, msg, cmd.seq(), self._seq_gen.next())
             self._queued_cmds.append(ack)
@@ -249,8 +251,6 @@
             reply = self._handle_job_files_request(cmd)
             if reply:
                 self._queued_cmds.append(reply)
-        elif isinstance(cmd, Commands.PlgCommandKillJob):
-            self._handle_kill_job_command(cmd)
 
     def _process_server_commands(self, cmd_list):
         """Process the server's command stream."""
@@ -347,8 +347,12 @@
     def _handle_kill_job_command(self, cmd):
         try:
             uniqid = cmd.archjob_id()
-            job = self._all_jobs[uniqid]
-            job.die()
+            archjob = self._all_jobs[uniqid]
+            archjob.die()
+            self._building_jobs_lock.acquire()
+            if archjob in self._building_jobs:
+                self._building_jobs.remove(archjob)
+            self._building_jobs_lock.release()
         except KeyError:
             pass
 
@@ -378,14 +382,18 @@
         """Startup HTTP and XML-RPC servers which the build server uses
         to talk to us."""
         hostname = get_hostname(self._cfg, bind_all=True)
-        self._log("Binding to address '%s'\n" % hostname)
+        xmlrpc_port = self._cfg.get_int("Passive", "xmlrpc_port")
+        
+        self._log("Binding to address '%s:%d'\n" % (hostname, xmlrpc_port))
 
         port = self._cfg.get_int("Passive", "fileserver_port")
-        self._http_server = HTTPServer.PlgHTTPServerManager((hostname, port),
-                self._work_dir, self._certs)
+        try:
+            self._http_server = HTTPServer.PlgHTTPServerManager((hostname, port),
+                    self._work_dir, self._certs)
+        except socket.error, exc:
+            raise socket.error(exc[0], "Couldn't create server for %s:%s: '%s'" % (hostname, port, exc[1]))
         self._http_server.set_POST_handler('/upload', self.upload_callback)
 
-        xmlrpc_port = self._cfg.get_int("Passive", "xmlrpc_port")
         try:
             if self._use_ssl:
                 self._xmlrpc_server = AuthedSSLXMLRPCServer((hostname, xmlrpc_port), None, self._certs)
@@ -471,8 +479,7 @@
     def request(self, cmd_list):
         """Main XML-RPC handler, called by the build server.  Dispatches
         the build server's requests and returns our response."""
-        cmds = Commands.deserialize_command_stream(cmd_list)
-        self._process_server_commands(cmds)
+        self._process_server_commands(cmd_list)
         cmds_for_server = self._get_default_commands()
         cmds_for_server = cmds_for_server + self._queued_cmds
         self._queued_cmds = []
@@ -532,6 +539,27 @@
         ul_callback(result, cb_data, msg)
         return None
 
+    def _handle_job_files_request(self, cmd):
+        """Return a list of urls of the result files of this job."""
+        archjob_id = cmd.archjob_id()
+        try:
+            job = self._all_jobs[archjob_id]
+        except KeyError:
+            return None
+
+        # url-ify the file list
+        urls = []
+        work_dir = self._get_workdir_for_job(job.uniqid())
+        port = "%s" % self._cfg.get_int("Network", "fileserver_port")
+        host = prefix_url(get_hostname(self._cfg))
+        for fpath in job.files():
+            if not fpath.startswith(work_dir):
+                return None
+            file_part = urllib.quote(fpath[len(work_dir) + 1:])
+            full_url = "%s:%s/%s" % (host, port, file_part)
+            urls.append(full_url)
+        return Commands.PlgCommandJobFilesAck(archjob_id, urls, cmd.seq(), self._seq_gen.next())
+
 
 # HACK: This class is a hack to work around SSL hanging issues,
 # which cause the whole server to grind to a halt


Index: BuilderMock.py
===================================================================
RCS file: /cvs/fedora/extras-buildsys/builder/BuilderMock.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- BuilderMock.py	15 May 2006 17:26:45 -0000	1.7
+++ BuilderMock.py	16 May 2006 15:49:50 -0000	1.8
@@ -36,21 +36,6 @@
 from plague import FileTransfer
 
 
-def get_url_for_file(cfg, file_path):
-    """ Return a URL pointing to a particular file in our work dir """
-
-    # Ensure the file we're turning into a URL lives in our builder work dir
-    work_dir = cfg.get_str("Directories", "builder_work_dir")
-    if not file_path.startswith(work_dir):
-        return None
-    file_part = file_path[len(work_dir) + 1:]
-    port = "%s" % cfg.get_int("Network", "fileserver_port")
-    hostname = Builder.get_hostname(cfg)
-    full_url = "%s:%s/%s" % (hostname, port, file_part)
-    full_url = Builder.prefix_url(full_url, cfg.get_bool("SSL", "use_ssl"))
-    return urllib.quote(full_url)
-
-
 class BuilderMock(threading.Thread):
     """puts things together for an arch - baseclass for handling builds for 
        other arches"""




More information about the fedora-extras-commits mailing list