Bug 1671577

Summary: Regenerate applicability fails when there is a missing repo
Product: Red Hat Satellite Reporter: sthirugn <sthirugn>
Component: PulpAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED ERRATA QA Contact: jcallaha
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.3.5CC: bmbouter, daviddavis, dkliban, egolov, ggainey, ipanova, mmccune, rchan, ttereshc
Target Milestone: 6.5.0Keywords: FieldEngineering, Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: pulp-2.18.1.1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1684707 (view as bug list) Environment:
Last Closed: 2019-05-14 12:40:00 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description sthirugn@redhat.com 2019-01-31 23:23:39 UTC
Description of problem:
Regenerate applicability fails when there is a missing repo

Version-Release number of selected component (if applicable):
Satellite 6.3.5

How reproducible:
In the customer environment for now

Steps to Reproduce:

# foreman-rake console
Loading production environment (Rails 4.2.6)
Failed to load console gems, starting anyway
irb(main):001:0> ForemanTasks.sync_task(Actions::Katello::Host::GenerateApplicability, Host.all)
ForemanTasks::TaskError: Task e659c565-5c34-4af7-a539-99a512f8ed30: Katello::Errors::PulpError: PLP0000: Repository matching query does not exist.
	from /opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-0.9.6.10/lib/foreman_tasks.rb:40:in `block in sync_task'
	from /opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-0.9.6.10/lib/foreman_tasks.rb:39:in `tap'
	from /opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-0.9.6.10/lib/foreman_tasks.rb:39:in `sync_task'
	from (irb):1
	from /opt/rh/rh-ror42/root/usr/share/gems/gems/railties-4.2.6/lib/rails/commands/console.rb:110:in `start'
	from /opt/rh/rh-ror42/root/usr/share/gems/gems/railties-4.2.6/lib/rails/commands/console.rb:9:in `start'
	from /usr/share/foreman/lib/tasks/console.rake:8:in `block in <top (required)>'
	from /opt/rh/rh-ruby23/root/usr/share/gems/gems/rake-10.4.2/lib/rake/task.rb:240:in `block in execute'
	from /opt/rh/rh-ruby23/root/usr/share/gems/gems/rake-10.4.2/lib/rake/task.rb:235:in `each'
	from /opt/rh/rh-ruby23/root/usr/share/gems/gems/rake-10.4.2/lib/rake/task.rb:235:in `execute'
	from /opt/rh/rh-ruby23/root/usr/share/gems/gems/rake-10.4.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
	from /opt/rh/rh-ruby23/root/usr/share/ruby/monitor.rb:214:in `mon_synchronize'
	from /opt/rh/rh-ruby23/root/usr/share/gems/gems/rake-10.4.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
	from /opt/rh/rh-ruby23/root/usr/share/gems/gems/rake-10.4.2/lib/rake/task.rb:165:in `invoke'
	from /opt/rh/rh-ruby23/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:150:in `invoke_task'
	from /opt/rh/rh-ruby23/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
	from /opt/rh/rh-ruby23/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:106:in `each'
	from /opt/rh/rh-ruby23/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:106:in `block in top_level'
	from /opt/rh/rh-ruby23/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:115:in `run_with_threads'
	from /opt/rh/rh-ruby23/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:100:in `top_level'
	from /opt/rh/rh-ruby23/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:78:in `block in run'
	from /opt/rh/rh-ruby23/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:176:in `standard_exception_handling'
	from /opt/rh/rh-ruby23/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:75:in `run'
	from /opt/rh/rh-ruby23/root/usr/share/gems/gems/rake-10.4.2/bin/rake:33:in `<top (required)>'
	from /opt/rh/rh-ruby23/root/usr/bin/rake:22:in `load'
	from /opt/rh/rh-ruby23/root/usr/bin/rake:22:in `<main>'
irb(main):002:0> ForemanTasks.sync_task(Actions::Katello::Host::GenerateApplicability, Host.all)
ForemanTasks::TaskError: Task d8696409-0f43-4e4e-b474-5cc6d4cb93b8: Katello::Errors::PulpError: PLP0000: Repository matching query does not exist.
	from /opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-0.9.6.10/lib/foreman_tasks.rb:40:in `block in sync_task'
	from /opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-0.9.6.10/lib/foreman_tasks.rb:39:in `tap'
	from /opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-0.9.6.10/lib/foreman_tasks.rb:39:in `sync_task'
	from (irb):2
	from /opt/rh/rh-ror42/root/usr/share/gems/gems/railties-4.2.6/lib/rails/commands/console.rb:110:in `start'
	from /opt/rh/rh-ror42/root/usr/share/gems/gems/railties-4.2.6/lib/rails/commands/console.rb:9:in `start'
	from /usr/share/foreman/lib/tasks/console.rake:8:in `block in <top (required)>'
	from /opt/rh/rh-ruby23/root/usr/share/gems/gems/rake-10.4.2/lib/rake/task.rb:240:in `block in execute'
	from /opt/rh/rh-ruby23/root/usr/share/gems/gems/rake-10.4.2/lib/rake/task.rb:235:in `each'
	from /opt/rh/rh-ruby23/root/usr/share/gems/gems/rake-10.4.2/lib/rake/task.rb:235:in `execute'
	from /opt/rh/rh-ruby23/root/usr/share/gems/gems/rake-10.4.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
	from /opt/rh/rh-ruby23/root/usr/share/ruby/monitor.rb:214:in `mon_synchronize'
	from /opt/rh/rh-ruby23/root/usr/share/gems/gems/rake-10.4.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
	from /opt/rh/rh-ruby23/root/usr/share/gems/gems/rake-10.4.2/lib/rake/task.rb:165:in `invoke'
	from /opt/rh/rh-ruby23/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:150:in `invoke_task'
	from /opt/rh/rh-ruby23/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
	from /opt/rh/rh-ruby23/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:106:in `each'
	from /opt/rh/rh-ruby23/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:106:in `block in top_level'
	from /opt/rh/rh-ruby23/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:115:in `run_with_threads'
	from /opt/rh/rh-ruby23/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:100:in `top_level'
	from /opt/rh/rh-ruby23/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:78:in `block in run'
	from /opt/rh/rh-ruby23/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:176:in `standard_exception_handling'
	from /opt/rh/rh-ruby23/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:75:in `run'
	from /opt/rh/rh-ruby23/root/usr/share/gems/gems/rake-10.4.2/bin/rake:33:in `<top (required)>'
	from /opt/rh/rh-ruby23/root/usr/bin/rake:22:in `load'
	from /opt/rh/rh-ruby23/root/usr/bin/rake:22:in `<main>'
irb(main):003:0>

/var/log/messages showed:
Jan 30 16:18:21 sat6-01 pulp: pulp.server.async.tasks:INFO: [597ed53a] Task failed : [597ed53a-dfc3-43d7-b722-1c14857bb83d]
Jan 30 16:18:21 sat6-01 pulp: celery.worker.job:ERROR: (9112-19648) Task pulp.server.managers.consumer.applicability.regenerate_applicability_for_consumers[597ed53a-dfc3-43d7-b722-1c14857bb83d] raised unexpected: DoesNotExist('Repository matching query does not exist.',)
Jan 30 16:18:21 sat6-01 pulp: celery.worker.job:ERROR: (9112-19648) Traceback (most recent call last):
Jan 30 16:18:21 sat6-01 pulp: celery.worker.job:ERROR: (9112-19648)   File "/usr/lib/python2.7/site-packages/celery/app/trace.py", line 240, in trace_task
Jan 30 16:18:21 sat6-01 pulp: celery.worker.job:ERROR: (9112-19648)     R = retval = fun(*args, **kwargs)
Jan 30 16:18:21 sat6-01 pulp: celery.worker.job:ERROR: (9112-19648)   File "/usr/lib/python2.7/site-packages/pulp/server/async/tasks.py", line 527, in __call__
Jan 30 16:18:21 sat6-01 pulp: celery.worker.job:ERROR: (9112-19648)     return super(Task, self).__call__(*args, **kwargs)
Jan 30 16:18:21 sat6-01 pulp: celery.worker.job:ERROR: (9112-19648)   File "/usr/lib/python2.7/site-packages/pulp/server/async/tasks.py", line 107, in __call__
Jan 30 16:18:21 sat6-01 pulp: celery.worker.job:ERROR: (9112-19648)     return super(PulpTask, self).__call__(*args, **kwargs)
Jan 30 16:18:21 sat6-01 pulp: celery.worker.job:ERROR: (9112-19648)   File "/usr/lib/python2.7/site-packages/celery/app/trace.py", line 438, in __protected_call__
Jan 30 16:18:21 sat6-01 pulp: celery.worker.job:ERROR: (9112-19648)     return self.run(*args, **kwargs)
Jan 30 16:18:21 sat6-01 pulp: celery.worker.job:ERROR: (9112-19648)   File "/usr/lib/python2.7/site-packages/pulp/server/managers/consumer/applicability.py", line 108, in regenerate_applicability_for_consumers
Jan 30 16:18:21 sat6-01 pulp: celery.worker.job:ERROR: (9112-19648)     manager.regenerate_applicability(profile_hash, content_type, profile_id, repo_id)
Jan 30 16:18:21 sat6-01 pulp: celery.worker.job:ERROR: (9112-19648)   File "/usr/lib/python2.7/site-packages/pulp/server/managers/consumer/applicability.py", line 241, in regenerate_applicability
Jan 30 16:18:21 sat6-01 pulp: celery.worker.job:ERROR: (9112-19648)     bound_repo_id)
Jan 30 16:18:21 sat6-01 pulp: celery.worker.job:ERROR: (9112-19648)   File "/usr/lib/python2.7/site-packages/pulp/server/managers/consumer/applicability.py", line 291, in _get_existing_repo_content_types
Jan 30 16:18:21 sat6-01 pulp: celery.worker.job:ERROR: (9112-19648)     repo_obj = model.Repository.objects.get(repo_id=repo_id)
Jan 30 16:18:21 sat6-01 pulp: celery.worker.job:ERROR: (9112-19648)   File "/usr/lib/python2.7/site-packages/mongoengine/queryset/base.py", line 242, in get
Jan 30 16:18:21 sat6-01 pulp: celery.worker.job:ERROR: (9112-19648)     raise queryset._document.DoesNotExist(msg)
Jan 30 16:18:21 sat6-01 pulp: celery.worker.job:ERROR: (9112-19648) Exception: Repository matching query does not exist.

Actual results:
Regenerate applicability errored.

Expected results:
Regenerate applicability works fine

Additional info:

Comment 5 pulp-infra@redhat.com 2019-02-01 13:31:44 UTC
The Pulp upstream bug status is at POST. Updating the external tracker on this bug.

Comment 6 pulp-infra@redhat.com 2019-02-01 13:31:46 UTC
The Pulp upstream bug priority is at Normal. Updating the external tracker on this bug.

Comment 7 pulp-infra@redhat.com 2019-02-11 12:31:51 UTC
The Pulp upstream bug status is at MODIFIED. Updating the external tracker on this bug.

Comment 8 pulp-infra@redhat.com 2019-02-11 13:02:22 UTC
All upstream Pulp bugs are at MODIFIED+. Moving this bug to POST.

Comment 9 Mike McCune 2019-03-01 22:16:34 UTC
This bug was cloned and is still going to be included in the 6.4.3 release. It no longer has the sat-6.4.z+ flag and 6.4.3 Target Milestone Set which are now on the 6.4.z cloned bug. Please see the Clones field to track the progress of this bug in the 6.4.3 release.

Comment 10 pulp-infra@redhat.com 2019-03-20 09:31:49 UTC
The Pulp upstream bug status is at ON_QA. Updating the external tracker on this bug.

Comment 11 pulp-infra@redhat.com 2019-04-02 21:01:34 UTC
The Pulp upstream bug status is at CLOSED - CURRENTRELEASE. Updating the external tracker on this bug.

Comment 12 jcallaha 2019-04-03 14:25:22 UTC
Verified in Satellite 6.5.0 Snap 22

Steps:
Add content to the Satellite
Sync and move it through the content management process
Register a host and align the content to it
Install katello-agent or katello-host-tools, to allow for applicability calculations
Run the mongo shell
Find a repo that is attached to the host
Remove it
Run the reproducer command in foreman-rake console

Results:
-bash-4.2# foreman-rake console
Loading production environment (Rails 5.2.1)
irb(main):001:0> ForemanTasks.sync_task(Actions::Katello::Host::GenerateApplicability, Host.all)
=> #<ForemanTasks::Task::DynflowTask id: "7d2d4d2f-d947-4a7e-8484-851108a69551", type: "ForemanTasks::Task::DynflowTask", label: "Actions::Katello::Host::GenerateApplicability", started_at: "2019-04-03 14:17:34", ended_at: "2019-04-03 14:17:35", state: "stopped", result: "success", external_id: "da1e2fb3-44ab-40dd-b7ae-bc2aed356bdb", parent_task_id: nil, start_at: "2019-04-03 14:17:33", start_before: nil, action: "Generate applicability">
irb(main):002:0> exit

The applicability task completed successfully, despite the repo being removed manually.

Comment 15 errata-xmlrpc 2019-05-14 12:40:00 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2019:1222