-
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
Enable cancel operation for service template transformation plan request #17825
Conversation
@bzwei @gmcculloug Please review. |
app/models/miq_request.rb
Outdated
false | ||
end | ||
|
||
def do_cancel |
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.
make it a private method
end | ||
|
||
def do_cancel | ||
update_attributes(:request_state => "finished", :status => "Error", :message => "Request is canceled by user.") |
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.
Move the logic to cancel
. Here do_cancel
does nothing.
@hsong-rh Please change the title to wip. |
d3fd4e6
to
9ac1276
Compare
9ac1276
to
4a43e3f
Compare
app/models/miq_request.rb
Outdated
validates_inclusion_of :approval_state, :in => %w(pending_approval approved denied), :message => "should be 'pending_approval', 'approved' or 'denied'" | ||
validates_inclusion_of :status, :in => %w(Ok Warn Error Timeout Denied) | ||
validates_inclusion_of :cancel_state, :in => %w(pending_cancel processing finished), :message => "should be 'pending_cancel', 'processing' or 'finished'" |
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.
for allowed states, how about %w(cancel_requested canceling canceled)
cc @fdupont-redhat @priley86 |
@bzwei How do I update task's Alos, this PR has code only for the model, but not for the service model. I guess there will be another PR for that. |
@fdupont-redhat yes. Another PR for service model is on the way. It will provide methods for automate to change |
@miq-bot add_label blocker |
@hsong-rh if this can be backported, please add the gaprindashvili/yes label. |
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.
Instead of jamming more code into the miq_request.rb and miq_request_task.rb files it would be better to move this logic into new files using include_concern
. There seems to be some potential to use a mixin as well as there are common elements in both.
Still need to review this more and it would be good to get together to discuss the columns involved as well as the state values.
c93e474
to
a30adc5
Compare
@bzwei @agrare @gmcculloug Please review. |
3e4c30e
to
91a7b4b
Compare
@agrare @bzwei @mkanoor @gmcculloug Changed StateMachine into |
:pending => {'pending' => 'pending'}, | ||
:queued => {'pending' => 'queued'}, | ||
:active => {'pending' => 'active', | ||
'active' => 'active', |
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.
@hsong-rh
Is active => active needed?
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.
Yes, one type of automated request needs it.
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.
@hsong-rh do you know which one of the automate request. Also if the next_state == current_state meaning active == active can't we just skip that state change
91a7b4b
to
d5c547b
Compare
@bzwei @mkanoor @agrare @gmcculloug Changed to focus on request cancellation for V2V. Refactor for state machine mixin will be in separate PR. Please review. |
d5c547b
to
d00da09
Compare
d00da09
to
1eadfcc
Compare
65f62fd
to
3452fe1
Compare
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.
A few minor suggestions around the spec, but otherwise this looks good.
@@ -38,4 +38,24 @@ | |||
expect(ServiceResource.find_by(:resource => vms[0]).status).to eq(ServiceResource::STATUS_APPROVED) | |||
end | |||
end | |||
|
|||
context "gets cancel request" 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.
Suggest "when request gets canceled"
Also, you can move the call to cancel
into a before
block: before { request.cancel }
@@ -38,4 +38,24 @@ | |||
expect(ServiceResource.find_by(:resource => vms[0]).status).to eq(ServiceResource::STATUS_APPROVED) | |||
end | |||
end | |||
|
|||
context "gets cancel request" do | |||
it "gets cancel_requested request" 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.
"cancelation status is set to requested"
expect(request.canceled?).to be_falsey | ||
end | ||
|
||
it "calls do_cancel" 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.
"marks request as finished in error"
3452fe1
to
2db1d05
Compare
2db1d05
to
5f10870
Compare
Checked commit hsong-rh@5f10870 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 |
@fdupont-redhat @priley86 Though this PR is related to https://bugzilla.redhat.com/show_bug.cgi?id=1614864, it will not back ported because it relies on schema migration. To summarize the changes
With this PR being merged the V2V cancellation will not work properly until automate and UI make the above modifications. |
This PR enable cancellation for V2V request by using the new introduced
cancelation_status
column inmiq_requests
table.cancelation_status
has three valid values:cancel_requested
,canceling
andcanceled
. After UI getscancel
request, it will mark tocancel_requested
. Following checking will change it tocanceling
,canceled
, based on subtasks' states.https://bugzilla.redhat.com/show_bug.cgi?id=1614864