-
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
Support cancellation for miq_request and miq_request_task #17687
Conversation
@miq-bot assign @gmcculloug |
app/models/miq_request.rb
Outdated
@@ -590,6 +590,14 @@ def self.display_name(number = 1) | |||
n_('Request', 'Requests', number) | |||
end | |||
|
|||
def cancel_request | |||
raise raise _("This type of request cannot be canceled.") |
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.
Duplicate raise
keyword
e3af104
to
ada1216
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.
Why wouldn't this be a regular state in the state machine?
app/models/miq_request.rb
Outdated
@@ -590,6 +590,14 @@ def self.display_name(number = 1) | |||
n_('Request', 'Requests', number) | |||
end | |||
|
|||
def cancel_request |
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.
Why not just 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.
I had the same thought. It would be better if we had a name that could be applied consistently across models. Suggest using cancel
which will match the exposed api action.
app/models/miq_request_task.rb
Outdated
@@ -206,6 +206,14 @@ def self.display_name(number = 1) | |||
n_('Request Task', 'Request Tasks', number) | |||
end | |||
|
|||
def cancel_task |
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.
Same here
app/models/miq_request.rb
Outdated
@@ -590,6 +590,14 @@ def self.display_name(number = 1) | |||
n_('Request', 'Requests', number) | |||
end | |||
|
|||
def cancel_request | |||
raise _("This type of request cannot be canceled.") |
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.
Suggested message: "Cancel operation is not supported for #{self.class.name}"
app/models/miq_request.rb
Outdated
@@ -590,6 +590,14 @@ def self.display_name(number = 1) | |||
n_('Request', 'Requests', number) | |||
end | |||
|
|||
def cancel_request |
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 had the same thought. It would be better if we had a name that could be applied consistently across models. Suggest using cancel
which will match the exposed api action.
app/models/miq_request_task.rb
Outdated
@@ -206,6 +206,14 @@ def self.display_name(number = 1) | |||
n_('Request Task', 'Request Tasks', number) | |||
end | |||
|
|||
def cancel_task | |||
raise _("This type of task cannot be canceled") |
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.
Rework message.
@bdunne We will eventually move it to a regular state. This feature is needed by v2v now but we expect much more work to be done in order to introduce a new state. |
ada1216
to
674d86c
Compare
Checked commit bzwei@674d86c with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 |
Would |
I would say There is work being added to do the cleanup (not just kill) the task here: ManageIQ/manageiq-content#357 |
@bdunne can you add API action for cancellation? |
@agrare Would this feature be a candidate for adding a The cancel action will be on all miq_request/miq_request_task objects but only supported/implemented on |
@gmcculloug I think this is fine the way it is for now, if we expose cancel to the UI and it is only supported by some providers then we might think about adding a supports feature for it. |
@miq-bot add_label blocker |
Support cancellation for miq_request and miq_request_task (cherry picked from commit d676ff5) https://bugzilla.redhat.com/show_bug.cgi?id=1610533
Gaprindashvili backport details:
|
There is immediate need from v2v for cancellation at both request and task levels. It is also a long demanded feature.
This PR adds
MiqRequest#cancel_request
andMiqRequestTask#cancel_task
methods for the API controller to call in order to receive a user action to cancel a request or task.Methods
MiqRequest#canceling
andMiqRequestTask#canceling
are for automate to check whether user has requested to cancel. Then automate can attempt to stop its work.These methods are initially not implemented for all types except transformation plan. The implementation for transformation plan is simply to store flag
cancel_requested
inoptions
. This is a temporary solution. Ultimately we want to addcanceling
andcanceled
to allowed states for both request and task.In this temporary solution we do not define how to report the state change or progress of the cancellation. @fdupont-redhat and @vconzola's team can agree on the keys and messages reading from options.
Related Links: ManageIQ/manageiq-v2v#370
https://bugzilla.redhat.com/show_bug.cgi?id=1564257
cc @bdunne @fdupont-redhat @vconzola @priley86