Bug 760458

Summary: Repos not getting published - some published link are not created
Product: [Retired] Pulp Reporter: Ivan Necas <inecas>
Component: user-experienceAssignee: Jeff Ortel <jortel>
Status: CLOSED CURRENTRELEASE QA Contact: Preethi Thomas <pthomas>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 1.0.0CC: skarmark
Target Milestone: ---Keywords: Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Ivan Necas 2011-12-06 09:07:20 UTC
When repositories with relative_path are created simultaneously, sometimes there occurs an error while creating links from /var/lib/pulp/published to /var/lib/pulp.

I had 3 repositories relative_paths:

ACME_Corporation/Locker/Red_Hat_Enterprise_Linux_Server/Red_Hat_Enterprise_Linux_6_Server_-_Optional_RPMs_61_x86_64

ACME_Corporation/Locker/Red_Hat_Enterprise_Linux_Server/Red_Hat_Enterprise_Linux_6_Server_-_Optional_Beta_RPMs_61_x86_64

ACME_Corporation/Locker/Red_Hat_Enterprise_Linux_Server/Red_Hat_Enterprise_Linux_6_Server_-_Supplementary_RPMs_61_x86_64

I tried to clone them into this relative paths:

ACME_Corporation/Development/Red_Hat_Enterprise_Linux_Server/Red_Hat_Enterprise_Linux_6_Server_-_Optional_RPMs_61_x86_64

ACME_Corporation/Development/Red_Hat_Enterprise_Linux_Server/Red_Hat_Enterprise_Linux_6_Server_-_Optional_Beta_RPMs_61_x86_64

ACME_Corporation/Development/Red_Hat_Enterprise_Linux_Server/Red_Hat_Enterprise_Linux_6_Server_-_Supplementary_RPMs_61_x86_64


Unfortunately only for the first one a link was created in /var/lib/pulp/published/repos

In Pulp log there are the following errors:

2011-12-02 10:16:10,340 3983:140232896804608: pulp.server.api.repo:ERROR: repo:303 [Errno 17] File exists: '/var/lib/pulp/published/repos/ACME_Corporation/Development/Red_Hat_Enterprise_Linux_Server'
2011-12-02 10:16:10,342 3983:140233247008512: pulp.server.api.repo:ERROR: repo:303 [Errno 17] File exists: '/var/lib/pulp/published/repos/ACME_Corporation/Development/Red_Hat_Enterprise_Linux_Server'

It seems to me like a race condition, when creating directories for the link, something like [1]

The code that caused it is probably here:

     def _create_published_link(self, repo):
        if not os.path.isdir(self.published_path):
            os.makedirs(self.published_path)

By the time the condition is evaluated the directory doesn't exist, but it gets created before the makedirs call. In the makedirs implementation it's solved by caching excpetion with errno.EEXISTS, but that's only for subdirs, and not the final desired directory:

    head, tail = path.split(name)
    if not tail:
        head, tail = path.split(head)
    if head and tail and not path.exists(head):
        try:
            makedirs(head, mode)
        except OSError, e:
            # be happy if someone already created the path
            if e.errno != errno.EEXIST:
                raise
        if tail == curdir:           # xxx/newdir/. exists if xxx/newdir exists
            return
    mkdir(name, mode)


There are more places where this could cause a trouble.

[1] - http://bugs.python.org/issue1675

Comment 1 Ivan Necas 2011-12-06 09:10:41 UTC
pulp-0.0.244-5.fc15.noarch

Comment 2 Jeff Ortel 2011-12-13 20:16:31 UTC
In pulp.server.util add makedirs() that handles race conditions for intermediate dirs and leaf directory as well.  Refit api/repo.py to use it.

commit: 4d8e38e3974dcb0aa0c784169004d79f7180581f

Comment 3 Jeff Ortel 2011-12-15 20:18:22 UTC
build: 0.255

Comment 4 Preethi Thomas 2012-01-13 14:34:27 UTC
verified
[root@qeblade20 ~]# rpm -q pulp
pulp-0.0.257-1.el6.noarch
[root@qeblade20 ~]# 

1. Created multiple repos with similar urls (rhel5/6 from cdn)
2. cloned repos with relpaths
repos cloned and published

Comment 5 Preethi Thomas 2012-02-24 20:19:09 UTC
Pulp v1.0 is released
Closed Current Release.

Comment 6 Preethi Thomas 2012-02-24 20:19:51 UTC
Pulp v1.0 is released.