Skip to content
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

Merged

Conversation

syncrou
Copy link
Contributor

@syncrou syncrou commented Feb 6, 2017

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 exist we have an atomic service

https://bugzilla.redhat.com/show_bug.cgi?id=1419730

@syncrou
Copy link
Contributor Author

syncrou commented Feb 6, 2017

@miq-bot assign @gmcculloug

@miq-bot add_label services, bz

@miq-bot
Copy link
Member

miq-bot commented Feb 6, 2017

@syncrou Cannot apply the following label because they are not recognized: bz

@syncrou
Copy link
Contributor Author

syncrou commented Feb 6, 2017

@miq-bot add_label bug

@miq-bot miq-bot added the bug label Feb 6, 2017
@syncrou syncrou force-pushed the service_without_service_template branch from f6531c3 to 93ad7a3 Compare February 6, 2017 22:15
@syncrou
Copy link
Contributor Author

syncrou commented Feb 6, 2017

cc - @jntullo

@jntullo
Copy link

jntullo commented Feb 6, 2017

This looks great, thanks @syncrou 😄

@@ -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?
Copy link
Member

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?

Copy link
Member

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
@syncrou syncrou force-pushed the service_without_service_template branch from 93ad7a3 to be71c6f Compare February 7, 2017 14:22
@miq-bot
Copy link
Member

miq-bot commented Feb 7, 2017

Checked commit syncrou@be71c6f with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
2 files checked, 0 offenses detected
Everything looks good. 🏆

@kbrock
Copy link
Member

kbrock commented Feb 8, 2017

As a side note, this is asking each level if it is composite. So this has the potential to slow things down. but I see no other way.

@gmcculloug
Copy link
Member

@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.

@gmcculloug gmcculloug merged commit 2de4087 into ManageIQ:master Feb 9, 2017
@gmcculloug gmcculloug added this to the Sprint 54 Ending Feb 13, 2017 milestone Feb 9, 2017
@kbrock
Copy link
Member

kbrock commented Feb 9, 2017

looking good

simaishi pushed a commit that referenced this pull request Mar 3, 2017
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
@simaishi
Copy link
Contributor

simaishi commented Mar 3, 2017

Euwe backport details:

$ git log -1
commit f61a7f1c15677afa121a82db4cdbe158304573f5
Author: Greg McCullough <gmccullo@redhat.com>
Date:   Thu Feb 9 11:45:55 2017 -0500

    Merge pull request #13785 from syncrou/service_without_service_template
    
    Power state for services that do not have an associated service_template
    (cherry picked from commit 2de408789d08b5f93421bccbaa1df87078ac2d6f)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1422650

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants