galaxyproject / galaxy

Data intensive science for everyone.
https://galaxyproject.org
Other
1.41k stars 1.01k forks source link

Repository installation throws exception and is left in inconsistent state when an unrelated repository is installed before it #525

Closed hexylena closed 9 years ago

hexylena commented 9 years ago

I've been working to duplicate all of our installed repositories from production using scripted API calls for reproducibility. I've run into a problem where an installed repository appears to conflict somehow with a later installation of a completely different repository, throwing an unhandled exception and leaving the installing repository in an inconsistent state.

(Note: this is the only failing case I've reduced to the bare minimum from the ~110 tools I was trying to install. Before trying to reduce to a test case I provoked similar errors from at least three other repositories, so the problem doesn't seem to be limited to this combination.)

Against a brand new 15.05 instance, I ran:

$ python ./scripts/api/install_tool_shed_repositories.py --local $GALAXY_INSTALL_URL --api $GALAXY_INSTALL_KEY --tool-deps --repository-deps --url https://toolshed.g2.bx.psu.edu --owner iuc --name samtools_sort --revision 38ea74bd4054

followed by:

$ python ./scripts/api/install_tool_shed_repositories.py --local $GALAXY_INSTALL_URL --api $GALAXY_INSTALL_KEY --tool-deps --repository-deps --url https://toolshed.g2.bx.psu.edu --owner lparsons --name htseq_count --revision 6f920f33c5eb

The first repository, samtools_sort, installed fine. However, installation of htseq_count next failed and logged the following:

tool_shed.galaxy_install.repository_dependencies.repository_dependency_manager DEBUG 2015-06-20 02:31:33,466 Creating repository dependency objects...
tool_shed.util.shed_util_common DEBUG 2015-06-20 02:31:34,552 Adding new row for repository 'htseq_count' in the tool_shed_repository table, status set to 'New'.
tool_shed.util.shed_util_common DEBUG 2015-06-20 02:31:34,880 Adding new row for repository 'package_numpy_1_7' in the tool_shed_repository table, status set to 'New'.
tool_shed.galaxy_install.repository_dependencies.repository_dependency_manager DEBUG 2015-06-20 02:31:34,892 Skipping installation of revision 95d2c4aefb5f of repository 'package_samtools_0_1_19' because it was installed with the (possibly updated) revision 95d2c4aefb5f and its current installation status is 'Installed'.
tool_shed.util.shed_util_common DEBUG 2015-06-20 02:31:35,242 Adding new row for repository 'package_pysam_0_7_7' in the tool_shed_repository table, status set to 'New'.
tool_shed.galaxy_install.repository_dependencies.repository_dependency_manager DEBUG 2015-06-20 02:31:35,255 Building repository dependency relationships...
tool_shed.galaxy_install.repository_dependencies.repository_dependency_manager DEBUG 2015-06-20 02:31:35,266 Creating new repository_dependency record for installed revision 0c288abd2a1e of repository: package_numpy_1_7 owned by devteam.
tool_shed.galaxy_install.repository_dependencies.repository_dependency_manager DEBUG 2015-06-20 02:31:35,332 Creating new repository_dependency record for installed revision b62538c8c664 of repository: package_pysam_0_7_7 owned by iuc.
galaxy.web.framework.decorators ERROR 2015-06-20 02:31:35,387 Uncaught exception in exposed API method:
Traceback (most recent call last):
  File "/mnt/scdata/scdata_03/galaxy/containers/galaxy-builder/stable/lib/galaxy/web/framework/decorators.py", line 251, in decorator
    rval = func( self, trans, *args, **kwargs)
  File "/mnt/scdata/scdata_03/galaxy/containers/galaxy-builder/stable/lib/galaxy/webapps/galaxy/api/tool_shed_repositories.py", line 246, in install_repository_revision
    payload )
  File "/mnt/scdata/scdata_03/galaxy/containers/galaxy-builder/stable/lib/tool_shed/galaxy_install/install_manager.py", line 709, in install
    install_options
  File "/mnt/scdata/scdata_03/galaxy/containers/galaxy-builder/stable/lib/tool_shed/galaxy_install/install_manager.py", line 801, in __initiate_and_install_repositories
    return self.install_repositories(tsr_ids, decoded_kwd, reinstalling=False)
  File "/mnt/scdata/scdata_03/galaxy/containers/galaxy-builder/stable/lib/tool_shed/galaxy_install/install_manager.py", line 844, in install_repositories
    reinstalling=reinstalling )
  File "/mnt/scdata/scdata_03/galaxy/containers/galaxy-builder/stable/lib/tool_shed/galaxy_install/install_manager.py", line 864, in install_tool_shed_repository
    repo_info_tuple = repo_info_dict[ tool_shed_repository.name ]
KeyError: u'package_pysam_0_7_7'

This left the htseq_count and package_numpy_1_7 repositories in the "New" state and the package_pysam_0_7_7 repository in the "Cloning" state, even after a restart of the server.

However, without installing samtools_sort first, htseq_count and its dependencies install fine.

from @bcclaywell on trello

(Note from @erasche, untested, moving due to recency + test cases provided)

mvdbeek commented 9 years ago

@erasche, @bcclaywell, @yhoogstrate I can reproduce this, and I think I have fixed it. With the proposed change the above procedure works.

Also @afgane ansible galaxy-tools-playbook is happiliy chugging through more than 50 tools, including multiple revisions, without fail, while before only a minority installed successfully.

bcclaywell commented 9 years ago

@mvdbeek I can verify that this patch eliminates the error I received in the test case above, and that my scripted installation of about 100 tools and dependencies now (mostly) finishes successfully! Thanks for digging this problem up :)

bgruening commented 9 years ago

Fixed in https://github.com/galaxyproject/galaxy/pull/681. Thanks @mvdbeek!