-
Notifications
You must be signed in to change notification settings - Fork 896
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
Suspend providers #17452
Suspend providers #17452
Conversation
app/models/miq_queue.rb
Outdated
@@ -206,6 +209,20 @@ def self.submit_job(options) | |||
put(options) | |||
end | |||
|
|||
# TODO: Array param not seen yet |
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.
@agrare this can be list of any <models_class, id>, right? I wonder if we need to check enabled for each. There might be a better place for it (where the array resources are loaded from the DB)
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.
app/models/miq_queue.rb
Outdated
if resource.respond_to?(:ext_management_system) | ||
ems = resource.ext_management_system | ||
if ems.present? && !ems.enabled | ||
_log.info("Provider is disabled: #{ems.name}. MiqQueue skipped.") |
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.
we should probably log the options too? And we can probably make it log.debug
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.
There is already a method for logging all the queue options properly, so use that one.
app/models/ext_management_system.rb
Outdated
@@ -177,6 +177,15 @@ def hostname_format_valid? | |||
|
|||
default_value_for :enabled, true | |||
|
|||
def self.enable(ems_id) | |||
ExtManagementSystem.where('id = ? OR parent_ems_id = ?', ems_id, ems_id).update_all(enabled: true) |
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.
Prefer where(:id => ems_id).or.where(:parent_ems_id => ems_id)
Also, you can leave out the model name just start the line with where(:id => ...
@jrafanie Please review. Personally, I'm reacting negatively to modifying any of the queueing code for when a worker is disabled. It feels like the wrong place. I understand how you are trying to avoid filling up the queue when a worker is disabled, but it feels like a sledgehammer approach because there may be things that do have to get to the queue. However, I'm not sure how to solve it directly, otherwise I'd offer an suggestion. :) |
@Fryguy This is the reason when I make PR in too incomplete state, because I feel it could have side effects. So I'll try to find better places. |
@Fryguy so question is, what things do have to get to the queue? :-) I am thinking e.g. retirement? Is that queued by scheduler? Then it has to be somehow postponed, until the provider is started again. Then e.g. metrics collection should be just cancelled (both collection and processing). If this will not be solved in a generic place, we will need to get a list of tasks we should not queue/cancel/postpone. And this should be probably documented, because there are side effects. (e.g. retirement can be postponed -> cost will be bigger than expected, metrics collection might have a data gap -> charge-back and reports will not be accurate, etc.) |
app/models/miq_queue.rb
Outdated
@@ -173,6 +173,9 @@ def self.put(options) | |||
def self.submit_job(options) | |||
service = options.delete(:service) || "generic" | |||
resource = options.delete(:affinity) | |||
|
|||
return unless resource_enabled?(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.
I'm confused, what about places that do MiqQueue.put
or other callers of .put
? Why is submit_job
singled out here? I'd think we'd need it everywhere we put something on the queue.
a79c79a
to
0d74660
Compare
410add9
to
67120c5
Compare
Please review. |
app/models/ext_management_system.rb
Outdated
# - these workers are not provider specific, but provider-type specific | ||
# @param value [Boolean] | ||
def change_enabled_with_children!(value) | ||
self.enabled = value |
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 wonder if this is better to handle as an after hook such that after enabled= is modified, then we push down to the children. That way the caller just calls enabled=
, then .save!
def enable! | ||
_log.info("Enabling EMS [#{name}] id [#{id}].") | ||
update!(:enabled => true) | ||
end |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
8a0ce76
to
0470a36
Compare
Have we tested other repos (UI & API repos in particular) with these changes? I wouldn't be surprised if this breaks some tests. |
in every spec doesn't make any sense. We should have This PR needs to get backported, so it would be best not to change every repo out there. (and AFAIK, we're not backporting cleanups) |
5f87dbc
to
36fe84d
Compare
tested on 14 repos, number of failures decreased to 3, which are solved by ManageIQ/manageiq-providers-ovirt#311 (has to be merged first) |
This pull request is not mergeable. Please rebase and repush. |
Enables/Disables ems with children and puts to maintenance zone https://bugzilla.redhat.com/show_bug.cgi?id=1455145
Name as constant
EMS cannot set invisible zone when enabled and change when disabled, MiqServer cannot set invisible zone
It only changes enabled flag.
maintenance zone identified by region and EMS.backup_zone renamed BZ https://bugzilla.redhat.com/show_bug.cgi?id=1455145
Spec and fix for nil zone BZ https://bugzilla.redhat.com/show_bug.cgi?id=1455145
MaintenanceZone uses SecureRandom, Zone.first changed to Zone.default_zone
validation replaces Zone.visible based validations
Avoiding hundreds of errors in dependent repos' specs
36fe84d
to
1bd6e0e
Compare
Checked commits slemrmartin/manageiq@352ddb4~...1bd6e0e with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 app/models/zone.rb
spec/models/miq_queue_spec.rb
|
Adds ability to suspend provider due to maintenance
Fixes BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1455145
Issue: #17489
depends on: Maintenance zone support for suspending provider manageiq-schema#275
dependent: Allow the suspension of cloud, infra and physical infra providers manageiq-ui-classic#4269
dependent: Use the new universal methods for suspending/resuming a provider manageiq-api#434
depends on: EMS validation with maintenance zone specs fix manageiq-providers-ovirt#311
It moves EMS and child managers to Maintenance zone, also sets EMS.enabled to false, which causes stopping provider-specific workers
Cc @Ladas, @agrare, @jerryk55, @romanblanco