-
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
Fix ServiceTemplateTransformationPlan edit action #17989
Fix ServiceTemplateTransformationPlan edit action #17989
Conversation
@@ -0,0 +1,51 @@ | |||
module ServiceTemplateTransformationPlan::ValidateConfigInfo | |||
def self.included(base) |
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 use ActiveSupport::Concern
.
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.
Added that. Thanks.
1612d90
to
f9e5eaf
Compare
@lfu In the last commit, I have handled a use case where
This use case covers editing plans that are completed or archived. |
9607c23
to
1f0f425
Compare
@mturley Thank you for your testing so far! |
1f0f425
to
caaf4dc
Compare
@lfu @bzwei sorry to bother you guys, but is there anything we can do to move this along? it's blocking ManageIQ/manageiq-v2v#620 and we have a code freeze on Monday. |
@lfu had a suggestion that for updating a plan which has not been executed yet, could we just delete the old resources, then add the new resource and update the config info -- which is a great suggestion and in fact what I initially intended to do. Anyway I tried this, which seems to work - def update_catalog_item(options, auth_user = nil)
if miq_requests.any? || options[:config_info].nil?
options[:config_info] = self.options[:config_info]
end
added_vms_enhanced_config_info = validate_config_info(options)
transaction do
update_from_options(options)
vm_resources.destroy_all
reload.tap do |service_template|
service_template.add_resource(added_vms_enhanced_config_info[:transformation_mapping])
added_vms_enhanced_config_info[:vms].each { |vm_hash| service_template.add_resource(vm_hash[:vm], :status => ServiceResource::STATUS_QUEUED, :options => vm_hash[:options]) }
service_template.create_resource_actions(added_vms_enhanced_config_info)
end
end
end @lfu What do you think of the above method? |
What's this for? Is this checking necessary? I thought
Do we need
Need to remove the old transformation_mapping resource first.
Should this be |
caaf4dc
to
cb85190
Compare
I have updated with a working version of what we discussed outside of the PR. Once we finalize on the code, I can squash some of the related commits. |
cb85190
to
e245d0c
Compare
pre_service_id = config_info[:pre_service].try(:id) || config_info[:pre_service_id] | ||
post_service_id = config_info[:post_service].try(:id) || config_info[:post_service_id] | ||
def update_catalog_item(options, _auth_user = nil) | ||
if miq_requests.any? || options[:config_info].nil? |
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.
if miq_requests
exists, do you allow an update?
If requests have been made and there were failed VMs, then user may want a retry. Before a retry they may want to update the VM list. Therefore it seems update should be allowed. But what about request is on-going? I think it is a question to PM.
Anyway, if it is not allowed, you should raise an error here. If allowed, you should use new options
, not the existing one.
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.
Currently we are allowing Edits that includes Name/Description and VMs on only those plans that haven't been executed yet.
We won't be allowing editing the associated infrastructure mapping.
Edits won't be allowed for plans in-progress.
As far as failed and completed plans go, we would be supporting only partial edits that will let the user edit attributes like Name/Description
@mturley can you corroborate that?
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.
If you only allow name/description changes for certain cases, you should not continue to update other fields by deleting vms and add them back. It will have unexpected result if there is a request running, or even the plan has completed or failed.
You said "Edits won't be allowed for plans in-progress", but I don't see it is reflected in the code. Maybe on UI it is not allowed, but it should be forbidden in backend also.
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.
@AparnaKarve is correct, for failed and completed plans, the UI as designed only supports editing the name and description.
I do want to point out that although we currently don't allow editing the associated infrastructure mapping, that is mostly a UI restriction (it complicates the state of the wizard), and @vconzola mentioned we might want to allow that in the future (which basically would mean replacing an entire plan).
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.
@bzwei Addressed some of your above concerns in the last update (last commit)
Can you verify?
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.
To confirm when things can and cannot be edited, see this table: https://docs.google.com/document/d/1B-iFdNKqUgw44GPHc0TIUEDc9MdKiBll2pK6PTve__M/edit
vm_resources.destroy_all | ||
reload.tap do |service_template| | ||
added_vms_enhanced_config_info[:vms].each { |vm_hash| service_template.add_resource(vm_hash[:vm], :status => ServiceResource::STATUS_QUEUED, :options => vm_hash[:options]) } | ||
service_template.create_resource_actions(added_vms_enhanced_config_info) |
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 create_resource_actions
every time? If yes, shouldn't you delete them first?
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 we have a method for deleting resource actions? If yes, then I think we should call it here.
Although note that we only want to delete the vm resources and rebuild them.
As mentioned above #17989 (comment), we don't want to update (and hence delete) the associated infrastructure mapping.
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 do need create_resource_actions
every time, otherwise the ServiceResource
records associated with the plan are not created.
Keeping the ServiceResource
records up-to-date is critical for accurate VM discovery.
From what I have observed so far it looks like the ServiceResource
records that were previously associated with a plan are auto-destroyed when a call to create_resource_actions
is made -- so we do not need an explicit delete in this case.
e245d0c
to
d3dbdfb
Compare
d3dbdfb
to
2a685fe
Compare
@lfu Please review the latest update. If all looks good, I would like to squash all the commits related to |
raise _('Must provide an existing transformation mapping') if mapping.blank? | ||
|
||
pre_service_id = config_info[:pre_service].try(:id) || config_info[:pre_service_id] | ||
post_service_id = config_info[:post_service].try(:id) || config_info[:post_service_id] |
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 believe that @michaelkro might be including other details in the config_info
including the OSP security group and the OSP flavor.
Though it might need to be in the actions
section below. Be sure to follow up and see where that needs to be added.
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.
Good point.
This code is a direct transplant from service_template_transformation_plan.rb
-- so there were no changes made to the existing behavior as such. Although adding any OSP specific info in this PR itself may not be a bad idea.
@bzwei Let me know if any OSP specific info needs to be added in actions
?
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.
Currently we have an outstanding UI PR - ManageIQ/manageiq-v2v#658 where we are adding osp_security_group
and osp_flavor
to actions
as part of the POST body for service_templates
@bzwei Is there anything that needs to be done here with regard to the 2 new additions - osp_security_group
and osp_flavor
?
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.
osp_
options do not impact actions
, so no need to update actions
They will need to be updated in service_resource
per vm. I would recommend another PR for both add/update such options.
@bzwei are you 👍 on this? Or, just don't have time to review? I just want to be sure where it currently stands. |
@@ -65,46 +66,23 @@ def self.create_catalog_item(options, _auth_user = nil) | |||
end | |||
end | |||
|
|||
private | |||
def update_catalog_item(options, _auth_user = nil) | |||
raise _("Editing a plan in progress is prohibited") if %w(active pending).include?(miq_requests.last.try(:request_state)) |
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.
Without proper sorting miq_requests.last
does not guarantee to be the latest 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.
Addressed this in the last update
:provision => config_info[:provision] || {} | ||
} | ||
transaction do | ||
vm_resources.destroy_all |
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.
Are we allowed to change the selection of infrastructure mapping? why not?
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.
We don't allow editing the associated infrastructure mapping.
I think the rationale here is that if one needs to change the infrastructure mapping for a plan, then creating a brand new plan with the desired infra mapping is a better approach.
Plus it's easier to deal with a static infrastructure mapping in the Wizard... as @mturley mentioned above #17989 (comment), it complicates the state of the wizard.
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.
UI may forbid updating the infrastructure mapping, but what about API or a direct call for update that includes a changed mapping? We should either log a warning or raise an error if such change is detected.
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 re-read #17989 (comment), and I think that we should consider supporting the infrastructure mapping update purely from a backend standpoint (API or a direct call, like you said)
UI may forbid updating it today, but that restriction may not apply in the future (based on the comment)
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.
added support for updating associated transformation mapping
2a685fe
to
f1429c3
Compare
@miq_bot add_label hammer/yes |
`validate_config_info` needs to be a Class method for Create and Instance method for Update
db80951
to
711d199
Compare
and edit transformation mapping
711d199
to
8a8bd75
Compare
Checked commits AparnaKarve/manageiq@c132327~...8a8bd75 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 |
In the latest update here, I have consolidated (squashed) some of the related commits. @bzwei @lfu Thank you for the review. @gmcculloug / @blomquisg This should be good to go |
@miq-bot add_label hammer/yes |
@roliveri We have some frontend work depending on this PR. |
…formation_plan_edit Fix ServiceTemplateTransformationPlan edit action (cherry picked from commit e89f4a1)
Hammer backport details:
|
While adding a new v2v UI feature for editing a Migration Plan (
ServiceTemplateTransformationPlan
) in ManageIQ/manageiq-v2v#620, we noticed a couple of issues related to VM discovery, such as -Above issues have been fixed in this PR