Issue #1250
closedBase FileDistributor is not forward-compatible with mongoengine converted units
Description
The base FileDistributor is designed to be subclassed by plugins, but the base code is not mongoengine-aware so as it passes objects to other methods it uses old-style unit definitions. When a plugin converts a subclassed FileDistributor (such as with puppet), it expects mongoengine to be used everywhere. As such the plugin code fails when the object passed in is an old-style model. I get a traceback shown below (assuming you're also using the logging fix in PR 2036).
pulp[10842]: pulp.plugins.file.distributor:ERROR: 'AssociatedUnit' object has no attribute 'checksum'
pulp[10842]: pulp.plugins.file.distributor:ERROR: (10842-98784) Traceback (most recent call last):
pulp[10842]: pulp.plugins.file.distributor:ERROR: (10842-98784) File "/home/bmbouter/Documents/pulp/server/pulp/plugins/file/distributor.py", line 92, in publish_repo
pulp[10842]: pulp.plugins.file.distributor:ERROR: (10842-98784) self.publish_metadata_for_unit(unit)
pulp[10842]: pulp.plugins.file.distributor:ERROR: (10842-98784) File "/home/bmbouter/Documents/pulp_puppet/pulp_puppet_plugins/pulp_puppet/plugins/distributors/filedi
_for_unit
pulp[10842]: pulp.plugins.file.distributor:ERROR: (10842-98784) unit.checksum,
pulp[10842]: pulp.plugins.file.distributor:ERROR: (10842-98784) AttributeError: 'AssociatedUnit' object has no attribute 'checksum'
pulp[10842]: pulp.plugins.file.distributor:ERROR: (10842-98784)
I think the resolution is to update the FileDistributor code to be forward-compatible with mongoengine and use a mongoengine model if the unit it's publishing is converted to mongoengine. At least it should work when tested against the in-development puppet conversion to mongoengine
Here is my reproducer script using httpie:
pulp-admin -u admin -p admin puppet repo create --repo-id=zoo-puppet --feed=http://forge.puppetlabs.com --queries torssh
pulp-admin puppet repo sync run --repo-id zoo-puppet
http --verify no --auth admin:admin POST https://localhost/pulp/api/v2/repositories/zoo-puppet/distributors/ distributor_type_id=puppet_file_distributor distributor_id=asdf
http --verify no --auth admin:admin POST https://localhost/pulp/api/v2/repositories/zoo-puppet/actions/publish/ id='asdf'