~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/buildmaster/model/builder.py

[r=jml][ui=none][bug=586359] Work around a bug in builder Xen guests
        where it sometimes appears to drop the first network packet. We
        send a fake ping message before building.

Show diffs side-by-side

added added

removed removed

Lines of Context:
512
512
        else:
513
513
            d = defer.succeed(None)
514
514
 
515
 
        def resume_done(ignored):
 
515
        def ping_done(ignored):
516
516
            return self.current_build_behavior.dispatchBuildToSlave(
517
517
                build_queue_item.id, logger)
518
518
 
519
 
        def eb_slave_failure(failure):
520
 
            failure.trap(BuildSlaveFailure)
521
 
            e = failure.value
522
 
            self.failBuilder(
523
 
                "Exception (%s) when setting up to new job" % (e,))
524
 
 
525
 
        def eb_cannot_fetch_file(failure):
526
 
            failure.trap(CannotFetchFile)
527
 
            e = failure.value
528
 
            message = """Slave '%s' (%s) was unable to fetch file.
529
 
            ****** URL ********
530
 
            %s
531
 
            ****** INFO *******
532
 
            %s
533
 
            *******************
534
 
            """ % (self.name, self.url, e.file_url, e.error_information)
535
 
            raise BuildDaemonError(message)
536
 
 
537
 
        def eb_socket_error(failure):
538
 
            failure.trap(socket.error)
539
 
            e = failure.value
540
 
            error_message = "Exception (%s) when setting up new job" % (e,)
541
 
            d = self.handleTimeout(logger, error_message)
542
 
            return d.addBoth(lambda ignored: failure)
 
519
        def resume_done(ignored):
 
520
            # Before we try and contact the resumed slave, we're going
 
521
            # to send it a message.  This is to ensure it's accepting
 
522
            # packets from the outside world, because testing has shown
 
523
            # that the first packet will randomly fail for no apparent
 
524
            # reason.  This could be a quirk of the Xen guest, we're not
 
525
            # sure.  We also don't care about the result from this message,
 
526
            # just that it's sent, hence the "addBoth".
 
527
            # See bug 586359.
 
528
            if self.virtualized:
 
529
                d = self.slave.echo("ping")
 
530
            else:
 
531
                d = defer.succeed(None)
 
532
            d.addBoth(ping_done)
 
533
            return d
543
534
 
544
535
        d.addCallback(resume_done)
545
 
        d.addErrback(eb_slave_failure)
546
 
        d.addErrback(eb_cannot_fetch_file)
547
 
        d.addErrback(eb_socket_error)
548
536
        return d
549
537
 
550
538
    def failBuilder(self, reason):