Bug 1309308

Summary: User shouldn't be able to install packages after un-registering a host from content-host page
Product: Red Hat Satellite Reporter: Sachin Ghai <sghai>
Component: HostsAssignee: Justin Sherrill <jsherril>
Status: CLOSED ERRATA QA Contact: Sachin Ghai <sghai>
Severity: medium Docs Contact:
Priority: unspecified    
Version: NightlyCC: ehelms
Target Milestone: Unspecified   
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
URL: http://projects.theforeman.org/issues/13756
Whiteboard:
Fixed In Version: rubygem-katello-3.0.0.31-1,rubygem-katello-3.0.0.31-1 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-07-27 11:00:57 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:
Attachments:
Description Flags
packages tab still shows options to install packages when host is unregistered
none
on installing pkg on a unregistered content-host UI raises error: Host has not been registered with subscription-manager. none

Description Sachin Ghai 2016-02-17 12:37:56 UTC
Created attachment 1127930 [details]
packages tab still shows options to install packages when host is unregistered

Description of problem:
I unregistered a content-host from webUI, host was unregistered successfully and I can see a message on UI on accessing subscription and errata tab like:

This Host is not currently registered with subscription-manager. Click here for registration information.

However, packages tab is still available to install packages though host is not registered. So use should get similar message as on accessing the 'packages' tab

Version-Release number of selected component (if applicable):
foreman-release-1.11.0-0.develop.201602111150gitf6014fb.el7.noarch
katello-installer-2.5.0-1.nightly.201602120122git5f95a31.el7.noarch
katello-2.5.0-4.nightly.el7.noarch

How reproducible:
always

Steps to Reproduce:
1. unregister a content-host
2. select content-host and goto 'packages' tab. It allows to install/removes packages
3.

Actual results:
packages tab allows to install/remove/update packages on content-host which is unregistered.

Expected results:
user should get message similar to one accessing subscription/errata tabs like:

This Host is not currently registered with subscription-manager. Click here for registration information.

Additional info:

Comment 1 Sachin Ghai 2016-02-17 12:38:30 UTC
Created redmine issue http://projects.theforeman.org/issues/13756 from this bug

Comment 3 Bryan Kearney 2016-02-17 13:04:37 UTC
Upstream bug component is Content Management

Comment 4 Bryan Kearney 2016-02-27 17:04:53 UTC
Upstream bug assigned to jsherril

Comment 5 Bryan Kearney 2016-02-27 17:04:54 UTC
Upstream bug component is Hosts

Comment 6 Sachin Ghai 2016-03-07 10:09:26 UTC
Reproducible with sat 6.2 snap2.

At first place, we host is not registered then user should get a warning message on installing package:

Like: This Host is not currently registered with subscription-manager

However, now with sat6.2 snap2, user can install package but UI throws error:

Host id '6' content facet is missing a uuid 

Also production.log throws following traceback:

2016-03-07 04:51:59 [app] [I] Started PUT "/api/v2/hosts/6/packages/install" for 10.65.193.200 at 2016-03-07 04:51:59 -0500
2016-03-07 04:51:59 [app] [I] Processing by Katello::Api::V2::HostPackagesController#install as JSON
2016-03-07 04:51:59 [app] [I]   Parameters: {"id"=>6, "packages"=>["zsh"], "api_version"=>"v2", "host_id"=>"6", "host_package"=>{"id"=>6, "packages"=>["zsh"]}}
2016-03-07 04:51:59 [app] [E] Katello::HttpErrors::NotFound: Host id '6' content facet is missing a uuid
 | /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.0.0.4/app/controllers/katello/api/v2/host_packages_controller.rb:95:in `find_editable_host_with_facet'
 | /opt/rh/rh-ror41/root/usr/share/gems/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:424:in `block in make_lambda'
 | /opt/rh/rh-ror41/root/usr/share/gems/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:143:in `call'
 | /opt/rh/rh-ror41/root/usr/share/gems/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:143:in `block in halting_and_conditional'
 | /opt/rh/rh-ror41/root/usr/share/gems/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:149:in `call'
 | /opt/rh/rh-ror41/root/usr/share/gems/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
 | /opt/rh/rh-ror41/root/usr/share/gems/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:149:in `call'
 | /opt/rh/rh-ror41/root/usr/share/gems/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
 | /opt/rh/rh-ror41/root/usr/share/gems/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:166:in `call'
 | /opt/rh/rh-ror41/root/usr/share/gems/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:166:in `block in halting'

Comment 7 Justin Sherrill 2016-05-10 19:02:16 UTC
I plan on improving the experience with:

* At unregister time, delete installed_packages list as they
  may not be accurate
* If attempting to install a package, throw a nicer warning
* UI to attempt to install a package is still there for REX
* Remove duplicate error/success messages block

Comment 8 Bryan Kearney 2016-05-11 14:12:21 UTC
Moving to POST since upstream bug http://projects.theforeman.org/issues/13756 has been closed

Comment 9 Sachin Ghai 2016-05-30 11:59:48 UTC
Thanks Justin,

Verified with sat62 GA snap13
Now I see proper error on trying to install package on unregistered content-host.

Comment 10 Sachin Ghai 2016-05-30 12:00:24 UTC
Created attachment 1162789 [details]
on installing pkg on a unregistered content-host UI raises error: Host has not been registered with subscription-manager.

Comment 11 Bryan Kearney 2016-07-27 11:00:57 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/RHBA-2016:1501