Project

Profile

Help

Issue #1250

closed

Base FileDistributor is not forward-compatible with mongoengine converted units

Added by bmbouter over 8 years ago. Updated almost 5 years ago.

Status:
CLOSED - CURRENTRELEASE
Priority:
High
Assignee:
Category:
-
Sprint/Milestone:
-
Start date:
Due date:
Estimated time:
Severity:
2. Medium
Version:
Master
Platform Release:
2.8.0
OS:
Triaged:
Yes
Groomed:
No
Sprint Candidate:
No
Tags:
Pulp 2
Sprint:
Quarter:

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'
Actions #1

Updated by mhrivnak over 8 years ago

  • Status changed from NEW to ASSIGNED
  • Assignee set to mhrivnak
Actions #2

Updated by mhrivnak over 8 years ago

  • Status changed from ASSIGNED to POST

https://github.com/pulp/pulp/pull/2041

Brian, I had to apply the below patch to your branch to make it use the forked distributor.

diff --git a/pulp_puppet_plugins/pulp_puppet/plugins/distributors/filedistributor.py b/pulp_puppet_plugins/pulp_puppet/plugins/distributors/filedistributor.py
index 47d58a1..48ee35f 100644
--- a/pulp_puppet_plugins/pulp_puppet/plugins/distributors/filedistributor.py
+++ b/pulp_puppet_plugins/pulp_puppet/plugins/distributors/filedistributor.py
@@ -1,7 +1,7 @@
 from gettext import gettext as _
 import os

-from pulp.plugins.file.distributor import FileDistributor
+from pulp.plugins.file.model_distributor import FileDistributor

 from pulp_puppet.common import constants
 from pulp_puppet.plugins.distributors import configuration
@@ -83,7 +83,7 @@ class PuppetFileDistributor(FileDistributor):
         :type config: pulp.plugins.config.PluginConfiguration
         """
         config.default_config = configuration.DEFAULT_CONFIG
-        hosting_dir = os.path.join(config.get(constants.CONFIG_FILE_HTTPS_DIR), repo.id)
+        hosting_dir = os.path.join(config.get(constants.CONFIG_FILE_HTTPS_DIR), repo.repo_id)
         return [hosting_dir]

     def get_paths_for_unit(self, unit):
Actions #3

Updated by mhrivnak over 8 years ago

  • Triaged changed from No to Yes
Actions #4

Updated by mhrivnak over 8 years ago

  • Status changed from POST to MODIFIED
Actions #5

Updated by dkliban@redhat.com about 8 years ago

  • Status changed from MODIFIED to 5
Actions #6

Updated by dkliban@redhat.com almost 8 years ago

  • Status changed from 5 to CLOSED - CURRENTRELEASE
Actions #7

Updated by bmbouter almost 5 years ago

  • Tags Pulp 2 added

Also available in: Atom PDF