Bug 882406 - Can't create 2 repos with similar substring in relative path
Summary: Can't create 2 repos with similar substring in relative path
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Pulp
Classification: Retired
Component: user-experience
Version: 1.1.0
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: ---
: 2.1.0
Assignee: John Matthews
QA Contact: Preethi Thomas
URL:
Whiteboard:
Depends On:
Blocks: 882411
TreeView+ depends on / blocked
 
Reported: 2012-11-30 21:29 UTC by Mike McCune
Modified: 2013-09-09 16:28 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 882411 (view as bug list)
Environment:
Last Closed: 2013-04-08 16:01:43 UTC
Embargoed:


Attachments (Terms of Use)

Description Mike McCune 2012-11-30 21:29:51 UTC
Trying to create a second repository with a relative path that appears to contain the same substring will cause an error:

Traceback (most recent call last):\n File \"/usr/lib/python2.6/site-packages/pulp/server/webservices/controllers/decorators.py\", line 48, in report_error\n return method(self, *args, **kwargs)\n File \"/usr/lib/python2.6/site-packages/pulp/server/webservices/controllers/decorators.py\", line 127, in _auth_decorator\n value = method(self, *args, **kwargs)\n File \"/usr/lib/python2.6/site-packages/pulp/server/webservices/controllers/repositories.py\", line 335, in POST\n publish=repo_data.get('publish', None), packages_dir=repo_data.get('packages_dir', None))\n File \"/usr/lib/python2.6/site-packages/pulp/server/api/repo.py\", line 271, in create\n raise PulpException(msg)\nPulpException: New relative path [RHIC/Library/content/beta/rhel/server/6/6Server/x86_64/ose-infra/1/source/SRPMS] conflicts with existing relative path [RHIC/Library/content/beta/rhel/server/6/6Server/x86_64/os]; paths may not be a parent or child ...

Note the 2 relative paths:

RHIC/Library/content/beta/rhel/server/6/6Server/x86_64/ose-infra/1/source/SRPMS
RHIC/Library/content/beta/rhel/server/6/6Server/x86_64/os

this blocks Katello from being able to import a subscription manifest and sync RH content from the CDN

Comment 1 Jay Dobies 2012-12-03 13:38:58 UTC
Preethi - He filed this against 1.1, can you please see if it's still an issue in 2.0?

Comment 2 Preethi Thomas 2012-12-03 18:35:34 UTC
[root@preethi-el6-pulp ~]# rpm -q pulp-server
pulp-server-2.0.6-0.11.beta.noarch
[root@preethi-el6-pulp ~]# 

I tried on v2 on can't seem to reproduce

[root@preethi-el6-pulp ~]# pulp-admin -u admin -p admin rpm repo create --repo-id zoo --feed http://repos.fedorapeople.org/repos/pulp/pulp/demo_repos/zoo/ --relative-url RHIC/Library/content/beta/rhel/server/6/6Server/x86_64/ose-infra/1/source/SRPMS
Successfully created repository [zoo]

[root@preethi-el6-pulp ~]# 
[root@preethi-el6-pulp ~]# 
[root@preethi-el6-pulp ~]# 
[root@preethi-el6-pulp ~]# pulp-admin -u admin -p admin rpm repo create --repo-id zoo1 --feed http://repos.fedorapeople.org/repos/pulp/pulp/demo_repos/zoo/ --relative-url RHIC/Library/content/beta/rhel/server/6/6Server/x86_64/
Successfully created repository [zoo1]

[root@preethi-el6-pulp ~]# 
[root@preethi-el6-pulp ~]# 
[root@preethi-el6-pulp ~]# 
[root@preethi-el6-pulp ~]# 
[root@preethi-el6-pulp ~]# pulp-admin -u admin -p admin rpm repo sync run --repo-id zoo1 
+----------------------------------------------------------------------+
                    Synchronizing Repository [zoo1]
+----------------------------------------------------------------------+

This command may be exited by pressing ctrl+c without affecting the actual
operation on the server.

Downloading metadata...
[|]
... completed

Downloading repository content...
[==================================================] 100%
RPMs:       32/32 items
Delta RPMs: 0/0 items
Tree Files: 0/0 items
Files:      0/0 items
... completed

Importing errata...
[-]
... completed

Importing package groups/categories...
[-]
... completed

Publishing packages...
[==================================================] 100%
Packages: 32/32 items
... completed

Publishing distributions...
[==================================================] 100%
Distributions: 0/0 items
... completed

Generating metadata
[\]
... completed

Publishing repository over HTTPS
[-]
... completed

Publishing repository over HTTP
[-]
... skipped

[root@preethi-el6-pulp ~]# pulp-admin -u admin -p admin rpm repo sync run --repo-id zoo
+----------------------------------------------------------------------+
                     Synchronizing Repository [zoo]
+----------------------------------------------------------------------+

This command may be exited by pressing ctrl+c without affecting the actual
operation on the server.

Downloading metadata...
[|]
... completed

Downloading repository content...
[==================================================] 100%
RPMs:       32/32 items
Delta RPMs: 0/0 items
Tree Files: 0/0 items
Files:      0/0 items
... completed

Importing errata...
[-]
... completed

Importing package groups/categories...
[-]
... completed

Publishing packages...
[==================================================] 100%
Packages: 32/32 items
... completed

Publishing distributions...
[==================================================] 100%
Distributions: 0/0 items
... completed

Generating metadata
[\]
... completed

Publishing repository over HTTPS
[-]
... completed

Publishing repository over HTTP
[-]
... skipped

[root@preethi-el6-pulp ~]# pulp-admin -u admin -p admin rpm repo list
+----------------------------------------------------------------------+
                            RPM Repositories
+----------------------------------------------------------------------+

Id:                 zoo1
Display Name:       zoo1
Description:        None
Content Unit Count: 39

Id:                 zoo
Display Name:       zoo
Description:        None
Content Unit Count: 39


[root@preethi-el6-pulp ~]#

Comment 3 Thom Carlin 2012-12-03 19:15:13 UTC
Please try RHIC/Library/content/beta/rhel/server/6/6Server/x86_64/os for the second repository (note the /os at the end, this is essential to reproduce)

Comment 4 Mike McCune 2012-12-03 22:36:10 UTC
With 1.1 I get:

[root@sat-perf-04 ~]# pulp-admin -u admin -p admin repo create --id=one --feed http://repos.fedorapeople.org/repos/pulp/pulp/demo_repos/zoo/ --relativepath RHIC/Library/content/beta/rhel/server/6/6Server/x86_64/ose-infra/1/source/SRPMS
Successfully created repository [ one ]

[root@sat-perf-04 ~]# pulp-admin -u admin -p admin repo create --id=two --feed http://repos.fedorapeople.org/repos/pulp/pulp/demo_repos/zoo/ --relativepath RHIC/Library/content/beta/rhel/server/6/6Server/x86_64/os
error:  operation failed: PulpException: New relative path [RHIC/Library/content/beta/rhel/server/6/6Server/x86_64/os] conflicts with existing relative path [RHIC/Library/content/beta/rhel/server/6/6Server/x86_64/ose-infra/1/source/SRPMS]; paths may not be a parent or child directory of another relative path

Comment 6 Preethi Thomas 2012-12-04 01:11:51 UTC
I marked it verified since it was put on_qa to verify against 2.0. 
I will put it back on new.

Comment 7 Jay Dobies 2012-12-04 13:36:58 UTC
I had told her to verify it against 2.0. We're not doing anymore 1.1 builds, we don't have the resources or time given you've requested a 2.0 release by the end of the year and then the upgrade by February 1. Feel free to submit a patch but you'll likely have to build/test/carry the RPM on your own.

Comment 8 John Matthews 2012-12-04 21:19:11 UTC
With the below diff functionality looks better:

$ git diff
diff --git a/src/pulp/server/api/repo.py b/src/pulp/server/api/repo.py
index d3695df..bd2a758 100644
--- a/src/pulp/server/api/repo.py
+++ b/src/pulp/server/api/repo.py
@@ -2599,6 +2599,16 @@ def validate_relative_path(new_path, existing_path):
     # Easy out clause: if they are the same, they are invalid
     existing_path = decode_unicode(existing_path)
     new_path = decode_unicode(new_path)
+    #
+    # BZ:882406 
+    # Intentionally putting '/' at end of both paths
+    # Allows distinguishing "os/" versus "ose-foo/"
+    # Previously "os" was found inside of "ose-foo" and a conflict was raised incorrectly.
+    # 
+    if existing_path[-1] != "/":
+        existing_path+="/"
+    if new_path[-1] != "/":
+        new_path+="/"
 
     if new_path == existing_path:
         return False
diff --git a/test/unit/test_repo_api.py b/test/unit/test_repo_api.py
index d5f28ef..9283d94 100644
--- a/test/unit/test_repo_api.py
+++ b/test/unit/test_repo_api.py
@@ -1559,6 +1559,14 @@ class TestRepoApi(testutil.PulpAsyncTest):
         self.assertTrue(repo.validate_relative_path('foo', 'bar'))
         self.assertFalse(repo.validate_relative_path('foo', 'foo/bar'))
         self.assertFalse(repo.validate_relative_path('foo/bar', 'foo'))
+        self.assertTrue(repo.validate_relative_path(
+            'RHIC/Library/content/beta/rhel/server/6/6Server/x86_64/os', 
+            'RHIC/Library/content/beta/rhel/server/6/6Server/x86_64/ose-infra/1/source/SRPMS')
+        )
+        self.assertTrue(repo.validate_relative_path(
+            'RHIC/Library/content/beta/rhel/server/6/6Server/x86_64/ose-infra/1/source/SRPMS',
+            'RHIC/Library/content/beta/rhel/server/6/6Server/x86_64/os') 
+        )
 
     def test_repo_publish_on_create(self):
         repo = self.repo_api.create('repo_publish_true', 'some name',


[root@sat-perf-04 api]# pulp-admin -u admin -p admin repo create --id=one --feed http://repos.fedorapeople.org/repos/pulp/pulp/demo_repos/zoo/ --relativepath RHIC/Library/content/beta/rhel/server/6/6Server/x86_64/ose-infra/1/source/SRPMS
Successfully created repository [ one ]

[root@sat-perf-04 api]# pulp-admin -u admin -p admin repo create --id=two --feed http://repos.fedorapeople.org/repos/pulp/pulp/demo_repos/zoo/ --relativepath RHIC/Library/content/beta/rhel/server/6/6Server/x86_64/os
Successfully created repository [ two ]

Comment 9 John Matthews 2012-12-05 12:59:57 UTC
Commit info:

[main] 836ff9e685696d9570696d7e9ebdf5aee3ac9ad9 - commit 1 of 5823 (0%)
commit 836ff9e685696d9570696d7e9ebdf5aee3ac9ad9
Refs: pulp_v1, <origin/pulp_v1>, pulp-1.1.14-1-3-g836ff9e
Author:     John Matthews <jmatthews>
AuthorDate: Wed Dec 5 07:55:49 2012 -0500
Commit:     John Matthews <jmatthews>
CommitDate: Wed Dec 5 07:55:49 2012 -0500

    882406 - Can't create 2 repos with similar substring in relative path
---
 src/pulp/server/api/repo.py |   10 ++++++++++
 test/unit/test_repo_api.py  |    8 ++++++++
 2 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/src/pulp/server/api/repo.py b/src/pulp/server/api/repo.py
index d3695df..bd2a758 100644
--- a/src/pulp/server/api/repo.py
+++ b/src/pulp/server/api/repo.py
@@ -2599,6 +2599,16 @@ def validate_relative_path(new_path, existing_path):
     # Easy out clause: if they are the same, they are invalid
     existing_path = decode_unicode(existing_path)
     new_path = decode_unicode(new_path)
+    #
+    # BZ:882406
+    # Intentionally putting '/' at end of both paths
+    # Allows distinguishing "os/" versus "ose-foo/"
+    # Previously "os" was found inside of "ose-foo" and a conflict was raised incorrectly.
+    #
+    if existing_path[-1] != "/":
+        existing_path+="/"
+    if new_path[-1] != "/":
+        new_path+="/"

     if new_path == existing_path:
         return False
diff --git a/test/unit/test_repo_api.py b/test/unit/test_repo_api.py
index d5f28ef..9283d94 100644
--- a/test/unit/test_repo_api.py
+++ b/test/unit/test_repo_api.py
@@ -1559,6 +1559,14 @@ class TestRepoApi(testutil.PulpAsyncTest):
         self.assertTrue(repo.validate_relative_path('foo', 'bar'))
         self.assertFalse(repo.validate_relative_path('foo', 'foo/bar'))
         self.assertFalse(repo.validate_relative_path('foo/bar', 'foo'))
+        self.assertTrue(repo.validate_relative_path(
+            'RHIC/Library/content/beta/rhel/server/6/6Server/x86_64/os',
+            'RHIC/Library/content/beta/rhel/server/6/6Server/x86_64/ose-infra/1/source/SRPMS')
+        )
+        self.assertTrue(repo.validate_relative_path(
+            'RHIC/Library/content/beta/rhel/server/6/6Server/x86_64/ose-infra/1/source/SRPMS',
+            'RHIC/Library/content/beta/rhel/server/6/6Server/x86_64/os')
+        )

     def test_repo_publish_on_create(self):
         repo = self.repo_api.create('repo_publish_true', 'some name',

Comment 10 Jeff Ortel 2013-01-19 16:59:41 UTC
build: 2.1.0-0.1.alpha

Comment 11 Preethi Thomas 2013-02-21 15:51:27 UTC
verified in 2.1 and 1.1.15

[root@pulp-upgrade-testing ~]# rpm -q pulp
pulp-1.1.15-1.el6.noarch
[root@pulp-upgrade-testing ~]# pulp-admin -u admin -p admin repo create --id=one --feed http://repos.fedorapeople.org/repos/pulp/pulp/demo_repos/zoo/ --relativepath RHIC/Library/content/beta/rhel/server/6/6Server/x86_64/ose-infra/1/source/SRPMS
Successfully created repository [ one ]

[root@pulp-upgrade-testing ~]# pulp-admin -u admin -p admin repo create --id=two --feed http://repos.fedorapeople.org/repos/pulp/pulp/demo_repos/zoo/ --relativepath RHIC/Library/content/beta/rhel/server/6/6Server/x86_64/os
Successfully created repository [ two ]


From 2.1

[root@preethi ~]# pulp-admin -u admin -p admin rpm repo create --repo-id zoo --feed http://repos.fedorapeople.org/repos/pulp/pulp/demo_repos/zoo/ --relative-url RHIC/Library/content/beta/rhel/server/6/6Server/x86_64/ose-infra/1/source/SRPMS
Successfully created repository [zoo]


[root@preethi ~]# pulp-admin -u admin -p admin rpm repo create --repo-id zoo1 --feed http://repos.fedorapeople.org/repos/pulp/pulp/demo_repos/zoo/ --relative-url RHIC/Library/content/beta/rhel/server/6/6Server/x86_64/
Successfully created repository [zoo1]

Comment 12 Preethi Thomas 2013-04-08 16:01:43 UTC
Pulp 2.1 released 


http://www.pulpproject.org/2013/04/05/pulp-2-1-0-released/


Note You need to log in before you can comment on or make changes to this bug.