Bug 1862135 - updating hosts policy using bulk action fails with sql error
Summary: updating hosts policy using bulk action fails with sql error
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: SCAP Plugin
Version: 6.8.0
Hardware: All
OS: All
unspecified
low
Target Milestone: 6.8.0
Assignee: Ondřej Pražák
QA Contact: Jameer Pathan
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-07-30 14:22 UTC by Ranjan Kumar
Modified: 2020-10-27 13:05 UTC (History)
4 users (show)

Fixed In Version: tfm-rubygem-foreman_openscap-4.0.2
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-10-27 13:04:55 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 30536 0 Normal Closed updating hosts policy using bulk action fails with sql error 2020-10-28 17:45:39 UTC
Red Hat Product Errata RHSA-2020:4366 0 None None None 2020-10-27 13:05:09 UTC

Description Ranjan Kumar 2020-07-30 14:22:56 UTC
Description of problem:
Add same policy twice to any host using bulk action fails with sql error, here is traceback
~~~
2020-07-30T10:02:15 [I|app|7234a419] Started POST "/compliance/policies/update_multiple_hosts?host_ids%5B%5D=4&host_ids%5B%5D=1" for 127.0.0.1 at 2020-07-30 10:02:15 -0400
2020-07-30T10:02:15 [I|app|7234a419] Processing by PoliciesController#update_multiple_hosts as HTML
2020-07-30T10:02:15 [I|app|7234a419]   Parameters: {"utf8"=>"✓", "authenticity_token"=>"AsoqhvaapVoYTBwMLIox+2ICKHwvMRV3jjSP0T103oDAJKw954AF0pszr5CazvCF26e9ttVLQUIplONSx6IkGA==", "policy"=>{"id"=>"1"}, "host_ids"=>["4", "1"]}
2020-07-30T10:02:17 [D|tax|7234a419] Current location set to Default Location
2020-07-30T10:02:17 [D|tax|7234a419] Current organization set to Default Organization
2020-07-30T10:02:17 [W|app|7234a419] Action failed
2020-07-30T10:02:17 [D|app|7234a419] Backtrace for 'Action failed' error (ActiveRecord::RecordNotUnique): PG::UniqueViolation: ERROR:  duplicate key value violates unique constraint "index_scaptimony_asset_policies_on_asset_id_and_policy_id"
DETAIL:  Key (asset_id, policy_id)=(8, 1) already exists.

/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/postgresql_adapter.rb:675:in `async_exec_params'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/postgresql_adapter.rb:675:in `block (2 levels) in exec_no_cache'
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.1/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.1/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.1/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/postgresql_adapter.rb:674:in `block in exec_no_cache'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/abstract_adapter.rb:722:in `block (2 levels) in log'

~~~

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


How reproducible: Always


Steps to Reproduce:
1. Go To "All Hosts" 
2. select few Hosts -> Click on "Select Action" on top right and click on "Assign Compliance Policy"
3. Select First Policy and click on submit
4. Repeat same step i.e select same hosts and try to assign same policy

Actual results:  It should not fails with sql error.


Expected results: It should ignore the host if same epolicy is already assign


Additional info:

Comment 1 Ondřej Pražák 2020-07-31 11:37:16 UTC
Created redmine issue https://projects.theforeman.org/issues/30536 from this bug

Comment 2 Bryan Kearney 2020-07-31 12:03:56 UTC
Upstream bug assigned to oprazak

Comment 3 Bryan Kearney 2020-07-31 12:03:59 UTC
Upstream bug assigned to oprazak

Comment 4 Bryan Kearney 2020-08-05 16:03:49 UTC
Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/30536 has been resolved.

Comment 5 Jameer Pathan 2020-08-25 09:57:39 UTC
Verified

Verified with:
- Satellite 6.8.0 snap 12

Test steps:
1. Create a compliance policy
2. Go to Hosts > All Hosts page
3. Select few hosts and assign compliance policy.
4. Select same hosts and same assign compliance policy again.

Observations:
- No sql errors.
- compliance policy applied successfully.

Comment 10 errata-xmlrpc 2020-10-27 13:04:55 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 (Important: Satellite 6.8 release), 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-2020:4366


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