Bug 1728157 - Deletion of hostgroup will not remove connection between hostgroup and OpenScap policies
Summary: Deletion of hostgroup will not remove connection between hostgroup and OpenSc...
Keywords:
Status: NEW
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: SCAP Plugin
Version: 6.9.0
Hardware: x86_64
OS: All
medium
medium
Target Milestone: Unspecified
Assignee: satellite6-bugs
QA Contact: Jameer Pathan
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-07-09 08:07 UTC by Jan Jansky
Modified: 2023-08-12 00:30 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-09-02 15:17:51 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 27259 0 Normal New Deletion of hostgroup will not remove connection between hostgroup and OpenScap policies 2022-03-10 11:05:51 UTC
Red Hat Issue Tracker SAT-19502 0 None None None 2023-08-11 10:53:58 UTC
Red Hat Knowledge Base (Solution) 5064501 0 None None None 2020-06-30 09:34:47 UTC

Description Jan Jansky 2019-07-09 08:07:20 UTC
Description of problem: When is deleted hostgroup with associated OpenScap policies, policies are not cleaned properly which end with failing API and hammer calls


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


How reproducible: Always. Same for 6.4, most likely even older Satellite.


Steps to Reproduce:
1. Create hostgroup x,y,z
2. Create scap content a,b,c
3. Create scap policy d,e,f
4. Edit policy d,e,f and attach hostgroups x,y,z
5. Delete hostgroups x,y,z
6. hammer policy info --name d

Actual results:
Couldn't find all Hostgroups with 'id': (1, 2, 3) (found 0 results, but was looking for 3).


Expected results:
Id:                        1
Name:                      d
Created at:                2019-01-01 00:00:00 UTC
Period:                    weekly
Weekday:                   monday
Day of month:              
Cron line:                 
SCAP content Id:           1
SCAP Content profile Id:   1
Tailoring file Id:         
Tailoring file profile Id: 
Locations:                 
    Default Location
Organizations:             
    Default Organization
Hostgroups:                

Additional info:

In Database records are staying.

select * from foreman_openscap_assets;
 id |         created_at         |         updated_at         | assetable_type | assetable_id 
----+----------------------------+----------------------------+----------------+--------------
  1 | 2019-07-09 07:51:27.390499 | 2019-07-09 07:51:27.390499 | Hostgroup      |            1
  2 | 2019-07-09 07:51:27.470928 | 2019-07-09 07:51:27.470928 | Hostgroup      |            2
  3 | 2019-07-09 07:51:27.474601 | 2019-07-09 07:51:27.474601 | Hostgroup      |            3
  4 | 2019-07-09 07:51:38.68147  | 2019-07-09 07:51:38.68147  | Hostgroup      |            1
  5 | 2019-07-09 07:51:38.698747 | 2019-07-09 07:51:38.698747 | Hostgroup      |            2
  6 | 2019-07-09 07:51:38.702891 | 2019-07-09 07:51:38.702891 | Hostgroup      |            3


select * from foreman_openscap_asset_policies;
 asset_id | policy_id 
----------+-----------
        1 |         1
        2 |         1
        3 |         1
        4 |         2
        5 |         2
        6 |         2
        7 |         3
        8 |         3
        9 |         3

Those records should be properly cleaned during hostgroup deletion.

Comment 4 Ondřej Pražák 2019-07-10 07:14:51 UTC
Created redmine issue https://projects.theforeman.org/issues/27259 from this bug

Comment 9 Mike McCune 2021-07-13 21:54:48 UTC
Upon review of our valid but aging backlog the Satellite Team has concluded that this Bugzilla does not meet the criteria for a resolution in the near term, and are planning to close in a month. This message may be a repeat of a previous update and the bug is again being considered to be closed. If you have any concerns about this, please contact your Red Hat Account team.  Thank you.

Comment 10 Mike McCune 2021-08-10 21:34:00 UTC
Thank you for your interest in Red Hat Satellite. We have evaluated this request, and while we recognize that it is a valid request, we do not expect this to be implemented in the product in the foreseeable future. This is due to other priorities for the product, and not a reflection on the request itself. We are therefore closing this out as WONTFIX. If you have any concerns about this feel free to contact your Red Hat Account Team. Thank you.

Comment 11 Pavel Moravec 2021-10-15 13:12:44 UTC
Reopening it as I have a reproducer. Basic idea: assign a Hostgroup to more Policies and then delete the HG. Second (and third etc., I expect) associated Policy will have invalid reference to the deleted HG.

Particular steps:
0) Create two policies (I use names 'SCAP-policy-test' with id=1 and 'SCAP-policy-test2' with id=2 below)

1) Have reproducer script reproducer_for_HG_Policy.sh :

HGNAME="HostGroup_$((RANDOM%100))"
hmr="echo "

$hmr policy update --name 'SCAP-policy-test'
$hmr policy update --name 'SCAP-policy-test2'

$hmr hostgroup create --name $HGNAME
$hmr policy update --hostgroups $HGNAME --id 1
$hmr policy update --hostgroups $HGNAME --id 2
$hmr hostgroup delete --name $HGNAME
$hmr policy update --name 'SCAP-policy-test'
$hmr policy update --name 'SCAP-policy-test2'

$hmr policy update --id 1
$hmr policy update --id 2
$hmr hostgroup create --name ${HGNAME}_2
$hmr policy update --hostgroups ${HGNAME}_2 --id 1
$hmr policy update --hostgroups ${HGNAME}_2 --id 2
$hmr hostgroup delete --name ${HGNAME}_2
$hmr policy update --id 1
$hmr policy update --id 2

2) Execute it:
./reproducer_for_HG_Policy.sh | hammer shell

3) See the results:
hammer> policy update --name SCAP-policy-test
Policy updated
hammer> policy update --name SCAP-policy-test2
Policy updated
hammer> hostgroup create --name HostGroup_88
Hostgroup created.
hammer> policy update --hostgroups HostGroup_88 --id 1
Policy updated
hammer> policy update --hostgroups HostGroup_88 --id 2
Policy updated
hammer> hostgroup delete --name HostGroup_88
Hostgroup deleted.
hammer> policy update --name SCAP-policy-test
Policy updated
hammer> policy update --name SCAP-policy-test2
Could not update the policy:
  Couldn't find Hostgroup with 'id'=26
hammer> policy update --id 1
Policy updated
hammer> policy update --id 2
Policy updated
hammer> hostgroup create --name HostGroup_88_2
Hostgroup created.
hammer> policy update --hostgroups HostGroup_88_2 --id 1
Policy updated
hammer> policy update --hostgroups HostGroup_88_2 --id 2
Policy updated
hammer> hostgroup delete --name HostGroup_88_2
Hostgroup deleted.
hammer> policy update --id 1
Policy updated
hammer> policy update --id 2
Policy updated
hammer> 

Surprisingly, "policy update --id .." _does_ work well, byt "policy update --name .." does _not_ work . Don't ask me why :) I have no clue. But at least "policy update --id .." is a workaround (that keeps orphaned records in DB, such that e.g. "policy list" does not work).

Comment 12 Pavel Moravec 2021-10-15 13:32:14 UTC
Please note that the key technical problem is in orphaned records in foreman_openscap_assets table. BUT *any* HG deletion (even associated to one Policy) leaves an orphaned record in foreman_openscap_asset_policies table.

These foreman_openscap_asset_policies orphans are not an issue now, as far as I tried various steps. But still it isn't nice to leave orphaned records either where, due to several reasons, and we should ideally fix this as well.

Comment 14 Mike McCune 2022-01-28 22:30:40 UTC
Upon review of our valid but aging backlog the Satellite Team has concluded that this Bugzilla does not meet the criteria for a resolution in the near term, and are planning to close in a month. This message may be a repeat of a previous update and the bug is again being considered to be closed. If you have any concerns about this, please contact your Red Hat Account team. Thank you.

Comment 15 Mike McCune 2022-03-18 19:44:22 UTC
Thank you for your interest in Red Hat Satellite. We have evaluated this request, and while we recognize that it is a valid request, we do not expect this to be implemented in the product in the foreseeable future. This is due to other priorities for the product, and not a reflection on the request itself. We are therefore closing this out as WONTFIX. If you have any concerns about this feel free to contact your Red Hat Account Team. Thank you.

Comment 17 Mike McCune 2022-07-08 17:15:31 UTC
Upon review of our valid but aging backlog the Satellite Team has concluded that this Bugzilla does not meet the criteria for a resolution in the near term, and are planning to close in a month. This message may be a repeat of a previous update and the bug is again being considered to be closed. If you have any concerns about this, please contact your Red Hat Account team.  Thank you.

Comment 18 Brad Buckingham 2022-09-02 20:08:50 UTC
Thank you for your interest in Red Hat Satellite. We have evaluated this request, and while we recognize that it is a valid request, we do not expect this to be implemented in the product in the foreseeable future. This is due to other priorities for the product, and not a reflection on the request itself. We are therefore closing this out as WONTFIX. If you have any concerns about this feel free to contact your Red Hat Account Team. Thank you.

Comment 19 Adam Ruzicka 2023-08-11 10:52:24 UTC
Reopening, we might take a stab at this as part of refreshing openscap.


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