-
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
Update a service's lifecycle_state. #18803
Conversation
Are you going to |
The renamed column was recently added in ManageIQ/manageiq-schema#356. |
app/models/mixins/lifecycle_mixin.rb
Outdated
end | ||
|
||
def provisioned? | ||
lifecycle_state == 'provisioned' |
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.
@lfu Would it make sense to have the states as constants and freeze them? (provisioning, provisioned, error_provisioned)
@@ -88,6 +89,7 @@ class Service < ApplicationRecord | |||
default_value_for :display, false | |||
default_value_for :retired, false | |||
default_value_for :initiator, 'user' | |||
default_value_for :lifecycle_state, 'unprovisioned' |
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.
expect(@service.lifecycle_state).to eq('provisioned') | ||
end | ||
|
||
it 'set servcie lifecycle_state to error_provisioned' do |
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.
@lfu same here.
app/models/mixins/lifecycle_mixin.rb
Outdated
def update_lifecycle_state | ||
case miq_request.request_state | ||
when "finished" | ||
lifecycle_state = miq_request.status == 'Ok' ? "provisioned" : "error_provisioned" |
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.
@lfu should error_provisioned be error_in_provisioning? or can it be just error
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 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 will take error_in_provisioning
to support retirement in the future.
expect(@service.lifecycle_state).to eq('provisioning') | ||
end | ||
|
||
it 'set servcie lifecycle_state to provisioned' do |
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.
@lfu Can you fix the typo for "set servcie"
7ea19a1
to
f7cf34e
Compare
@lfu Dependent schema PR is merged. |
f7cf34e
to
e53acfc
Compare
@task_0.destination = @service | ||
@request.miq_request_tasks.except(@task_0).each { |t| t.update(:state => "finished") } | ||
@task_0.update_and_notify_parent(:state => "finished", :status => "Ok", :message => "Test Message") | ||
expect(@service.lifecycle_state).to eq(Service::STATE_PROVISIONED) |
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.
@lfu should this just use the helper method provisioned? ?
@task_0.destination = @service | ||
@request.miq_request_tasks.except(@task_0).each { |t| t.update(:state => "finished") } | ||
@task_0.update_and_notify_parent(:state => "finished", :status => "Error", :message => "Test Message") | ||
expect(@service.lifecycle_state).to eq(Service::STATE_ERROR_PROVISIONING) |
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.
@lfu this could use the provision_failed? method
e53acfc
to
747f636
Compare
@@ -258,6 +258,30 @@ def service_resource_id(index, scaling_max) | |||
@task_1_2.destination = @service | |||
@task_1_2.update_and_notify_parent(:state => "finished", :status => "Ok", :message => "Test Message") | |||
end | |||
|
|||
it 'set service lifecycle_state to provisioning' do | |||
zone = FactoryBot.create(:zone, :name => "service_template_zone") |
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.
Please don't set zone name, it is sequenced by the factory
|
||
it 'set service lifecycle_state to provisioning' do | ||
zone = FactoryBot.create(:zone, :name => "service_template_zone") | ||
@task_3.source = FactoryBot.create(:service_template, :zone => zone) |
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.
Do you need to set zone here?
747f636
to
da1c436
Compare
Checked commit lfu@da1c436 with ruby 2.3.3, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0 |
Add lifecycle_state column to services to record a service's provision state. May be extended to the full lifecycle which contains provision, reconfigure and retirement.
Depends on ManageIQ/manageiq-schema#374.
https://bugzilla.redhat.com/show_bug.cgi?id=1677571
@miq-bot assign @tinaafitz
@miq-bot add_label enhancement, changelog/yes, services