-
Notifications
You must be signed in to change notification settings - Fork 303
Fixes #33525 - Add debs packages_restrict_latest #9671
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
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack from the logic point of view
| return relation.joins( | ||
| "LEFT OUTER JOIN(#{relation.to_sql}) AS katello_debs2 ON " \ | ||
| 'katello_debs.name = katello_debs2.name AND katello_debs.architecture = katello_debs2.architecture AND ' \ | ||
| 'deb_version_cmp(katello_debs.version, katello_debs2.version) < 0 ' \ | ||
| ).where('katello_debs2.id IS NULL') |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.