Bug 1436132

Summary: Some container resources not cleaned up after removal from Openshift - research
Product: Red Hat CloudForms Management Engine Reporter: Mooli Tayer <mtayer>
Component: ProvidersAssignee: Bronagh Sorota <bsorota>
Status: CLOSED CURRENTRELEASE QA Contact: Einat Pacifici <epacific>
Severity: high Docs Contact:
Priority: high    
Version: 5.8.0CC: cpelland, dajohnso, fsimonce, jfrey, jhardy, obarenbo, simaishi
Target Milestone: GAKeywords: TestOnly, ZStream
Target Release: 5.9.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: container
Fixed In Version: 5.9.0.1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1469653 1472384 (view as bug list) Environment:
Last Closed: 2018-03-06 14:56:52 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: Container Management Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1469653, 1472384    

Description Mooli Tayer 2017-03-27 09:14:57 UTC
We suspect that some resource types aren't being remove from ManageIQ inventory after removal from openshift[1] those might be types not listed in [2] although some should be removed through relations(i.e when their parent is removed).

We need to check which are the ones that are not being removed and we should probably have a test for each type after that.

[1] https://github.com/ManageIQ/manageiq/pull/14388#issuecomment-288576213
[2] https://github.com/ManageIQ/manageiq/blob/fbd5ebff98f75843644eb75684e6f6abdb8c276a/app/models/ems_refresh/save_inventory_container.rb#L5

Comment 2 zakiva 2017-05-17 16:24:10 UTC
I made some tests to check whether we remove the objects according to an updated inventory we get from Openshift. 

We have two options for removing objects:

1. Actually delete the object, i.e. remove it from the DB. We use this option for most of the Container resources. For these resources, after the object removed from openshift we remove it on our side including its children as expected.
 
2. Disconnect the object, i.e. mark the object as deleted, and remove its relations. However, the object will still remain in the DB. We use this option for several Container resources: Container, ContainerDefinition, ContainerGroup, ContianerProject, and ContainerImage. For these resources, after the object removed from openshift we mark it as deleted and do not change its children. I believe that it makes sense to keep also the children in the DB as they consist data on the object that may be relevant, e.g. in reports, etc. I would like to hear any thoughts on that.

Comment 3 Federico Simoncelli 2017-05-17 16:54:55 UTC
This may be relevant: https://github.com/ManageIQ/manageiq/pull/14359

Comment 4 Mooli Tayer 2017-05-17 17:15:55 UTC
I believe we do change the children (at least in some cases) for example see ContainerDefinition.disconnect_inv.

Comment 5 zakiva 2017-05-17 18:36:45 UTC
(In reply to Mooli Tayer from comment #4)
> I believe we do change the children (at least in some cases) for example see
> ContainerDefinition.disconnect_inv.

Yes, as I mentioned ContainerDefinition is one of the entities that we mark as deleted. So to be more clear: we do not change the children unless they are in the list of entities above (hopefully I didn't miss anything). For example, if a Pod is deleted on Openshift, we will mark both the Pod and its associated Containers and ContainerDefinitions as deleted. However, other children of the deleted pod will not be changed (e.g. its labels).

Comment 6 Federico Simoncelli 2017-05-18 09:08:02 UTC
(In reply to Federico Simoncelli from comment #3)
> This may be relevant: https://github.com/ManageIQ/manageiq/pull/14359

Sorry scratch that I assumed that it was on OpenShift provider removal.

As mentioned from Einat, could bug 1451832 be an instance of this BZ?

Comment 7 zakiva 2017-05-21 13:13:54 UTC
> As mentioned from Einat, could bug 1451832 be an instance of this BZ?

Yes, it seems related. I reproduced this issue and will send a fix soon.

Comment 9 Satoe Imaishi 2017-07-11 16:09:00 UTC
PR: https://github.com/ManageIQ/manageiq/pull/15182

Comment 11 Einat Pacifici 2017-11-30 12:59:03 UTC
Verified. Under full regression tests of Refresh functionality.