Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1524329 - API endpoint for auto_attach subscription in host bulk action is incorrect
Summary: API endpoint for auto_attach subscription in host bulk action is incorrect
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Subscription Management
Version: 6.2.12
Hardware: x86_64
OS: All
medium
medium
Target Milestone: 6.4.0
Assignee: Ranjan Kumar
QA Contact: Lukáš Hellebrandt
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-12-11 09:35 UTC by Ranjan Kumar
Modified: 2021-03-11 16:36 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-10-16 19:35:13 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 21923 0 Normal Closed API endpoint for auto_attach/remove/add subscription in host bulk action is incorrect 2020-03-31 09:42:17 UTC

Description Ranjan Kumar 2017-12-11 09:35:45 UTC
Description of problem:
API call for subscription auto attach fails for bulk actions

→ curl -u admin:<password> --request PUT --url https://satellite.example.com/api/hosts/bulk/subscriptions/auto_attach --header 'content-type: application/json' --data '{"organization_id": 1, "included": {"ids": [<host_id-1>,<host_id-2>]}}'
{"displayMessage":"ActiveRecord::RecordNotFound","errors":["ActiveRecord::RecordNotFound"]} 

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


How reproducible: Always

Comment 1 Brad Buckingham 2017-12-12 18:36:02 UTC
Moving from POST to ASSIGNED.  Once it is merged upstream, it can go to POST.  Thanks for the submission!!

Comment 3 vritant 2017-12-26 15:27:18 UTC
I think this might not be a subscription-manager bug. Apologies if that is not so, also removed the Triaged keyword so my action can be verified.
If it is a subscription manager bug please elaborate a little.

Comment 4 vritant 2017-12-26 15:41:33 UTC
Apologies. I misread the component name. undoing all my changes.

Comment 5 Satellite Program 2018-01-05 01:18:01 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/21923 has been resolved.

Comment 7 Lukáš Hellebrandt 2018-08-31 12:50:42 UTC
Verified with Sat 6.4 snap 18.

API Help now contains the correct path.

# curl -u admin:changeme --request PUT --url https://$(hostname)/api/hosts/bulk/auto_attach --header 'content-type: application/json' --data '{"organization_id": 1, "included": {"ids": [35,20]}}'

  {"id":"a626d652-0ba2-4504-a5a3-3562c0b5c483","label":"Actions::BulkAction","pending":true,"action":"Bulk action","username":"admin","started_at":"2018-08-31 12:41:11 UTC","ended_at":null,"state":"planned","result":"pending","progress":0.0,"input":{"action_class":"Actions::Katello::Host::AutoAttachSubscriptions","target_ids":[20,35],"target_class":"Host::Managed","args":[],"current_user_id":4},"output":{},"humanized":{"action":"Bulk action","input":null,"output":null,"errors":[]},"cli_example":null}

=> The task has been added, verified in WUI.

When using the old path with .../subscriptions/... , a potentially misleading error occurs:

{"displayMessage":"Action unauthorized to be performed on selected hosts.","errors":["Action unauthorized to bsubscriptions/auto_attach --header 'content-type: application/json' --data '{"organization_id": 1, "included": {"ids": [420,421]}}'(hostname)/api/hosts/bulk/auto_attach --header 'content-type: application/json' --data '{"org
{"displayMessage":"Couldn't find Host::Managed with 'id'=bulk [WHERE \"hosts\".\"type\" IN ('Host::Managed') AND \"hosts\".\"organization_id\" = 1]","errors":["Couldn't find Host::Managed with 'id'=bulk [WHERE \"hosts\".\"type\" IN ('Host::Managed') AND \"hosts\".\"organization_id\" = 1]"]}

That is because the non-bulk version of the API call matches the path and "bulk" is treated as ID. This can potentially cause trouble but I think it makes sense as it is.

Comment 8 Bryan Kearney 2018-10-16 19:35:13 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-2018:2927


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