--Nq2Wo0NMKNjxTN9z Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Folks, Chatted with Seth and discoverd that handling the yumgroups.xml file was a special case for the failover code. Attached is a patch that I *think* fixes the problem. Hard to test for....Icon? Jack -- Jack Neely <slack@xxxxxxxxxxxxxxx> Linux Realm Kit Administration and Development PAMS Computer Operations at NC State University GPG Fingerprint: 1917 5AC1 E828 9337 7AA4 EA6B 213B 765F 3B6A 5B89 --Nq2Wo0NMKNjxTN9z Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="groups-failover.patch" ? archwork.pyc ? callback.pyc ? clientStuff.pyc ? comps.pyc ? config.pyc ? failover.pyc ? i18n.pyc ? keepalive.pyc ? logger.pyc ? nevral.pyc ? patch ? pkgaction.pyc ? rpmUtils.pyc ? urlgrabber.pyc ? yumcomps.pyc ? yumlock.pyc ? yummain.pyc Index: clientStuff.py =================================================================== RCS file: /home/groups/yum/cvs/yum/clientStuff.py,v retrieving revision 1.47.2.51 diff -u -r1.47.2.51 clientStuff.py --- clientStuff.py 15 Jun 2003 17:52:25 -0000 1.47.2.51 +++ clientStuff.py 21 Jun 2003 19:28:13 -0000 @@ -600,7 +600,7 @@ if not conf.cache: log(3, 'getting groups from server: %s' % serverid) try: - localgroupfile = grab(serverid, remotegroupfile, localgroupfile, copy_local=1) + localgroupfile = grab(serverid, remotegroupfile, localgroupfile, nofail=1, copy_local=1) except URLGrabError, e: log(3, 'Error getting file %s' % remotegroupfile) log(3, '%s' % e) @@ -940,18 +940,25 @@ size = size / 1000000000.0 return "%.2f GB" % size -def grab(serverID, url, filename=None, copy_local=0, close_connection=0, +def grab(serverID, url, filename=None, nofail=0, copy_local=0, + close_connection=0, progress_obj=None, throttle=None, bandwidth=None, numtries=3, retrycodes=[-1,2,4,5,6,7], checkfunc=None): """Wrap retry grab and add in failover stuff. This needs access to the conf class as well as the serverID. + nofail -- Set to true to go through the failover object without + incrimenting the failures counter. (Actually this just resets + the failures counter.) Usefull in the yumgroups.xml special case. + We do look at retrycodes here to see if we should return or failover. On fail we will raise the last exception that we got.""" fc = conf.get_failClass(serverID) base = '' + findex = fc.get_index() + for root in conf.serverurl[serverID]: if string.find(url, root) == 0: # We found the current base this url is made of @@ -965,6 +972,7 @@ log(3, "failover: path = " + filepath) # don't trust the base that the user supplied + # this call will return the same thing as fc.get_serverurl(findex) base = fc.get_serverurl() while base != None: # Loop over baseURLs until one works or all are dead @@ -979,8 +987,12 @@ except URLGrabError, e: if e.errno in retrycodes: errorlog(1, "retrygrab() failed for %s -- executing failover method" % base) - fc.server_failed() - base = fc.get_serverurl() + if nofail: + findex = findex + 1 + base = fc.get_serverurl(findex) + else: + fc.server_failed() + base = fc.get_serverurl() if base == None: errorlog(1, "failover: out of servers to try") raise Index: failover.py =================================================================== RCS file: /home/groups/yum/cvs/yum/Attic/failover.py,v retrieving revision 1.1.2.1 diff -u -r1.1.2.1 failover.py --- failover.py 27 May 2003 17:32:21 -0000 1.1.2.1 +++ failover.py 21 Jun 2003 19:28:13 -0000 @@ -29,17 +29,33 @@ self.serverID = serverID self.failures = 0 - def get_serverurl(self): - "Returns a serverurl based on this failover method or None if complete failure." + def get_serverurl(self, i=None): + """Returns a serverurl based on this failover method or None + if complete failure. If i is given it is a direct index + to pull a server URL from instead of using the failures + counter.""" return None def server_failed(self): "Tells the failover method that the current server is failed." self.failures = self.failures + 1 - def reset(self): - "Reset the failures counter." - self.failures = 0 + def reset(self, i=0): + "Reset the failures counter to a given index." + self.failures = i + + def get_index(self): + """Returns the current number of failures which is also the + index into the list this object represents. ger_serverurl() + should always be used to translate an index into a URL + as this object may change how indexs map. (See RoundRobin)""" + + return self.failures + + def len(self): + """Returns the how many URLs we've got to cycle through.""" + + return len(self.conf.serverurl[self.serverID]) @@ -47,13 +63,18 @@ """Chooses server based on the first success in the list.""" - def get_serverurl(self): + def get_serverurl(self, i=None): "Returns a serverurl based on this failover method or None if complete failure." - if self.failures >= len(self.conf.serverurl[self.serverID]): + if i == None: + index = self.failures + else: + index = i + + if index >= len(self.conf.serverurl[self.serverID]): return None - return self.conf.serverurl[self.serverID][self.failures] + return self.conf.serverurl[self.serverID][index] @@ -66,11 +87,18 @@ random.seed() self.offset = random.randint(0, 37) - def get_serverurl(self): + def get_serverurl(self, i=None): "Returns a serverurl based on this failover method or None if complete failure." + + if i == None: + index = self.failures + else: + index = i - if self.failures >= len(self.conf.serverurl[self.serverID]): + if index >= len(self.conf.serverurl[self.serverID]): return None - i = (self.failures + self.offset) % len(self.conf.serverurl[self.serverID]) - return self.conf.serverurl[self.serverID][i] + rr = (index + self.offset) % len(self.conf.serverurl[self.serverID]) + return self.conf.serverurl[self.serverID][rr] + +# SDG Index: yummain.py =================================================================== RCS file: /home/groups/yum/cvs/yum/yummain.py,v retrieving revision 1.40.2.28 diff -u -r1.40.2.28 yummain.py --- yummain.py 31 May 2003 16:30:01 -0000 1.40.2.28 +++ yummain.py 21 Jun 2003 19:28:13 -0000 @@ -332,4 +332,4 @@ sys.exit(1) if __name__ == "__main__": - main() + main(sys.argv[1:]) --Nq2Wo0NMKNjxTN9z--