Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upFixes #20929 - Added fact name filtering on import #5021
Conversation
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Issues: #20929 |
theforeman-bot
added
Needs testing
Not yet reviewed
labels
Nov 22, 2017
theforeman-bot
added
Waiting on contributor
Needs re-review
Needs testing
and removed
Not yet reviewed
Waiting on contributor
labels
Dec 7, 2017
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
ShimShtein
Dec 13, 2017
Member
Rebased, renamed, refactored and extended already existing facts:clean rake task
|
Rebased, renamed, refactored and extended already existing |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
lzap
Dec 14, 2017
Member
Marek pointed out on one important issue - fact names are different from interface names.
interfaces => enp30s0,lo,redhat0,virbr0,virbr1,virbr2,virbr0_nic,virbr1_nic,virbr2_nic
ipaddress6_enp30s0 => fd5a:f687:b576:0:xxxx:f6ff:fe3e:aa52
ipaddress_enp30s0 => 192.168.x.13
macaddress_enp30s0 => 88:d7:f6:xx:xx:52
mtu_enp30s0 => 1500
netmask_enp30s0 => 255.255.255.0
network_enp30s0 => 192.168.1.0
I think we should be more explicit to prevent filtering out unwanted entries, therefore I suggest to create separate starting list. How about this:
IGNORED_FACTS = IGNORED_INTERFACES.map{|i| "_#{i}"}This will at least prefix all entries with underscore, which will match what we want.
|
Marek pointed out on one important issue - fact names are different from interface names.
I think we should be more explicit to prevent filtering out unwanted entries, therefore I suggest to create separate starting list. How about this: IGNORED_FACTS = IGNORED_INTERFACES.map{|i| "_#{i}"}This will at least prefix all entries with underscore, which will match what we want. |
theforeman-bot
added
Waiting on contributor
Needs re-review
Needs testing
and removed
Needs re-review
Waiting on contributor
labels
Dec 14, 2017
lzap
reviewed
Dec 19, 2017
I have two big concerns. First, the deletion must not happen during fact upload, but via an external rake task (cron). This way, we can even make this more simple and simply iterate over all fact names via Ruby loop and filter them out using single regexp, you are trying to work in two "modes" (SQL and regexp) which makes the code too complex.
Second, you are not testing with real sample data. I think the code either does not match real world samples, or filters out what's not required. I think the pattern should be with underscore to match macaddress_em1 (pattern *_em1 or dhcp-server::em1 (pattern ::em1).
theforeman-bot
added
Waiting on contributor
Needs re-review
Needs testing
and removed
Needs re-review
Waiting on contributor
labels
Dec 19, 2017
lzap
dismissed
their
stale review
Dec 20, 2017
New version
lzap
requested changes
Dec 20, 2017
Overall no blockers but I don't want to rush this. Can you improve tests, I am still missing one and I have a proposal to share testing data across both two workflows to prevent regressions.
| ignored_fact_name = FactoryBot.create(:fact_name, :name => 'ignored01') | ||
| bad_fact_name = FactoryBot.create(:fact_name, :name => 'empty_bad') | ||
| FactoryBot.create(:fact_value, :fact_name => good_fact_name) | ||
| FactoryBot.create(:fact_value, :fact_name => ignored_fact_name) |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
lzap
Dec 20, 2017
Member
I still do not see testing of "macaddress_em1" kind of fact. Frankly, I was hoping for real-world interface names rather than these artificial ones :-)
lzap
Dec 20, 2017
Member
I still do not see testing of "macaddress_em1" kind of fact. Frankly, I was hoping for real-world interface names rather than these artificial ones :-)
theforeman-bot
added
Waiting on contributor
Needs re-review
Needs testing
and removed
Needs re-review
Waiting on contributor
labels
Dec 20, 2017
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
ShimShtein
Dec 24, 2017
Member
Finally! The tests are green. Had to give up cleaner's DB code, there is no way to escape LIKE query so it will work on all databases.
|
Finally! The tests are green. Had to give up cleaner's DB code, there is no way to escape |
| logger.debug "Removing excluded fact names..." | ||
| deleted_names = FactName.unscoped.where(:id => fact_names).delete_all | ||
| logger.debug "Removed #{deleted_names} fact name records." | ||
| deleted_names |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
lzap
Dec 26, 2017
Member
I am usually against debug messages like "I am doing something..." the "Removed" lines are enough to tell you it has been processed.
lzap
Dec 26, 2017
Member
I am usually against debug messages like "I am doing something..." the "Removed" lines are enough to tell you it has been processed.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
ShimShtein
Dec 27, 2017
Member
It really helps to identify slow queries - you will see the "starting.." message, but not the "finished" one.
ShimShtein
Dec 27, 2017
Member
It really helps to identify slow queries - you will see the "starting.." message, but not the "finished" one.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
lzap
Dec 29, 2017
Member
Fair enough, although AR time is reported for each request by Rails framework and then there is SQL server tracking, but I buy that. We miss TRACE level so much.
lzap
Dec 29, 2017
Member
Fair enough, although AR time is reported for each request by Rails framework and then there is SQL server tracking, but I buy that. We miss TRACE level so much.
| :suffix => '(\Z|::.*)' | ||
| } | ||
| ) | ||
| end |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
lzap
Dec 26, 2017
Member
Okay, this can be moved to settings, why not? The other line with send really hurts :-)
lzap
Dec 26, 2017
Member
Okay, this can be moved to settings, why not? The other line with send really hurts :-)
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
ShimShtein
Dec 27, 2017
Member
Since we don't have a special settings class, I prefer keeping it with the importer. Refactored it to a class method though.
ShimShtein
Dec 27, 2017
Member
Since we don't have a special settings class, I prefer keeping it with the importer. Refactored it to a class method though.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
| 'something::filter::something_else' => 'will_not_show' | ||
| } | ||
| end | ||
| end |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
lzap
Dec 26, 2017
Member
One could say this belongs to Katello, but I really think it should be in core. Thanks.
lzap
Dec 26, 2017
Member
One could say this belongs to Katello, but I really think it should be in core. Thanks.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
ShimShtein
Dec 27, 2017
Member
Katello is only an example of this kind of facts. Since this notation is supported by core, I think it should be tested in core.
ShimShtein
Dec 27, 2017
Member
Katello is only an example of this kind of facts. Since this notation is supported by core, I think it should be tested in core.
| def self.default_excluded_facts(ignored_interfaces = IGNORED_INTERFACES) | ||
| ignored_interfaces | ||
| end |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
lzap
Dec 26, 2017
Member
Can you optionally add couple of tests to test IGNORED_INTERFACES constant actually? We are not sure we ship with default value that just works. A single test with different names "Ipaddress_vnet1" should do it "Ipaddress:vnet1".
lzap
Dec 26, 2017
Member
Can you optionally add couple of tests to test IGNORED_INTERFACES constant actually? We are not sure we ship with default value that just works. A single test with different names "Ipaddress_vnet1" should do it "Ipaddress:vnet1".
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Katello test failures seem irrelevant. |
ShimShtein commentedNov 22, 2017
Added a setting that will filter out fact names, so they won't be recorded into
fact_namesandfact_valuestables at all.