Fixes #33525 - Add debs packages_restrict_latest#9671
Fixes #33525 - Add debs packages_restrict_latest#9671m-bucher wants to merge 1 commit intoKatello:masterfrom
Conversation
|
Issues: #33525 |
93a1677 to
62a5c67
Compare
a6fe79d to
9875519
Compare
9875519 to
6835c26
Compare
6835c26 to
91d6332
Compare
|
Can you add some benchmark values here? https://ruby-doc.org/stdlib-2.5.3/libdoc/benchmark/rdoc/Benchmark.html How can we get this fast? |
91d6332 to
1142695
Compare
adamruzicka
left a comment
There was a problem hiding this comment.
Ack from the logic point of view
There was a problem hiding this comment.
Capturing things we talked about live: If I were doing this I'd probably drop the explicit return and used a squiggly heredoc, but that's just personal preference so feel free to ignore.
There was a problem hiding this comment.
Since most of the code was shamelessly copied over from app/models/katello/rpm.rb, I would keep it that way for being consistent.
Eventually, we should think about enforcing a certain style through rubocop. AFAIK Katello's rubocop rules are currently pretty flexible.
1142695 to
3207034
Compare
|
Hi @m-bucher! Is this PR still relevant to Katello 4.17+? We're wondering if you'd like us to close this out. |
|
I was auditing some older PRs, @qcjames53 this appears to still provide value for Katello. We should review it soon. |
| def self.latest(_relation) | ||
| fail 'NotImplemented' | ||
| def self.latest(relation) | ||
| # This might be very slow |
There was a problem hiding this comment.
Some LLM fun to try avoiding the left outer join:
def self.latest(relation)
# Create a CTE to avoid double subquery execution
sql = "WITH base_data AS (#{relation.to_sql})
SELECT bd1.* FROM base_data bd1
WHERE NOT EXISTS (
SELECT 1 FROM base_data bd2
WHERE bd1.name = bd2.name
AND bd1.architecture = bd2.architecture
AND deb_version_cmp(bd1.version, bd2.version) < 0
)"
relation.from("(#{sql}) optimized_latest")
end
This should implement the
packages_restrict_latestparameter, but I am not sure I really want to have this merged, because it does not scale well at all.This originates in the way we compare debian versions and the fact that we have to compare them and are not able to simply sort them.
Maybe some kind of restriction to a max number of packages is in order for this to be usable.