Bug 1104795 - Proxy candlepin request to get available releases to System.available_releases
Summary: Proxy candlepin request to get available releases to System.available_releases
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Content Management
Version: 6.0.3
Hardware: Unspecified
OS: Unspecified
unspecified
high vote
Target Milestone: Unspecified
Assignee: Eric Helms
QA Contact: Kedar Bidarkar
URL: http://projects.theforeman.org/issues...
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-06-04 17:33 UTC by Eric Helms
Modified: 2019-09-26 14:32 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-09-11 12:20:47 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 5968 0 None None None 2016-04-22 16:46:08 UTC

Description Eric Helms 2014-06-04 17:33:41 UTC
Katello should intercept requests to GET /consumers/:id/available_releases and return the system's available release versions as viewed by katello.

RHSM will leverage this and bypass its default CDN lookup in order to report the same set as katello.

More Info Here:
https://mojo.redhat.com/docs/DOC-960839

Comment 1 Eric Helms 2014-06-04 17:33:42 UTC
Created from redmine issue http://projects.theforeman.org/issues/5968

Comment 6 Eric Helms 2014-06-23 16:00:26 UTC
This fix only works for subscription manager versions greater than: subscription-manager-1.12.1

Prior to the above version, all requests for a system's available releases would go directly to the CDN (and thus should see no hit on the Katello server and the rhsm.log should show the CDN). After this version, querying for available releases should hit the Katello server and only return releases that in the system's content view the same as happens in the UI.

The sub-man command is: 

subscription-manager release --list

Comment 9 Kedar Bidarkar 2014-07-01 14:31:14 UTC
On the sat6 server side using the sat6-SNAP11-compose
[root@dhcp201-151 ~]# rpm -qav | grep -i subscription-manager
subscription-manager-1.12.4-1.el6.x86_64



2014-07-01 19:44:01,248 [DEBUG] subscription-manager @connection.py:446 - Making request: GET /katello/api/status
2014-07-01 19:44:01,294 [DEBUG] subscription-manager @connection.py:469 - Response: status=200
2014-07-01 19:44:01,295 [ERROR] subscription-manager @utils.py:240 - Error while checking server version: 'rulesVersion'
2014-07-01 19:44:01,296 [ERROR] subscription-manager @utils.py:242 - 'rulesVersion'
Traceback (most recent call last):
  File "/usr/share/rhsm/subscription_manager/utils.py", line 224, in get_server_versions
    rules_version = status['rulesVersion']
KeyError: 'rulesVersion'


==========================================================================
2014-07-01 19:44:01,296 [INFO] subscription-manager @managercli.py:309 - Server Versions: {'rules-version': 'Unknown', 'candlepin': 'Unknown', 'server-type': 'Red Hat Subscription Management'}
2014-07-01 19:44:01,298 [INFO] subscription-manager @managercli.py:274 - self.identity: <Identity, name=dhcp201-151.englab.pnq.redhat.com, uuid=e5f38e1f-9041-4223-94d2-6789f98ffeb5, consumer=consumer: name="dhcp201-151.englab.pnq.redhat.com", uuid=e5f38e1f-9041-4223-94d2-6789f98ffeb5>
2014-07-01 19:44:01,299 [DEBUG] subscription-manager @connection.py:414 - Loaded CA certificates from /etc/rhsm/ca/: redhat-uep.pem, candlepin-local.pem, candlepin-stage.pem
2014-07-01 19:44:01,300 [DEBUG] subscription-manager @connection.py:446 - Making request: GET /katello/api/consumers/e5f38e1f-9041-4223-94d2-6789f98ffeb5
2014-07-01 19:44:01,528 [DEBUG] subscription-manager @connection.py:469 - Response: status=200
2014-07-01 19:44:01,531 [DEBUG] subscription-manager @connection.py:414 - Loaded CA certificates from /etc/rhsm/ca/: redhat-uep.pem, candlepin-local.pem, candlepin-stage.pem
2014-07-01 19:44:01,532 [DEBUG] subscription-manager @connection.py:446 - Making request: GET /katello/api/
2014-07-01 19:44:01,761 [DEBUG] subscription-manager @connection.py:469 - Response: status=200
2014-07-01 19:44:01,764 [DEBUG] subscription-manager @connection.py:686 - Server supports the following resources:
2014-07-01 19:44:01,764 [DEBUG] subscription-manager @connection.py:687 - {'available_releases': '/api/available_releases', 'tasks': '/api/tasks/', 'distributors': '/api/distributors/', 'content_overrides': '/api/content_overrides', 'environments': '/api/environments/', 'content_views': '/api/content_views/', 'content_view_filters': '/api/content_view_filters/', 'puppet_modules': '/api/puppet_modules/', 'host_collections': '/api/host_collections/', 'guestids': '/api/guestids', 'consumers': '/api/consumers/', 'systems': '/api/systems/', 'gpg_keys': '/api/gpg_keys/', 'entitlements': '/api/entitlements/', 'status': '/api/status/', 'capsules': '/api/capsules/', 'users': '/api/users/', 'sync_plans': '/api/sync_plans/', 'subscriptions': '/api/subscriptions/', 'content_view_versions': '/api/content_view_versions/', 'packages': '/api/packages/', 'organizations': '/api/organizations/', 'roles': '/api/roles/', 'package_groups': '/api/package_groups/', 'repository_sets': '/api/repository_sets/', 'repositories': '/api/repositories/', 'products': '/api/products/', 'activation_keys': '/api/activation_keys/', 'errata': '/api/errata/'}



============================================================================

2014-07-01 19:44:01,765 [DEBUG] subscription-manager @connection.py:446 - Making request: GET /katello/api/consumers/e5f38e1f-9041-4223-94d2-6789f98ffeb5/available_releases
2014-07-01 19:44:01,808 [DEBUG] subscription-manager @connection.py:469 - Response: status=404
2014-07-01 19:44:01,809 [ERROR] subscription-manager @connection.py:498 - Response: 404
2014-07-01 19:44:01,809 [ERROR] subscription-manager @connection.py:499 - JSON parsing error: No JSON object could be decoded
2014-07-01 19:44:01,809 [ERROR] subscription-manager @managercli.py:154 - exception caught in subscription-manager
2014-07-01 19:44:01,810 [ERROR] subscription-manager @managercli.py:155 - Server error attempting a GET to /katello/api/consumers/e5f38e1f-9041-4223-94d2-6789f98ffeb5/available_releases returned status 404
Traceback (most recent call last):
  File "/usr/sbin/subscription-manager", line 82, in <module>
    sys.exit(abs(main() or 0))
  File "/usr/sbin/subscription-manager", line 73, in main
    return managercli.ManagerCLI().main()
  File "/usr/share/rhsm/subscription_manager/managercli.py", line 2412, in main
    return CLI.main(self)
  File "/usr/share/rhsm/subscription_manager/cli.py", line 160, in main
    return cmd.main()
  File "/usr/share/rhsm/subscription_manager/managercli.py", line 439, in main
    return_code = self._do_command()
  File "/usr/share/rhsm/subscription_manager/managercli.py", line 1317, in _do_command
    releases = self.release_backend.get_releases()
  File "/usr/share/rhsm/subscription_manager/release.py", line 48, in get_releases
    return provider.get_releases()
  File "/usr/share/rhsm/subscription_manager/release.py", line 67, in get_releases
    return self._conn().getAvailableReleases(self.identity.uuid)
  File "/usr/lib64/python2.6/site-packages/rhsm/connection.py", line 1067, in getAvailableReleases
    return self.conn.request_get(method)
  File "/usr/lib64/python2.6/site-packages/rhsm/connection.py", line 550, in request_get
    return self._request("GET", method)
  File "/usr/lib64/python2.6/site-packages/rhsm/connection.py", line 478, in _request
    self.validateResponse(result, request_type, handler)
  File "/usr/lib64/python2.6/site-packages/rhsm/connection.py", line 526, in validateResponse
    handler=handler)
RemoteServerException: Server error attempting a GET to /katello/api/consumers/e5f38e1f-9041-4223-94d2-6789f98ffeb5/available_releases returned status 404


Me not sure, if something is missing. But do let me know if it is so. for now it looks like it's FAILEDQA.

Comment 10 Michael Stead 2014-07-09 14:03:20 UTC
Definitely an issue.

Looking at the log, subscription-manager seems to be doing what it should be. The root resource exists for available_releases, and a call is being made to katello for the release versions. Subscription-manager would be requesting them from the CDN directly, otherwise.

To me this appears to be an issue with the way katello is handling GET /katello/api/consumers/:consumer_uuid/available_releases

I wonder if katello is proxying this request directly to candlepin, instead of handling itself (as it should be). Candlepin does not implement that end-point, so if it were proxied, the 404 would occur from candlepin.

Comment 11 Michael Stead 2014-07-11 13:43:34 UTC
I have confirmed that this is happening on the katello side. The issue is that the route for GET /katello/api/consumers/:consumer_uuid/available_releases is included in v2 but not in v1 routing file. Candlepin proxied routes are handled by V1 routes and therefore it is not being matched.

Adding a match statement to config/routes/api/v1.rb will fix the issue.

NOTE: This is not broken in github master -- only beta.

Comment 12 Eric Helms 2014-07-28 18:27:12 UTC
Please re-test this on a more recent snap.

Comment 14 Kedar Bidarkar 2014-08-11 12:42:35 UTC
Tested with 
a) Sat6-GA-Snap4
b) subscription-manager-1.12.4-1.el6.x86_64
c) python-rhsm-1.12.3-1.el6.x86_64

[root@xxxx ~]# subscription-manager release --list
+-------------------------------------------+
          Available Releases
+-------------------------------------------+
6.4
6.5

Comment 18 Bryan Kearney 2014-09-11 12:20:47 UTC
This was delivered with Satellite 6.0 which was released on 10 September 2014.


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