buildbot: correct monotone source step

Markus Wanner <[email protected]>
Newsgroups gmane.comp.version-control.monotone.devel,gmane.comp.python.buildbot.devel
Message-ID <[email protected]>
Hi,

on buildbot.monotone.ca, a buildbot master instance is running. As
recently brought up on IRC, I had issues with it since I switched to use
the newer server-side source step.

The attached patch fixes two issues in steps/source/mtn.py:

 a) in _sourcedirIsUpdatable, the inline function cont served as a
    callback to the deferred returned by _sourcedirIsUpdatable. However,
    it uses d.addCallback, where d is what's calling it. I.e. at the
    time of execution, d is already called. It seems strange to add
    another callback. Further, and probably the actual bug: It doesn't
    return a value. I think that's what led to the hang I originally
    discovered.

    I fixed it rewriting _sourcedirIsUpdatable as an inlined
    callback method, which first checks for the existence of both, the
    _MTN directory and the database db.mtn, and only decides *after*
    both checks. I added proper logging to simplify debugging in the
    future.

 b) startVC calls _checkDb, which in turn runs 'mtn db info' on the
    database db.mtn. However, if the database doesn't exist, yet, that
    command fails, writing an error message to stderr (not stdout).
    This aborts the entire step, rather than creating and filling the
    database.

    The fix in the patch is not optimal: I simply set abandonOnFailure
    to False. A better solution would be to check for the existence of
    the database db.mtn first (that's done in _sourcedirIsUpdatable,
    anyways) and only run 'mtn db info' if it is known to exist. (Or
    skip the existence test and properly parse stderr. However, that
    seems prone to error, IMO.)

The patch as attached applies to buildbot release 0.8.10. I'm happy to
test an improved variant of it, if necessary.

Regards

Markus Wanner

_______________________________________________
Monotone-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/monotone-devel
buildbot_mtn_fix.diff (text/x-patch, 1.9 KB)
*** a/buildbot/steps/source/mtn.py.orig	2015-04-16 22:27:34.336585869 +0200
--- b/buildbot/steps/source/mtn.py	2015-04-17 14:33:35.539813501 +0200
***************
*** 319,325 ****
          return d
  
      def _checkDb(self):
!         d = self._dovccmd(['mtn', 'db', 'info', '--db', self.database], collectStdout=True)
  
          def checkInfo(stdout):
              if stdout.find("does not exist") > 0:
--- 319,327 ----
          return d
  
      def _checkDb(self):
!         d = self._dovccmd(['mtn', 'db', 'info', '--db', self.database],
!                           collectStdout=True,
!                           abandonOnFailure=False)
  
          def checkInfo(stdout):
              if stdout.find("does not exist") > 0:
***************
*** 337,352 ****
          d.addCallback(checkInfo)
          return d
  
      def _sourcedirIsUpdatable(self):
!         d = self.pathExists(self.build.path_module.join(self.workdir, '_MTN'))
  
!         def cont(res):
!             if res:
!                 d.addCallback(lambda _: self.pathExists('db.mtn'))
!             else:
!                 return False
!         d.addCallback(cont)
!         return d
  
      def finish(self, res):
          d = defer.succeed(res)
--- 339,358 ----
          d.addCallback(checkInfo)
          return d
  
+     @defer.inlineCallbacks
      def _sourcedirIsUpdatable(self):
!         workdir_path = self.build.path_module.join(self.workdir, '_MTN')
!         workdir_exists = yield self.pathExists(workdir_path)
  
!         db_path = self.build.path_module.join(self.workdir, self.database)
!         db_exists = yield self.pathExists(db_path)
! 
!         if not db_exists:
!             log.msg("Database does not exist, fallback to a fresh clone")
!         if not workdir_exists:
!             log.msg("Workdir does not exist, fallback to a fresh clone")
! 
!         defer.returnValue(db_exists and workdir_exists)
  
      def finish(self, res):
          d = defer.succeed(res)
signature.asc (application/pgp-signature, 1.5 KB)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQQcBAEBCgAGBQJVMQSFAAoJEOhoLRs/MemzYSAgAKr7EqOER+Yui/3MIFgxqNPq
jj2bTv6r5LPs25t5gv6nF0e28gXXTLQzKSK3F+WFULJbzYGvNErs6C8F9u0co0Jt
OQH9lOWAbljRUPo6sfsBwb9dTZdt3ILfROk9CHcQvEnoQu2oOrn2OcdkRWYRlEeX
dSUuTodqfJttsKkg+qKHvoL5SGBxrnWxT2K8h81afQJkvHKk8CdM41bQ2HQDSmIj
7EEH8z4XXBLoi20Xqgo5tf/94yUYs0I9z+pAUpB4gP0CR0i393oEe3xDFKPY6PJF
Tm5Cyo1OkF2z+7FW6PXLCwPda2hUia7khJs6ZdZu651SwTHWQkIxAsJCUGAmg0hv
scqtBc03qFR2gTPjUF6zyNpIfQuWVyB8Xe5RUZ0kafqsiHySvhuVWZNLK4u95iGV
k+Am4ZXnUw+1/nDASI2c0AGFdiMQdqVvhuQazY4XnRfzNH9CZes+jp2OoAF/S0SV
osyVY7RhoRa0eGO8T9H1o2lbGxoa13n3Ab3HO2qu1ydv5tjsD8WD/xmEntzH7NNz
sbvBC/QcKIf3viOHBYxL/oVOQqu1oyiN4Jt/1NRRKweMy8zjI1mp5KxUK82wzRI4
y7EjeHbQqtk/odAWjDYDJKiobPzCVPiEEgvbLQOi/AawZX/i86Isz0wQTzR2KUbn
Mj/oP7Ay+FtnM4DavTiFgjfY9+xBakphadSBdblYOtNjMnLGzASLarllseXf2xD9
/hgjFRqrpSABFhLeIkpccedsT+DiV8dXDOFM6PHJO5KfJUSO+B4aNbvOtN7mlOiV
zQcT+q6vLY7kYTgV5PdUFftA3mHy0Xv3XQSzqHdmqUf63QYlZMDdzw9nl7Gf8r8a
oT5vnZIeJ1lyK/xHborDB2uUCx/gSub334GG8Vji7alcNZckeWNNt8P0Sn10dYoQ
xTR2w6EVU1kRPN4Yx3KUVYsyiEBL1xd8ZwSK2H4vq4/iHNRe9bAPhtjNWq246v4G
iquhNvS3iz0KcY+kAQp6piq9KG1ZJjxeucfzMyokQD913UdNfQCiL+DHkvinMaVq
uHLq8244uA9mQW8savKI0U/fLMwQSMGeBJEa0PBFkpx5enX/5p/wCspQBe4QdxdY
Vb1790WvO1Hrxo1iLi74xVZNx+vOu2cll/yLR6WFhlZ8ShXHpFNvCnSGFnTWvSdz
wQ5fuSXDiMKh94oTMYH22g07xnj+ofKUdpigBeYuE+vq3jzUgSs1LMwQ93NxkjTS
47NYO9wJxYjnsHK9feqSlY8C7ahnN+nv8TT5n3V45Zs88Pr5vISJ2ZEDRPLDoBku
GJ6LbGh3g8MBZSu9qG0Kevy9vC4PoWU1ICWHmkpJBkhRxmRPFxiXOOyvBJ+6cco=
=3y2l
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.