Bug 1492047

Summary: Old interfaces are never removed from Foreman DB
Product: Red Hat Satellite Reporter: Ivan Necas <inecas>
Component: FactAssignee: Shimon Shtein <sshtein>
Status: CLOSED ERRATA QA Contact: Lai <ltran>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.2.0CC: bkearney, egolov, fgarciad, ltran, mhulan, mmccune, mmithaiw, pmoravec, sshtein, sthirugn, tstrachota
Target Milestone: 6.4.0Keywords: FieldEngineering, PrioBumpField, PrioBumpQA, 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: Environment:
Last Closed: 2018-10-16 19:18:33 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
One interface removed none

Description Ivan Necas 2017-09-15 10:44:56 UTC
Hosts like hypervisors or docker hosts may often change interfaces (e.g. network bridges) which confuses Foreman and during fact import it creates more and more interfaces, old are never deleted. After some time when a host passes thousands of interfaces, due to O(n^2) one fact upload can take several minutes of processing.

We need to delete old interfaces from Foreman database, either during fact upload directly or on schedule (those that hasn't been updated for a while).

The behvior is really bad, Foreman eats up all memory until passenger process is restarted, which can take a while (non-Enterprise version do not have maximum memory setting).

Comment 1 Ivan Necas 2017-09-15 10:45:03 UTC
Created from redmine issue http://projects.theforeman.org/issues/19244

Comment 2 Ivan Necas 2017-09-15 10:45:08 UTC
Upstream bug assigned to None

Comment 4 Ivan Necas 2017-09-15 10:48:06 UTC
*** Bug 1473644 has been marked as a duplicate of this bug. ***

Comment 7 Francisco Garcia 2018-01-05 09:25:10 UTC
*** Bug 1455891 has been marked as a duplicate of this bug. ***

Comment 8 Satellite Program 2018-01-24 19:14:33 UTC
Upstream bug assigned to sshtein

Comment 9 Satellite Program 2018-01-24 19:14:37 UTC
Upstream bug assigned to sshtein

Comment 10 Satellite Program 2018-02-14 11:15:57 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/19244 has been resolved.

Comment 12 Ivan Necas 2018-09-21 15:00:59 UTC
Verification steps:

1. register a host with multiple network interfaces
2. ensure the interfaces are loaded when going to the host details, and that the interfaces are not marked as managed
3. Go to Administer -> Settings -> Provisioning, add a pattern that would match one of the interfaces "Ignore interfaces with matching identifier"
4. foreman-rake interfaces:clean
5. the interfaces that match the pattern should be removed from the host

Comment 13 Lai 2018-09-21 20:01:30 UTC
Created attachment 1485789 [details]
One interface removed

Followed inecas' instruction.

1. Registered a host with multiple network interfaces
2. Saw that interfaces are not marked as managed. (eth1)
3. Added eth1 to the "Ignore interfaces with matching identifier" list
4. Ran foreman-rake interface:clean
5. Checked that the eth1 interface was removed.

-bash-4.2# foreman-rake interfaces::clean
/usr/share/foreman/lib/foreman.rb:8: warning: already initialized constant Foreman::UUID_REGEXP
/usr/share/foreman/lib/foreman.rb:8: warning: previous definition of UUID_REGEXP was here
/usr/share/foreman/lib/core_extensions.rb:182: warning: already initialized constant ActiveSupport::MessageEncryptor::DEFAULT_CIPHER
/opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activesupport-5.1.6/lib/active_support/message_encryptor.rb:22: warning: previous definition of DEFAULT_CIPHER was here
rake aborted!
Don't know how to build task 'interfaces::clean' (see --tasks)
/opt/rh/rh-ruby24/root/usr/share/gems/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
(See full trace by running task with --trace)
-bash-4.2# foreman-rake interfaces:clean
/usr/share/foreman/lib/foreman.rb:8: warning: already initialized constant Foreman::UUID_REGEXP
/usr/share/foreman/lib/foreman.rb:8: warning: previous definition of UUID_REGEXP was here
/usr/share/foreman/lib/core_extensions.rb:182: warning: already initialized constant ActiveSupport::MessageEncryptor::DEFAULT_CIPHER
/opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activesupport-5.1.6/lib/active_support/message_encryptor.rb:22: warning: previous definition of DEFAULT_CIPHER was here
Starting ingnored interfaces clean up...
Finished, cleaned 1 interfaces

Check attachment for eth1 not showing up.

Comment 15 Bryan Kearney 2018-10-16 19:18:33 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/RHSA-2018:2927