Bug 1357122 - [upgrade - with oscap] upgrade step migrate_foreman failed
Summary: [upgrade - with oscap] upgrade step migrate_foreman failed
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Upgrades
Version: 6.2.0
Hardware: Unspecified
OS: Unspecified
high
high vote
Target Milestone: Unspecified
Assignee: Shlomi Zadok
QA Contact: Kedar Bidarkar
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-07-15 20:00 UTC by Kedar Bidarkar
Modified: 2019-09-26 14:37 UTC (History)
5 users (show)

Fixed In Version: foreman-1.11.0.49-1
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-07-27 11:23:18 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 13529 0 None None None 2016-07-17 13:24:20 UTC

Description Kedar Bidarkar 2016-07-15 20:00:31 UTC
Description of problem:

[ERROR 2016-07-15 15:06:42 main] Upgrade step migrate_foreman failed. Check logs for more information.
[DEBUG 2016-07-15 15:06:42 main] Exit with status code: 1 (signal was 1)
[ERROR 2016-07-15 15:06:42 main] Errors encountered during run:
[ERROR 2016-07-15 15:06:42 main] rake aborted!
ArgumentError: some permissions were not found
/usr/share/foreman/app/models/role.rb:136:in `add_permissions'
/usr/share/foreman/app/models/role.rb:151:in `add_permissions!'
/usr/share/foreman/app/services/foreman/plugin.rb:232:in `block in role'
/opt/rh/rh-ror41/root/usr/share/gems/gems/activerecord-4.1.5/lib/active_record/connection_adapters/abstract/database_statements.rb:201:in `block in transaction'
/opt/rh/rh-ror41/root/usr/share/gems/gems/activerecord-4.1.5/lib/active_record/connection_adapters/abstract/database_statements.rb:209:in `within_new_transaction'
/opt/rh/rh-ror41/root/usr/share/gems/gems/activerecord-4.1.5/lib/active_record/connection_adapters/abstract/database_statements.rb:201:in `transaction'
/opt/rh/rh-ror41/root/usr/share/gems/gems/activerecord-4.1.5/lib/active_record/transactions.rb:208:in `transaction'
/usr/share/foreman/app/services/foreman/plugin.rb:230:in `role'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman_openscap-0.5.3.15/lib/foreman_openscap/engine.rb:96:in `block (2 levels) in <class:Engine>'
/usr/share/foreman/app/services/foreman/plugin.rb:64:in `instance_eval'



Version-Release number of selected component (if applicable):
Sat62-snap20.1-RHEL6.8 + the fix in this bug https://bugzilla.redhat.com/show_bug.cgi?id=1356447#c7

How reproducible:
By upgrading from sat61 to sat62 with a setup where OSCAP is configured.

Steps to Reproduce:
1. Sat6.1.9 + oscap configured
2. satellite-installer --scenario satellite --upgrade
3.

Actual results:
upgrade step: migrate_foreman fails

Expected results:

upgrade step: migrate_foreman should succeed

Additional info:

Will be uploading foreman-debug logs shortly.

Comment 4 Ohad Levy 2016-07-17 08:34:54 UTC
looking at the logs, it looks like some part is missing. e.g.

i can see in the seed logs:

You have 13 pending migrations:
  20150819105725 AddLookupValueMatchToHostAndHostgroup
  20150917155300 UpdateHostStatusStatusFieldInt
  20151009084350 DropPtables
  20151019174035 RenameDomainHostCount
  20151025120534 AddHiddenValueToLookupKey
  20151104100257 AddHostsCountToHostgroup
  20151109152507 AddHostStatusHostIdIndex
  20151120153254 DeleteBootableInterface
  20151220093801 RemoveSpacesFromSmartVariableKey
  20160201131211 AddExpiredLogsToSmartProxy
  20160215143900 AddSubnetDomainRelationConstraints
  20160404074723 DowncaseDisplayTypes
  20160609092110 RemoveNilFromMergeOverride

yet, in the db migration logs it looks like it ran without any missing migrations?

installer logs shows it ran successfully (db:migrate).

Are you able to reproduce / provide machine that we can reproduce this on?
thanks!

Comment 5 Tomer Brisker 2016-07-17 10:16:23 UTC
Looks like this stems from 2 openscap permissions being created twice: 

[2] pry(#<Foreman::Plugin>)> Permission.where(:name => permissions)
=> [#<Permission id: 237, name: "view_arf_reports", resource_type: nil, created_at: "2016-06-30 06:57:00", updated_at: "2016-06-30 06:57:00">,
 #<Permission id: 245, name: "destroy_arf_reports", resource_type: nil, created_at: "2016-07-15 17:00:18", updated_at: "2016-07-15 17:00:18">,
 #<Permission id: 247, name: "view_policies", resource_type: "ForemanOpenscap::Policy", created_at: "2016-07-15 17:00:18", updated_at: "2016-07-15 17:00:18">,
 #<Permission id: 248, name: "edit_policies", resource_type: "ForemanOpenscap::Policy", created_at: "2016-07-15 17:00:18", updated_at: "2016-07-15 17:00:18">,
 #<Permission id: 249, name: "create_policies", resource_type: "ForemanOpenscap::Policy", created_at: "2016-07-15 17:00:18", updated_at: "2016-07-15 17:00:18">,
 #<Permission id: 250, name: "create_policies", resource_type: "ForemanOpenscap::Policy", created_at: "2016-07-15 17:00:18", updated_at: "2016-07-15 17:00:18">,
 #<Permission id: 251, name: "destroy_policies", resource_type: "ForemanOpenscap::Policy", created_at: "2016-07-15 17:00:18", updated_at: "2016-07-15 17:00:18">,
 #<Permission id: 252, name: "assign_policies", resource_type: "ForemanOpenscap::Policy", created_at: "2016-07-15 17:00:18", updated_at: "2016-07-15 17:00:18">,
 #<Permission id: 253, name: "view_scap_contents", resource_type: "ForemanOpenscap::ScapContent", created_at: "2016-07-15 17:00:18", updated_at: "2016-07-15 17:00:18">,
 #<Permission id: 254, name: "edit_scap_contents", resource_type: "ForemanOpenscap::ScapContent", created_at: "2016-07-15 17:00:18", updated_at: "2016-07-15 17:00:18">,
 #<Permission id: 255, name: "create_scap_contents", resource_type: "ForemanOpenscap::ScapContent", created_at: "2016-07-15 17:00:18", updated_at: "2016-07-15 17:00:18">,
 #<Permission id: 256, name: "destroy_scap_contents", resource_type: "ForemanOpenscap::ScapContent", created_at: "2016-07-15 17:00:18", updated_at: "2016-07-15 17:00:18">,
 #<Permission id: 257, name: "destroy_scap_contents", resource_type: "ForemanOpenscap::ScapContent", created_at: "2016-07-15 17:00:18", updated_at: "2016-07-15 17:00:18">]

Note that "destroy_scap_contents" and "create_policies" appear twice, though this should not be allowed (as permission names should be unique). This causes the open scap plugin initialization to fail, stopping any attempt to start the application (such as running migrations) to fail. 
I attempted to investigate what caused the duplicate permissions, but still haven't found the root cause.

Comment 6 Ohad Levy 2016-07-17 13:24:20 UTC
OK, after further investigation this happens due to a fairly rare race condition in plugin add permissions. connecting to existing upstream issue.

Comment 7 Bryan Kearney 2016-07-17 14:16:43 UTC
Upstream bug assigned to szadok

Comment 8 Bryan Kearney 2016-07-17 14:16:45 UTC
Upstream bug component is Upgrades

Comment 9 Bryan Kearney 2016-07-17 14:16:48 UTC
Upstream bug assigned to szadok

Comment 10 Brad Buckingham 2016-07-18 13:04:07 UTC
Moving to POST as upstream fix has been merged.

Comment 11 Kedar Bidarkar 2016-07-21 13:08:40 UTC
This issue is no longer seen while upgrading with oscap for RHEL6 or RHEL7 setups.

As this is a rare race condition, please feel free to re-open this bug, if seen again.

VERIFIED With sat62-snap20.3(GA)

Comment 12 Bryan Kearney 2016-07-27 11:23:18 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


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