Bug 1417994

Summary: Unable to remove cloned built-in roles (6.2 backport)
Product: Red Hat Satellite Reporter: Lukas Zapletal <lzap>
Component: Users & RolesAssignee: Swapnil Abnave <sabnave>
Status: CLOSED DUPLICATE QA Contact: Katello QA List <katello-qa-list>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.2.1CC: abalakht, asahni, bbuckingham, bkearney, brcoca, dhawke, dhlavacd, foremar1, kelly.brown1, marbet, mhulan, mjahangi, omaciel, pondrejk, rankumar, sabnave, satellite6-bugs, snemeth
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1378544 Environment:
Last Closed: 2017-02-24 19:07:04 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:
Bug Depends On: 1378544, 1426672    
Bug Blocks:    
Attachments:
Description Flags
Hotfix tarball
none
Hotfix - updated version none

Description Lukas Zapletal 2017-01-31 14:46:14 UTC
+++ This bug was initially created as a clone of Bug #1378544 +++

Description of problem:
Unable to remove cloned built-in roles

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

BACKPORT REQUEST, ONE LINER.

Comment 4 Lukas Zapletal 2017-01-31 14:55:55 UTC
Created attachment 1246320 [details]
Hotfix tarball

I am attaching a hotfix that will prevent from incorrect cloned roles, please apply it:

[root@amd-ma78gm-01 hotfix]# ./satellite-hotfix 1378544
Applying 1378544: Cloned roles cannot be deleted
Applying 1378544: file 1378544-builtin-role.patch
patch -fup1 --verbose -d /usr/share/foreman -r /root/hotfix/backups/1485874196-1378544/1378544.rej -b -B /root/hotfix/backups/1485874196-1378544/ < /root/hotfix/patches/1378544-builtin-role.patch
...
done
Please restart httpd service, other services do not need to be restarted:
  systemctl restart httpd
Also please run the following command to fix existing (cloned) roles:
  echo "Role.where(:builtin => nil).update_all(:builtin => 0)" | foreman-rake console
SUCCESS! Backup files are in /root/hotfix/backups

Then please run this command to fix all existing roles:

#  echo "Role.where(:builtin => nil).update_all(:builtin => 0)" | foreman-rake console

And afterwards you should be able to edit/delete those roles.

Comment 5 Satellite Program 2017-01-31 15:16:01 UTC
Upstream bug assigned to sabnave

Comment 6 Satellite Program 2017-01-31 15:16:07 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/16828 has been resolved.

Comment 8 Lukas Zapletal 2017-02-15 13:27:07 UTC
Can we get QAck? This missed 6.2.8 errata, hopefully this will be in the next one. it is oneliner backport.

Comment 12 Lukas Zapletal 2017-02-24 13:31:20 UTC
Created attachment 1257215 [details]
Hotfix - updated version

Usage (tarball extraction):

  tar -xzf satellite-hotfix-20170101-abcdef1.tar.gz
  cd satellite-hotfix-20170101-abcdef1

Usage (dry run):

  ./satellite-hotfix -n 1234567

Usage:

  ./satellite-hotfix 1234567

Revert a hotfix:

  ./satellite-hotfix -r 1234567

List all available hotfixes:

  ./satellite-hotfix

The numbers are real Red Hat Bugzilla numbers. All backup and reject files are
save in backups/ sub-directory. Please keep the tarball for possible reverting
of the change in the future. If patching fails, revert immediately and report
the output. After each Satellite update, this hotfix process must be repeated
if the updated does not include the bugfix yet, search in errata notes for
bugzilla numbers to confirm. Hotfixes are distributed in tarballs with date
timestamps, new tarball obsoletes the old one and includes all previous
patches.

If system-wide Ruby is not installed for some reason, use Satellite Foreman
Ruby software collection:

  scl enable rh-ruby22 -- ./satellite-hotfix -h

To find out Ruby versions available do:

  ls /opt/*/*ruby* -d

Comment 13 Bryan Kearney 2017-02-24 19:07:04 UTC
closing this out as a duplicate of 1378544

*** This bug has been marked as a duplicate of bug 1378544 ***