Description of problem: spacewalk-clone-by-date does not handle correctly invalid configuration file. Version-Release number of selected component (if applicable): spacewalk-utils-1.7.15-38 How reproducible: 100% Steps to Reproduce: 1. Create custom software chhannel: test_x86_64 2. Add/push some packages in it. 3. Make sure the repodata is generated for the channel #ll /var/cache/rhn/repodata/test_x86_64 4. Create incorrect configuration file (there is a extra space after channel name) cat > clone_1.conf <<EOF { "username":"admin", "password":"nimda", "assumeyes":true, "skip_depsolve":false, "blacklist": { }, "removelist": { }, "channels":[ { "test_x86_64 ": "clone-test_x86_64" } ] } EOF 5.# spacewalk-clone-by-date --config clone_1.conf Reading repository information. By continuing the following channels will be created: clone-test_x86_64 Cloning test_x86_64 to clone-test_x86_64 with original package set. DEBUG ADDED BY DY:repos = [{"id":label, "relative_path":repodata(label)} for label in labels] [{'id': 'test_x86_64 ', 'relative_path': '/var/cache/rhn/repodata/test_x86_64 '}] Copying repodata, please wait. Unable to read repository information. Please verify repodata has been generated in /var/cache/rhn/repodata/LABEL. Error from yum: Cannot retrieve repository metadata (repomd.xml) for repository: test_x86_64 . Please verify its path and try again Actual results: The problem in the configuration file is discovered too late. As a side effect a new folder is created by function create_repodata_link() (cloneByDate.py): #ll /var/cache/rhn/repodata/test_x86_64\ / This folder will not be removed by def remove_repodata_link(link_path): if os.path.exists(link_path): return os.unlink(link_path) even if Bug 870794 will be solved. Expected results: The problem is discovered at the very beginning. Probably in file spacewalk-clone-by-date try: config = json.load(open(options.config)) except: raise UserError("Configuration file is invalid, please check syntax.") Additional info: def dep_solve(self, nvrea_list, labels=None): if not labels: labels = self.channel_map.keys() repos = [{"id":label, "relative_path":repodata(label)} for label in labels] print "Copying repodata, please wait." # dep solver expects the metadata to be in /repodata directory; # create temporary symlinks temp_repo_links = [] for repo in repos: yum_repodata_path = "%s/repodata" % (repo['relative_path']) create_repodata_link(repo['relative_path'], yum_repodata_path) temp_repo_links.append(yum_repodata_path) try: solver = DepSolver(repos, nvrea_list) dep_results = solver.processResults(solver.getDependencylist()) solver.cleanup() self.process_deps(dep_results) except RepoError, e: raise UserError("""Unable to read repository information. Please verify repodata has been generated in /var/cache/rhn/repodata/LABEL. Error from yum: %s""" % e.value) # clean up temporary symlinks for link in temp_repo_links: remove_repodata_link(link) def create_repodata_link(src_path, dst_path): if not os.path.exists(os.path.dirname(dst_path)): # create a dir if missing os.makedirs(os.path.dirname(dst_path)) if not os.path.exists(dst_path): if os.path.lexists(dst_path): # remove dead links os.unlink(dst_path) # create the link os.symlink(src_path, dst_path) def remove_repodata_link(link_path): if os.path.exists(link_path): return os.unlink(link_path)
Since it is impossible for channel labels or package names to contain whitespace, why don't we simply strip the whitespace away from the values before we do anything else? If there is a more serious problem parsing the config file then we'll already throw an error for that, and if it's just a whitespace issue we can just fix it and move on. No need to throw another error for this. Committed to Spacewalk master: fa1ecf6982dbcda2e4bae938139bbe5032cfe468
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. http://rhn.redhat.com/errata/RHBA-2013-0167.html