Bug 765888

Summary: Error during promotion
Product: Red Hat Satellite Reporter: Mike McCune <mmccune>
Component: APIAssignee: Lukas Zapletal <lzap>
Status: CLOSED CURRENTRELEASE QA Contact: Garik Khachikyan <gkhachik>
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.0.0CC: gkhachik, gstoecke, inecas, jweiss, lzap, mkoci, tstrachota
Target Milestone: UnspecifiedKeywords: TestBlocker
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-08-22 18:12:13 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Bug Depends On:    
Bug Blocks: 747354    

Description Mike McCune 2011-12-09 16:09:24 UTC
Sync and promote RHEL content into the next env out of Locker and you get this error in the task_statuses db table:


more info here how to find this error:

https://fedorahosted.org/katello/wiki/TaskStatuses

{"errors":["Validation
failed: Pulp id has already been
taken","/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.10/li
b/active_record/validations.rb:49:in
`save!'/n/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.10/lib/active_record/attribute_methods/dirty.rb:30:in
`save!'/n/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.10/lib
/active_record/transactions.rb:245:in
`save!'/n/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.10/lib/active_record/transactions.rb:292:in
`with_transaction_returning_status'/n/usr/lib/ruby/gems/1.8/gems/acti
verecord-3.0.10/lib/active_record/connection_adapters/abstract/database_statements.rb:139:in
`transaction'/n/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.10/lib/active_record/transactions.rb:207:in
`transac
tion'/n/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.10/lib/active_record/transactions.rb:290:in
`with_transaction_returning_status'/n/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.10/lib/active_record/transa
ctions.rb:245:in
`save!'/n/usr/share/katello/app/models/lazy_accessor.rb:109:in
`save!'/n/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.10/lib/active_record/validations.rb:34:in
`create!'/n/usr/share/katello /app/models/glue/pulp/repo.rb:108:in
`promote'/n/usr/share/katello/app/models/glue/pulp/repos.rb:515:in
`promote_repos'/n/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.10/lib/active_record/relation.rb:13:in 
`each'/n/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.10/lib/active_record/relation.rb:13:in
`__send__'/n/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.10/lib/active_record/relation.rb:13:in
`each'/n/usr/shar e/katello/app/models/glue/pulp/repos.rb:508:in
`promote_repos'/n/usr/share/katello/app/models/glue/pulp/repos.rb:147:in
`promote'/n/usr/share/katello/app/models/changeset.rb:336:in
`promote_products'/n/usr

Comment 2 Garik Khachikyan 2011-12-09 16:15:16 UTC
issue seems to be: having already a promotion passed and making a second try to the same org/env (but different promotion name).

Comment 3 Ivan Necas 2011-12-09 16:50:41 UTC
I've reproduced this problem, when the first promotion was made prior to synchronization. It seems Pulp ends up then with the following error:

    2011-12-09 17:38:05,886 2537:139878796867328: pulp.server.api.repo_sync:ERROR: repo_sync:141 Cannot retrieve repository metadata (repomd.xml) for repository: /tmp/temp_pulp_repoS6sW6Y. Please verify its path and try again
    2011-12-09 17:38:05,888 2537:139878796867328: pulp.server.api.repo_sync:WARNING: repo_sync:142 Traceback: Traceback (most recent call last):
    File "/usr/lib/python2.7/site-packages/pulp/server/api/repo_sync.py", line 136, in _clone
    _sync(clone_id, progress_callback=progress_callback, synchronizer=synchronizer)
    File "/usr/lib/python2.7/site-packages/pulp/server/api/repo_sync.py", line 272, in _sync
    progress_callback, synchronizer, max_speed, threads)
    File "/usr/lib/python2.7/site-packages/pulp/server/api/repo_sync.py", line 350, in fetch_content
    progress_callback, max_speed, threads)
    File "/usr/lib/python2.7/site-packages/pulp/server/api/synchronizers.py", line 158, in sync
    max_speed=max_speed, threads=threads)
    File "/usr/lib/python2.7/site-packages/pulp/server/api/synchronizers.py", line 1116, in local
    progress_callback)
    File "/usr/lib/python2.7/site-packages/pulp/server/api/synchronizers.py", line 871, in _sync_rpms
    unfiltered_pkglist = pulp.server.util.get_repo_packages(src_repo_dir)
    File "/usr/lib/python2.7/site-packages/pulp/server/util.py", line 307, in get_repo_packages
    sack.populate(r, 'metadata', None, 0)
    File "/usr/lib/python2.7/site-packages/yum/yumRepo.py", line 164, in populate
    if self._check_db_version(repo, mydbtype):
    File "/usr/lib/python2.7/site-packages/yum/yumRepo.py", line 222, in _check_db_version
    return repo._check_db_version(mdtype)
    File "/usr/lib/python2.7/site-packages/yum/yumRepo.py", line 1255, in _check_db_version
    repoXML = self.repoXML
    File "/usr/lib/python2.7/site-packages/yum/yumRepo.py", line 1454, in <lambda>
    repoXML = property(fget=lambda self: self._getRepoXML(),
    File "/usr/lib/python2.7/site-packages/yum/yumRepo.py", line 1450, in _getRepoXML
    raise Errors.RepoError, msg
    RepoError: Cannot retrieve repository metadata (repomd.xml) for repository: /tmp/temp_pulp_repoS6sW6Y. Please verify its path and try again
     
    2011-12-09 17:38:05,888 2537:139878796867328: pulp.server.tasking.task:ERROR: task:455 Task failed: Task 2abe3d82-2284-11e1-9034-f0def16f6678: _clone(ACME_Corporation-Dev-Red_Hat_Enterprise_Linux_Server-Red_Hat_Enterprise_Linux_6_Server_RPMs_62_x86_64, feed=parent, progress_callback=<bound method RepoCloneTask.progress_callback of <pulp.server.api.repo_clone_task.RepoCloneTask object at 0x7f380813e490>>, clone_name=Red Hat Enterprise Linux 6 Server RPMs 62 x86_64, relative_path=ACME_Corporation/Dev/content/dist/rhel/server/6/6.2/x86_64/os, synchronizer=<pulp.server.api.synchronizers.YumSynchronizer object at 0x7f380813e8d0>, filters=[], id=ACME_Corporation-Red_Hat_Enterprise_Linux_Server-Red_Hat_Enterprise_Linux_6_Server_RPMs_62_x86_64, groupid=['product:69', 'env:2', 'org:1', 'content:168'])
    Traceback (most recent call last):
    File "/usr/lib/python2.7/site-packages/pulp/server/tasking/task.py", line 404, in run
    result = self.callable(*self.args, **self.kwargs)
    File "/usr/lib/python2.7/site-packages/pulp/server/api/repo_sync.py", line 136, in _clone
    _sync(clone_id, progress_callback=progress_callback, synchronizer=synchronizer)
    File "/usr/lib/python2.7/site-packages/pulp/server/api/repo_sync.py", line 272, in _sync
    progress_callback, synchronizer, max_speed, threads)
    File "/usr/lib/python2.7/site-packages/pulp/server/api/repo_sync.py", line 350, in fetch_content
    progress_callback, max_speed, threads)
    File "/usr/lib/python2.7/site-packages/pulp/server/api/synchronizers.py", line 158, in sync
    max_speed=max_speed, threads=threads)
    File "/usr/lib/python2.7/site-packages/pulp/server/api/synchronizers.py", line 1116, in local
    progress_callback)
    File "/usr/lib/python2.7/site-packages/pulp/server/api/synchronizers.py", line 871, in _sync_rpms
    unfiltered_pkglist = pulp.server.util.get_repo_packages(src_repo_dir)
    File "/usr/lib/python2.7/site-packages/pulp/server/util.py", line 307, in get_repo_packages
    sack.populate(r, 'metadata', None, 0)
    File "/usr/lib/python2.7/site-packages/yum/yumRepo.py", line 164, in populate
    if self._check_db_version(repo, mydbtype):
    File "/usr/lib/python2.7/site-packages/yum/yumRepo.py", line 222, in _check_db_version
    return repo._check_db_version(mdtype)
    File "/usr/lib/python2.7/site-packages/yum/yumRepo.py", line 1255, in _check_db_version
    repoXML = self.repoXML
    File "/usr/lib/python2.7/site-packages/yum/yumRepo.py", line 1454, in <lambda>
    repoXML = property(fget=lambda self: self._getRepoXML(),
    File "/usr/lib/python2.7/site-packages/yum/yumRepo.py", line 1450, in _getRepoXML
    raise Errors.RepoError, msg
    RepoError: Cannot retrieve repository metadata (repomd.xml) for repository: /tmp/temp_pulp_repoS6sW6Y. Please verify its path and try again

However, there is no error showed on the Katello side. This error prevents creation of an association between repo and it's clone in Pulp (all clone_ids are empty, even if the cloned repos are already there).

Due to missing this association, Katello is not aware of the existing clone and tries to clone it again in next promotion. This causes the validation error on pulp_id (because a record is aready created from the previous try)

Comment 4 Jeff Weiss 2011-12-09 20:04:48 UTC
*** Bug 765962 has been marked as a duplicate of this bug. ***

Comment 5 Ivan Necas 2011-12-12 12:57:04 UTC
The bug above is not a duplicate of this one

Comment 6 Lukas Zapletal 2011-12-12 13:04:14 UTC
Two issues:

1) We do not report error when an async task fails. We need to properly report those errors in Katello.

2) We should not allow to promote an empty repo.

Comment 7 Lukas Zapletal 2011-12-12 13:11:27 UTC
Working on the 2)

Comment 8 Tomas Strachota 2011-12-12 13:44:30 UTC
Taking the 1)

Comment 9 Tomas Strachota 2011-12-13 08:23:32 UTC
Number 1 fixed in version katello-0.1.139-1

commit 1542d8c21802b56b79a102685a38c9f6c23f2661
async tasks - raising exception when a task fails while waiting until it finishes

Waiting for number 2.

Comment 10 Lukas Zapletal 2011-12-13 14:20:38 UTC
Note to myself: empty repo is UNSYNCHRONIZED repo in this context.

Empty repo is okay: http://lzap.fedorapeople.org/fakerepos/empty/

Comment 11 Lukas Zapletal 2011-12-14 10:26:07 UTC
   def add_product cpid
     product = find_product_by_cpid(cpid)
+
+    # check if product was already synced
+    raise _("Product '#{product.name}' was not synchronized yet") if product.last_sync.nil?
+
     self.products << product
     product
   end


0f5c9f7 765888 - Error during promotion

Comment 12 Ivan Necas 2011-12-14 17:43:58 UTC
The problem with repositories not being promoted before synchronization relates to the bug on Pulp side:

https://bugzilla.redhat.com/show_bug.cgi?id=760310

With the fix on the Pulp side there is no need to check the sync status before promotion.

Comment 13 Lukas Zapletal 2011-12-19 15:13:46 UTC
Ok I will revert the patch as it was fixed in Pulp.

Comment 14 Lukas Zapletal 2011-12-19 17:49:04 UTC
commit 82f3f7b72e758238a4d81997714f2db6113bdad8
Refs: keys, katello-configure-0.1.42-1-6-g82f3f7b
Author:     Lukas Zapletal <lzap+git>
AuthorDate: Mon Dec 19 18:15:36 2011 +0100
Commit:     Lukas Zapletal <lzap+git>
CommitDate: Mon Dec 19 18:42:42 2011 +0100

    Revert "765888 - Error during promotion"

Comment 16 Garik Khachikyan 2012-02-13 12:07:36 UTC
# VERIFIED

Trying with scenarios of import manifest/sync repo/promoting, re-promoting content - all works fine so far.

Please fill free to reopen this bug or another defect related to the Red Hat provider's manifest import/sync/promotion.

As an CDN was used: http://inecas.fedorapeople.org/fakerepos/cds/ (and the fake -manifest-syncable.zip)

a note: promoting empty repos is allowed and is ok now.

Checked against:
---

katello-0.1.235-1.git.0.737ec3f.el6.noarch
katello-cli-0.1.54-1.git.0.2670189.el6.noarch
pulp-0.0.265-1.el6.noarch
candlepin-0.5.17-1.el6.noarch