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

Add provisioned? lifecycle status info to retireable? check #18943

Merged

Conversation

d-m-u
Copy link
Contributor

@d-m-u d-m-u commented Jul 8, 2019

We need to factor in the lifecycle status when we ask a service if it's retireable. Contrary to previous suggestions, it makes no sense to use the supports_feature mixin, because that's a class check and this is specific to the instance. It may as well just be part of this check, as well.

I just wanted to start the conversation and get feedback and buy-in. I'm not taking into account places this is overridden yet cause I wanted opinions first.

start for https://bugzilla.redhat.com/show_bug.cgi?id=1595511

@miq-bot assign @tinaafitz

@d-m-u d-m-u changed the title [WIP] Add provisioned? lifecycle status info to retireable? check [WIP] [POC] Add provisioned? lifecycle status info to retireable? check Jul 8, 2019
@miq-bot
Copy link
Member

miq-bot commented Jul 8, 2019

@d-m-u 'lfu, bdunne, gmcculloug' is an invalid reviewer, ignoring...

@d-m-u
Copy link
Contributor Author

d-m-u commented Jul 8, 2019

@miq-bot add_reviewer @lfu
@miq-bot add_reviewer @bdunne
@miq-bot add_reviewer @gmcculloug

@miq-bot miq-bot added the wip label Jul 8, 2019
@miq-bot miq-bot requested review from lfu, bdunne and gmcculloug July 8, 2019 16:11
@d-m-u
Copy link
Contributor Author

d-m-u commented Jul 8, 2019

@Fryguy, thoughts? Since you are likely to be vociferous about it...

@d-m-u
Copy link
Contributor Author

d-m-u commented Jul 11, 2019

Anyone other than Lucy want to look at this, please?

app/models/service.rb Outdated Show resolved Hide resolved
@d-m-u d-m-u changed the title [WIP] [POC] Add provisioned? lifecycle status info to retireable? check [WIP] Add provisioned? lifecycle status info to retireable? check Jul 11, 2019
@d-m-u d-m-u force-pushed the adding_retireable_check_with_lifecycle_state branch 5 times, most recently from f0a4922 to 6c52708 Compare July 12, 2019 10:40
@@ -156,7 +156,11 @@ def request_type
end

def retireable?
parent.present? ? true : type.present?
if parent.present? && provisioned?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the provisioned? check effect all services? Meaning, if it is not provisioned can we immediately say it cannot be retired?

def retireable?
  false unless provisioned?

  parent.present? ? true : type.present?
end

Otherwise, it seems odd that we jump to using type.present? if parent.present? is true but provisioned? is false.

I guess the other form of this method I might expect is:

  def retireable?
    if parent.present?
      provisioned?
    else
      type.present?
    end
  end

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. So does that mean that you can immediately return false if the service is not provisioned? My first example.

Copy link
Contributor Author

@d-m-u d-m-u Jul 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anything currently provisioned has a lifecycle state that isn't set, so we can't currently use this until a data migration (ManageIQ/manageiq-schema#392) to fix that gets in. I'm not sure if there are other cases than this that were missed, @lfu, thoughts?

Copy link
Contributor Author

@d-m-u d-m-u Jul 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a service is in the middle of retirement and failed, is it still considered provisioned? (Tina said yes.) If someone went in and manually retired a vm from a service, is the service still considered provisioned? (Still yes.) Could you conceivably then have a service with all parts and pieces gone that is still "provisioned"? I think you can, and I understand that, but I don't particularly like it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest that we focus on the normal use-case (provision service, then retire service) first and look into what I would consider edge conditions as a follow up. Seems like it would overcomplicate this PR by trying to handle everything here.

But to add thoughts on the questions above, I would think we could write a method to validate if all the parts of a service are retired. Then this check would need to be run at the end of the retirement of a resource and the service could be processed at that time. Or it could be done as a schedule event, but without digging to deep into it I like the first approach better. I am sure there are more nuances here that would need to be flushed out. Again, this would be a follow up effort.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for creating the data migration @d-m-u. I'm sure we'll encounter other edge conditions, but I can't think of anything else right now. @lfu Do you have any concerns?

The initial use case for the lifecycle state is to prevent retirement from being called/run while the service is being provisioned. I believe the code changes here satisfy that requirement.

@d-m-u d-m-u force-pushed the adding_retireable_check_with_lifecycle_state branch 2 times, most recently from ea3824c to 755e555 Compare July 15, 2019 18:32
@d-m-u d-m-u changed the title [WIP] Add provisioned? lifecycle status info to retireable? check Add provisioned? lifecycle status info to retireable? check Jul 15, 2019
@d-m-u
Copy link
Contributor Author

d-m-u commented Jul 15, 2019

@miq-bot remove_label wip
everyone else, please re-review?

@miq-bot miq-bot removed the wip label Jul 15, 2019
app/models/service.rb Outdated Show resolved Hide resolved
@d-m-u d-m-u force-pushed the adding_retireable_check_with_lifecycle_state branch 2 times, most recently from 664e915 to c5e4460 Compare July 16, 2019 16:42
@d-m-u d-m-u force-pushed the adding_retireable_check_with_lifecycle_state branch from c5e4460 to f377318 Compare July 16, 2019 17:06
@miq-bot
Copy link
Member

miq-bot commented Jul 16, 2019

Checked commit d-m-u@f377318 with ruby 2.4.6, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0
4 files checked, 0 offenses detected
Everything looks fine. 🍰

@bdunne
Copy link
Member

bdunne commented Jul 16, 2019

@tinaafitz Can you take another look?

Copy link
Member

@tinaafitz tinaafitz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bdunne Looks good.

@bdunne
Copy link
Member

bdunne commented Jul 16, 2019

Have the UI tests been run with this change? I suspect they will have tests around this

@d-m-u
Copy link
Contributor Author

d-m-u commented Jul 16, 2019

@bdunne gimme just a minute, please

@d-m-u
Copy link
Contributor Author

d-m-u commented Jul 16, 2019

Of the 11 failures I get, they're all

 8) Mixins::EmsCommon::Angular get_task_args openstack cloud returns connect options for openstack cloud AMQP tab
     Failure/Error: expect(@ems_cloud_controller.send(:get_task_args, 'ManageIQ::Providers::Openstack::CloudManager')).to eq(expected_connect_options)
     
       expected: ["v2:{k8Sm5ygvDAvvY5zkvev1ag==}", {"amqp_api_port"=>"5462", "amqp_hostname"=>"host_amqp", "amqp_security_protocol"=>"non_ssl", "amqp_userid"=>"xyz"}]
            got: ["v2:{6yyYgLW3nPt9T1wkYsOzJQ==}", {"amqp_api_port"=>"5462", "amqp_hostname"=>"host_amqp", "amqp_security_protocol"=>"non_ssl", "amqp_userid"=>"xyz"}]
     
       (compared using ==)
     
       Diff:
       @@ -1,4 +1,4 @@
       -["v2:{k8Sm5ygvDAvvY5zkvev1ag==}",
       +["v2:{6yyYgLW3nPt9T1wkYsOzJQ==}",

and not a one looks related to any of this code change.

@d-m-u
Copy link
Contributor Author

d-m-u commented Jul 16, 2019

I suspect they will have tests around this

I mean no they won't, the UI work for this hasn't been done yet.

@bdunne bdunne merged commit d93213e into ManageIQ:master Jul 16, 2019
@bdunne bdunne assigned bdunne and unassigned tinaafitz Jul 16, 2019
@bdunne bdunne added this to the Sprint 116 Ending Jul 22, 2019 milestone Jul 16, 2019
@d-m-u
Copy link
Contributor Author

d-m-u commented Jul 16, 2019

@miq-bot add_label enhancement
I guess you know it's buggy when it has its own label, looking at you, Services.

@d-m-u d-m-u deleted the adding_retireable_check_with_lifecycle_state branch September 26, 2019 10:36
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