-
Notifications
You must be signed in to change notification settings - Fork 901
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
Add purge_by_date_and_orphaned #23385
Conversation
Introduce purging first by date and then by orphanes. It is not optimal to take 2 arguments, since most purging has stuck to one But both of these need to be passed in. We could have leveraged these 2 methods separately, but we wanted them to be serialized, and avoid adding a dependency in the queue.
@@ -11,8 +11,7 @@ def purge_mode_and_value | |||
# remove anything where the resource no longer exists AND | |||
# remove anything older than a certain date | |||
def purge_timer | |||
purge_queue(:orphaned, "resource") | |||
purge_queue(:date, purge_date) | |||
purge_queue(:date_and_orphaned, purge_date, "resource") |
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.
Will this work? We're putting both purge_date (used by date) and "resource" (used by orphaned) in the queue args. I see purge_by_date_and_orphaned
having a signature older_than, fk_name, window
, so I think it will work but maybe it's a bit over engineered.
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.
Maybe we should try using miq_callback? I'll try to draft that to see which is more straight forward.
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.
Trying this locally:
diff --git a/app/models/mixins/purging_mixin.rb b/app/models/mixins/purging_mixin.rb
index bdb7910782..bc9aad7f2b 100644
--- a/app/models/mixins/purging_mixin.rb
+++ b/app/models/mixins/purging_mixin.rb
@@ -63,11 +63,12 @@ module PurgingMixin
purge_queue(*purge_mode_and_value)
end
- def purge_queue(mode, value = nil)
+ def purge_queue(mode, value = nil, callback = nil)
MiqQueue.submit_job(
- :class_name => name,
- :method_name => "purge_by_#{mode}",
- :args => [value]
+ :class_name => name,
+ :method_name => "purge_by_#{mode}",
+ :args => [value],
+ :miq_callback => callback.present? ? callback : nil
)
end
diff --git a/app/models/vim_performance_state/purging.rb b/app/models/vim_performance_state/purging.rb
index d3dee077cb..cf6e24d96d 100644
--- a/app/models/vim_performance_state/purging.rb
+++ b/app/models/vim_performance_state/purging.rb
@@ -11,8 +11,12 @@ class VimPerformanceState < ApplicationRecord
# remove anything where the resource no longer exists AND
# remove anything older than a certain date
def purge_timer
- purge_queue(:orphaned, "resource")
- purge_queue(:date, purge_date)
+ callback = {
+ :class_name => name,
+ :method_name => :purge_queue,
+ :args => [:orphaned, "resource"]
+ }
+ purge_queue(:date, purge_date, callback)
end
def purge_window_size
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.
Of course I messed it up in my pseudo code... but I dropped the miq_task and did it through a callback in the original PR: #23383
Backported to
|
Add purge_by_date_and_orphaned (cherry picked from commit 7811720)
Introduce purging first by date and then by orphanes.
It is not optimal to take 2 arguments, since most purging has stuck to one But both of these need to be passed in.
We could have leveraged these 2 methods separately, but we wanted them to be serialized, and avoid adding a dependency in the queue.
Alternative to #23383 and #23381