-
Notifications
You must be signed in to change notification settings - Fork 297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #38003 - more efficient handle_acs_product_removal #11214
Fixes #38003 - more efficient handle_acs_product_removal #11214
Conversation
I dont understand the failed tests:
should be independent.
That seems relevant, but I can not reproduce it - what does the test do differently than me? 1) create a product and a repo with feed URL, 2) create ACS referring to the product, 3) delete the repo - here, some extra debugs show me that Maybe this is a consequence of (unrelated?) error
? |
Test failures are unrelated, restarting them. There was an issue with remote_execution that caused those. |
repo_content_types.add(test_repo.content_type) if (repository.id != test_repo.id) && test_repo.url.present? | ||
end | ||
root_ids = product.repositories.where.not(:id => repository.id).pluck(:root_id).uniq | ||
repo_content_types = ::Katello::RootRepository.where(:id => root_ids).where.not(:url => [nil, '']).pluck(:content_type).uniq |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about
repo_content_types = ::Katello::RootRepository.where(:id => product.repositories.where.not(:id => repository.id).select(:root_id)).where.not(:url => [nil, '']).distinct.pluck(:content_type)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was my original patch :) But wasnt sure about code readability here (or where to split the cmd into multiple lines).
Either patch is fine for me. Let me know if I shall update the PR per this suggestion.
Before PR: [root@ip-10-0-168-118 ~]# top
top - 14:31:25 up 22:44, 2 users, load average: 1.13, 1.17, 1.50
Tasks: 315 total, 2 running, 313 sleeping, 0 stopped, 0 zombie
%Cpu(s): 16.6 us, 0.3 sy, 0.0 ni, 83.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
MiB Mem : 23776.6 total, 8386.2 free, 14127.7 used, 1854.1 buff/cache
MiB Swap: 4096.0 total, 4096.0 free, 0.0 used. 9648.9 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
162874 foreman 20 0 9849.0m 10.7g 12032 S 100.0 40.9 15:40.76 rails
2024-11-13T14:38:54 [I|app|fedcbe8b] Completed 202 Accepted in 1107208ms (Views: 136.3ms | ActiveRecord: 26627.4ms | Allocations: 346926573) With @parthaa suggestion: |
Was the reason for this code existing tested as well? You would test it by deleting the last repository with an upstream URL in a product that belongs to a simplified ACS. The code should then remove the empty product from the ACS. |
Yes, I tested this scenario on a backport of the patch to my Sat6.15. I noticed log |
@pmoravec Are you able to push up a change with Partha's suggestion in it and rebase(that should fix the test failures) The improvement is so much faster. My satellite UI literally crashed because it took to long to return the task. |
9febdb8
to
b368813
Compare
Sure, here you are ;-) |
b368813
to
45b89be
Compare
Still same/similar errors in CI test..? :-o |
This looks like the test failure: Error: Failure: test_0009_plans ACS product removal when removing the deleting the last repo with URL
Expected: 0
Actual: 1 @ianballou do you know why that would have failed with the new DB query? |
I'm not sure just by looking at the query, the best way to find out would be to debug the test and see what's actually going wrong. |
I'm looking into it a bit, I think the issue might come down to the test data caching old root repository URLs. I was seeing unexpected results during debugging. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did some debugging, hopefully these results help a little:
45b89be
to
7ad9723
Compare
@pmoravec @qcjames53 it looks like the same test is failing :( |
Yeah.. The own manual test case "add product with last repo to ACS, delete the repo, check the ACS" against the current code (backported to a Satellite) passes to me. Is the test case updated in upstream? It is https://github.com/Katello/katello/blob/master/test/actions/katello/repository_test.rb#L210-L228 ? Also, should not I update the test on my branch? I mean, what test is executed by the CI jobs - from the given PR or from upstream? |
Just to be super safe, does it also work if you have two yum repositories in a product with an ACS, one with a URL and one without a URL, and you delete the repo with the URL? |
You can replace the failing test with the fixed one that @qcjames53 provided in the comments above. The test CI runs the tests that are in your own branch used in this PR. |
7ad9723
to
3a63647
Compare
Running test:
I got:
So here the ACS<->Product relation was properly removed. I updated the test in my PR as well, let see now.. |
I dont want to fight for my change, it can be possible I have a mistake there, just a thought about the slight difference in checks. Original check applied test:
for each repository individually. My approach applies the
and that is the same like my check does, just in different ordering of conditions. I replaced About the modified test case: what is the reference to |
With the testing being done I'm pretty confident that your PR is okay. Since your fix here brings high value, if we can't get the test working in a couple more days I suggest we temporarily disable it. We can get the test working again after the fact to release you Pavel :) |
|
||
# manually remove the URLs from all repos in product except repository | ||
repository.product.repositories.each do |repo| | ||
repo.root.update!(url: nil) unless repo.id == repository.id | ||
testing_repo = repository.product.repositories[4] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@qcjames53 I'm not sure if the repository at index [4] will consistently be the same one, we'd probably need to look up by name instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually.... it looks like this was applied to the wrong test? The failing test is plans ACS product removal when removing the deleting the last repo with URL
. I'll see about updating that other test to see if it helps.
@pmoravec this diff should fix all of the tests:
|
Updating also relevant test per qcjames53's and ianballou's comments. Signed-off-by: Pavel Moravec <[email protected]>
3a63647
to
76a17a8
Compare
Cool, that helped, thanks! Maybe I copy&pasted wrong patch from the discussion, sorry for the confusion. Now just rpm-build on RHEL8 is failing - I think due to this:
but I have no idea how to resolve it (though it should be independent on this PR). |
We don't need the EL8 to pass, those are gone now and removed yesterday. Will give it another test and if it looks good will merge it in. Thanks @ianballou @qcjames53 for helping Pavel getting the tests passing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK, works great @pmoravec thank you. Big difference with the pr applied:
Before:
2024-11-25T15:13:33 [I|app|9eb151c6] Completed 202 Accepted in 754786ms (Views: 115.9ms | ActiveRecord: 20691.8ms | Allocations: 241932979)
After:
Completed 202 Accepted in 13832ms (Views: 160.9ms | ActiveRecord: 2170.0ms | Allocations: 5362191)
Since this was merged we see nightly fail:
The next run failed on the same thing. |
@ianballou @qcjames53 do you have any suggestions to fix nightly? It was all green on the pr, why I merged it |
I wonder if there's random behavior and so a different seed caused a failure |
ktest test/actions/katello/repository_test.rb --seed 32408 reproduces the failing test. |
This seems to be an issue with the [4] index I used to select the RHEL7 package. It looks like this index is occasionally incorrect. Sorry about that; I didn't know that was something that could happen. This will need another PR to so we're selecting by package instead of index for this unit test. |
I think #11237 has resolved the failure, but wasn't linked here. |
Thanks Ewoud! |
What are the changes introduced in this pull request?
Simplified calculation of content types that remain in the product after the repo removal. One (or two) ActiveRecord queries are much faster and much less memory demanding than traversing potentially hundreds or thousands of repos in the product.
Considerations taken when implementing this change?
The PR was tested in one call flow only (CV version deletion).
What are the testing steps for this pull request?
See the foreman issue.