-
Notifications
You must be signed in to change notification settings - Fork 898
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
Adjust power states on a service to handle children #14550
Adjust power states on a service to handle children #14550
Conversation
@miq-bot assign @gmcculloug @miq-bot add_label bug, services |
610f3e4
to
7745b88
Compare
app/models/service.rb
Outdated
children.present? | ||
end | ||
|
||
def empty_child_resources? |
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.
Discussed with @syncrou and was originally thinking these methods could be remove, but are leaning toward replacing them with atomic?
and composite?
methods to match the terminology used for service_templates.
The difference with services is they can change between atomic and composite after they are created through automate or API calls. Therefore we need methods to determine what their current configuration is.
a17b1a6
to
6e8febd
Compare
app/models/service.rb
Outdated
elsif atomic? && (power_states[0] == POWER_STATE_MAP[action]) | ||
return update_power_status(action) | ||
end | ||
return update_power_status(action) if all_states_match?(action) |
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.
Could simplify to: all_states_match?(action) ? update_power_status(action) : false
app/models/service.rb
Outdated
each_group_resource do |svc_rsc| | ||
sa << svc_rsc | ||
end | ||
end.map(&action_name.to_sym).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.
Maybe set action_name
to a symbol when setting the variable action_name = "#{action}_action".to_sym
instead of during each call. Also, you end up calling compact
on service_actions
below, should that happen here?
I am feeling like this block should be broken out into a separate method.
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.
@gmcculloug - Are you thinking lines 208 - 211 should be broken out into their own method?
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.
Lines 208 - 212 could be a method that returns service_actions
.
1. Iterate through the children if there are no service_resources on the parent 2. Iterate through the children for power states to adjust the power state and status for the entire service https://bugzilla.redhat.com/show_bug.cgi?id=1416903
6e8febd
to
f2a06a8
Compare
Checked commits syncrou/manageiq@ec58361~...f2a06a8 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
For an atomic service with children.
service_resources
on the parentpower_states
to adjust the power state and status forthe entire service
https://bugzilla.redhat.com/show_bug.cgi?id=1416903