[Buildbot-commits] buildbot/buildbot/process step.py,1.72,1.73

Brian Warner warner at users.sourceforge.net
Mon Oct 24 21:39:54 UTC 2005


Update of /cvsroot/buildbot/buildbot/buildbot/process
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19252/buildbot/process

Modified Files:
	step.py 
Log Message:
Revision: arch at buildbot.sf.net--2004/buildbot--dev--0--patch-376
Creator:  Brian Warner <warner at lothar.com>

improve VC handling of old buildslaves, sometimes refuse to build

	* buildbot/process/step.py (CVS.startVC): refuse to build
	update/copy -style builds on a non-default branch with an old
	buildslave (<=0.6.6) that doesn't know how to do it properly. The
	concern is that it will do a VC 'update' in an existing tree when
	it is supposed to be switching branches (and therefore clobbering
	the tree to do a full checkout), thus building the wrong source.
	This used to be a warning, but I think the confusion it is likely
	to cause warrants making it an error.
	(SVN.startVC): same, also make mode=export on old slaves an error
	(Darcs.startVC): same
	(Git.startVC): improve error message for non-Git-enabled slaves
	(Arch.checkSlaveVersion): same. continue to emit a warning when a
	specific revision is built on a slave that doesn't pay attention
	to args['revision'], because for slowly-changing trees it will
	probably do the right thing, and because we have no way to tell
	whether we're asking it to build the most recent version or not.
	* buildbot/interfaces.py (BuildSlaveTooOldError): new exception

	* buildbot/scripts/runner.py (SlaveOptions.postOptions): assert
	that 'master' is in host:portnum format, to catch errors sooner


Index: step.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/process/step.py,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -d -r1.72 -r1.73
--- step.py	22 Oct 2005 23:22:10 -0000	1.72
+++ step.py	24 Oct 2005 21:39:52 -0000	1.73
@@ -9,6 +9,7 @@
 from twisted.python.failure import Failure
 from twisted.web.util import formatFailure
 
+from buildbot.interfaces import BuildSlaveTooOldError
 from buildbot.util import now
 from buildbot.status import progress, builder
 from buildbot.status.builder import SUCCESS, WARNINGS, FAILURE, SKIPPED, \
@@ -920,13 +921,14 @@
     to override __init__ and implement computeSourceRevision() and
     startVC(). The class as a whole builds up the self.args dictionary, then
     starts a LoggedRemoteCommand with those arguments.
-
     """
 
     # if the checkout fails, there's no point in doing anything else
     haltOnFailure = True
     notReally = False
 
+    branch = None # the default branch, should be set in __init__
+
     def __init__(self, workdir, mode='update', alwaysUseLatest=False,
                  timeout=20*60, retry=None, **kwargs):
         """
@@ -1126,7 +1128,7 @@
                       it was previously performed or not.
 
         @type  branch: string
-        @param branch: the default branch nane, will be used in a '-r'
+        @param branch: the default branch name, will be used in a '-r'
                        argument to specify which branch of the source tree
                        should be used for this checkout. Defaults to None,
                        which means to use 'HEAD'.
@@ -1189,6 +1191,23 @@
         return formatdate(when)
 
     def startVC(self, branch, revision, patch):
+        if not self.slaveVersionNewEnough("cvs", "1.39"):
+            # the slave doesn't know to avoid re-using the same sourcedir
+            # when the branch changes. We have no way of knowing which branch
+            # the last build used, so if we're using a non-default branch and
+            # either 'update' or 'copy' modes, it is safer to refuse to
+            # build, and tell the user they need to upgrade the buildslave.
+            if (branch != self.branch
+                and self.args['mode'] in ("update", "copy")):
+                m = ("This buildslave (%s) does not know about multiple "
+                     "branches, and using mode=%s would probably build the "
+                     "wrong tree. "
+                     "Refusing to build. Please upgrade the buildslave to "
+                     "buildbot-0.7.0 or newer." % (self.build.slavename,
+                                                   self.args['mode']))
+                log.msg(m)
+                raise BuildSlaveTooOldError(m)
+
         if branch is None:
             branch = "HEAD"
         self.args['branch'] = branch
@@ -1203,19 +1222,7 @@
         # deal with old slaves
         warnings = []
         slavever = self.slaveVersion("cvs", "old")
-        if not self.slaveVersionNewEnough("cvs", "1.39"):
-            # the slave doesn't know to avoid re-using the same sourcedir
-            # when the branch changes. We have no way of knowing which branch
-            # the last build used, so if we're using a non-default branch and
-            # either 'update' or 'copy' modes, it is safer to switch to
-            # 'clobber' mode.
-            if branch != None and self.args['mode'] in ("update", "copy"):
-                m = ("buildslave does not know about multiple branches, "
-                     "switching from mode=%s to mode=clobber to insure "
-                     "we don't build the wrong branch." % self.args['mode'])
-                warnings.append(m + "\n")
-                log.msg(m)
-                self.args['mode'] = "clobber"
+
         if slavever == "old":
             # 0.5.0
             if self.args['mode'] == "export":
@@ -1284,24 +1291,28 @@
 
     def startVC(self, branch, revision, patch):
 
-        # accomodate old slaves
+        # handle old slaves
         warnings = []
         slavever = self.slaveVersion("svn", "old")
+        if not slavever:
+            m = "slave does not have the 'svn' command"
+            raise BuildSlaveTooOldError(m)
 
-        assert slavever, "slave does not have the 'svn' command"
         if not self.slaveVersionNewEnough("svn", "1.39"):
             # the slave doesn't know to avoid re-using the same sourcedir
             # when the branch changes. We have no way of knowing which branch
             # the last build used, so if we're using a non-default branch and
-            # either 'update' or 'copy' modes, it is safer to switch to
-            # 'clobber' mode.
-            if branch != None and self.args['mode'] in ("update", "copy"):
-                m = ("buildslave does not know about multiple branches, "
-                     "switching from mode=%s to mode=clobber to insure "
-                     "we don't build the wrong branch." % self.args['mode'])
-                warnings.append(m + "\n")
-                log.msg(m)
-                self.args['mode'] = "clobber"
+            # either 'update' or 'copy' modes, it is safer to refuse to
+            # build, and tell the user they need to upgrade the buildslave.
+            if (branch != self.branch
+                and self.args['mode'] in ("update", "copy")):
+                m = ("This buildslave (%s) does not know about multiple "
+                     "branches, and using mode=%s would probably build the "
+                     "wrong tree. "
+                     "Refusing to build. Please upgrade the buildslave to "
+                     "buildbot-0.7.0 or newer." % (self.build.slavename,
+                                                   self.args['mode']))
+                raise BuildSlaveTooOldError(m)
 
         if slavever == "old":
             # 0.5.0 compatibility
@@ -1312,15 +1323,22 @@
                 warnings.append("WARNING: this slave can only do SVN updates"
                                 ", not mode=%s\n" % self.args['mode'])
                 log.msg("WARNING: this slave only does mode=update")
-            assert self.args['mode'] != "export" # more serious
+            if self.args['mode'] == "export":
+                raise BuildSlaveTooOldError("old slave does not have "
+                                            "mode=export")
             self.args['directory'] = self.args['workdir']
             if revision is not None:
-                # 0.5.0 can only do HEAD
-                warnings.append("WARNING: this slave can only update to "
-                                "HEAD, not revision=%s\n" % revision)
-                log.msg("WARNING: this slave only does -rHEAD")
+                # 0.5.0 can only do HEAD. We have no way of knowing whether
+                # the requested revision is HEAD or not, and for
+                # slowly-changing trees this will probably do the right
+                # thing, so let it pass with a warning
+                m = ("WARNING: old slave can only update to HEAD, not "
+                     "revision=%s" % revision)
+                log.msg(m)
+                warnings.append(m + "\n")
             revision = "HEAD" # interprets this key differently
-            assert not patch # 0.5.0 slave can't do patch
+            if patch:
+                raise BuildSlaveTooOldError("old slave can't do patch")
 
         if self.svnurl:
             assert not branch # we need base_url= to use branches
@@ -1379,22 +1397,30 @@
 
     def startVC(self, branch, revision, patch):
         slavever = self.slaveVersion("darcs")
-        assert slavever, "slave is too old, does not know about darcs"
+        if not slavever:
+            m = "slave is too old, does not know about darcs"
+            raise BuildSlaveTooOldError(m)
+
         if not self.slaveVersionNewEnough("darcs", "1.39"):
-            # 0.6.6 slaves can't handle args['revision']
-            assert not revision
+            if revision:
+                # TODO: revisit this once we implement computeSourceRevision
+                m = "0.6.6 slaves can't handle args['revision']"
+                raise BuildSlaveTooOldError(m)
+
             # the slave doesn't know to avoid re-using the same sourcedir
             # when the branch changes. We have no way of knowing which branch
             # the last build used, so if we're using a non-default branch and
-            # either 'update' or 'copy' modes, it is safer to switch to
-            # 'clobber' mode.
-            if branch != None and self.args['mode'] in ("update", "copy"):
-                m = ("buildslave does not know about multiple branches, "
-                     "switching from mode=%s to mode=clobber to insure "
-                     "we don't build the wrong branch." % self.args['mode'])
-                warnings.append(m + "\m")
-                log.msg(m)
-                self.args['mode'] = "clobber"
+            # either 'update' or 'copy' modes, it is safer to refuse to
+            # build, and tell the user they need to upgrade the buildslave.
+            if (branch != self.branch
+                and self.args['mode'] in ("update", "copy")):
+                m = ("This buildslave (%s) does not know about multiple "
+                     "branches, and using mode=%s would probably build the "
+                     "wrong tree. "
+                     "Refusing to build. Please upgrade the buildslave to "
+                     "buildbot-0.7.0 or newer." % (self.build.slavename,
+                                                   self.args['mode']))
+                raise BuildSlaveTooOldError(m)
 
         if self.repourl:
             assert not branch # we need base_url= to use branches
@@ -1426,7 +1452,9 @@
         self.args['revision'] = revision
         self.args['patch'] = patch
         slavever = self.slaveVersion("git")
-        assert slavever, "slave is too old, does not know about git"
+        if not slavever:
+            raise BuildSlaveTooOldError("slave is too old, does not know "
+                                        "about git")
         self.cmd = LoggedRemoteCommand("git", self.args)
         ShellCommand.start(self)
 
@@ -1489,36 +1517,48 @@
             return "base-0"
         return "patch-%d" % lastChange
 
-    def checkSlaveVersion(self, cmd):
+    def checkSlaveVersion(self, cmd, branch):
         warnings = []
         slavever = self.slaveVersion(cmd)
-        assert slavever, "slave is too old, does not know about arch"
+        if not slavever:
+            m = "slave is too old, does not know about %s" % cmd
+            raise BuildSlaveTooOldError(m)
+
         # slave 1.28 and later understand 'revision'
         if not self.slaveVersionNewEnough(cmd, "1.28"):
             if not self.alwaysUseLatest:
-                log.msg("warning, buildslave is too old to use a revision")
-                warnings.append("buildslave is too old to use a revision")
+                # we don't know whether our requested revision is the latest
+                # or not. If the tree does not change very quickly, this will
+                # probably build the right thing, so emit a warning rather
+                # than refuse to build at all
+                m = "WARNING, buildslave is too old to use a revision"
+                log.msg(m)
+                warnings.append(m + "\n")
 
         if not self.slaveVersionNewEnough(cmd, "1.39"):
             # the slave doesn't know to avoid re-using the same sourcedir
             # when the branch changes. We have no way of knowing which branch
             # the last build used, so if we're using a non-default branch and
-            # either 'update' or 'copy' modes, it is safer to switch to
-            # 'clobber' mode.
-            if branch != None and self.args['mode'] in ("update", "copy"):
-                m = ("buildslave does not know about multiple branches, "
-                     "switching from mode=%s to mode=clobber to insure "
-                     "we don't build the wrong branch." % self.args['mode'])
-                warnings.append(m + "\n")
+            # either 'update' or 'copy' modes, it is safer to refuse to
+            # build, and tell the user they need to upgrade the buildslave.
+            if (branch != self.branch
+                and self.args['mode'] in ("update", "copy")):
+                m = ("This buildslave (%s) does not know about multiple "
+                     "branches, and using mode=%s would probably build the "
+                     "wrong tree. "
+                     "Refusing to build. Please upgrade the buildslave to "
+                     "buildbot-0.7.0 or newer." % (self.build.slavename,
+                                                   self.args['mode']))
                 log.msg(m)
-                self.args['mode'] = "clobber"
+                raise BuildslaveError(m)
+
         return warnings
 
     def startVC(self, branch, revision, patch):
         self.args['version'] = branch
         self.args['revision'] = revision
         self.args['patch'] = patch
-        warnings = self.checkSlaveVersion("arch")
+        warnings = self.checkSlaveVersion("arch", branch)
         self.cmd = LoggedRemoteCommand("arch", self.args)
         ShellCommand.start(self, warnings)
 
@@ -1555,7 +1595,7 @@
         self.args['version'] = branch
         self.args['revision'] = revision
         self.args['patch'] = patch
-        warnings = self.checkSlaveVersion("bazaar")
+        warnings = self.checkSlaveVersion("bazaar", branch)
         self.cmd = LoggedRemoteCommand("bazaar", self.args)
         ShellCommand.start(self, warnings)
 





More information about the Commits mailing list