-
Notifications
You must be signed in to change notification settings - Fork 897
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
Power state for services that do not have an associated service_template #13785
Power state for services that do not have an associated service_template #13785
Conversation
@miq-bot assign @gmcculloug @miq-bot add_label services, bz |
@syncrou Cannot apply the following label because they are not recognized: bz |
@miq-bot add_label bug |
f6531c3
to
93ad7a3
Compare
cc - @jntullo |
This looks great, thanks @syncrou 😄 |
app/models/service.rb
Outdated
@@ -211,6 +209,14 @@ def power_states_match?(action) | |||
false | |||
end | |||
|
|||
def composite? | |||
service_template ? service_template.service_type.to_s.include?('composite') : children.present? |
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.
If you have a service_template all you have to do is call the existing method on that class.
service_template ? service_template.composite? : children.present?
(Same for atomic?
below)
@kbrock Is children.present?
going to load all the child objects? Is there a way to check for children in ancestry without the overhead of loading them?
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 like idea from @gmcculloug
You can check if this object has a parent without a query.
But children checks that others are pointing to this object.
so it will always be a query hit.
and this will be an n+1
…_template For the cases in Automate where a service does not have an associated ServiceTemplate 1. If children exist we have a composite service 2. If no children exists we have an atomic service https://bugzilla.redhat.com/show_bug.cgi?id=1419730
93ad7a3
to
be71c6f
Compare
Checked commit syncrou@be71c6f with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
As a side note, this is asking each level if it is |
@kbrock I forgot to mention that this edge-case is when a service is created directly from automate instead of through the normal workflow of ordering a service_template. |
looking good |
Power state for services that do not have an associated service_template (cherry picked from commit 2de4087) https://bugzilla.redhat.com/show_bug.cgi?id=1422650
Euwe backport details:
|
For the cases in Automate where a
Service
does not have an associatedServiceTemplate
https://bugzilla.redhat.com/show_bug.cgi?id=1419730