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

[V2V] Set context data for the task associated with conversion host creation #18541

Merged
merged 4 commits into from
Mar 29, 2019
Merged

[V2V] Set context data for the task associated with conversion host creation #18541

merged 4 commits into from
Mar 29, 2019

Conversation

djberg96
Copy link
Contributor

@djberg96 djberg96 commented Mar 11, 2019

This PR modifies the ConversionHost::Configurations#enable_queue method so that the original params are stored in the context_data of the associated task. This is a serialized field, so it would be accessible as a hash of options.

A few things to head off potential questions about why this PR is written the way it is:

Q: What is this going to be used for?
A: The UI team would like it for a "retry" option. To do that they need the original parameters, which they can retrieve from the associated task.

Q: Why not just add context_data to the task_opts hash above?
A: Because MiqTask.generic_action_with_callback only recognizes certain options. The rest are dropped.

Q: Why use MiqTask.find on a task that you just created?
A: Because MiqTask.generic_action_with_callback returns a task_id instead of the full task object.

Q: Where are task_id and miq_task_id coming from, and why explicitly .except them?
A: They're injected at some point in the queue lifecycle, so I have to manually reject them because they aren't actually part of the params. The specs revealed that. Without that, the specs will fail.

https://bugzilla.redhat.com/show_bug.cgi?id=1622728
https://bugzilla.redhat.com/show_bug.cgi?id=1695886

@djberg96
Copy link
Contributor Author

@fdupont-redhat @mturley Please review.

@mturley
Copy link
Contributor

mturley commented Mar 11, 2019

So this will store all the params of the original request in context_data? Since we're going to be passing SSH private keys in that request, my concern is that we'll be exposing those to the public here. Maybe we need some way of optionally referencing the stored keys in the enable request as an alternative to passing them in explicitly, and some identifiers for the keys can be stored here?

Sorry if I'm misunderstanding.

@mturley
Copy link
Contributor

mturley commented Mar 11, 2019

If we need to break the SSH keys into a separate request that we do before the enable request, that would be fine. Not sure if that makes this easier.

@djberg96
Copy link
Contributor Author

Ah, true, forgot about private ssh keys. I don't know if we want to make that a separate request, though. I guess I would need some idea of the behavior of a retry option where the user had supplied a key. I can always just filter it out, too.

@ghost
Copy link

ghost commented Mar 11, 2019

Wouldn't that be more practical to create the conversion host before queuing the enablement task ? That would give the conversion host id pretty early, while being quite fast. Upon creation, it would create the Authentication from the SSH key, so we could discard it from the params hash. Then the queue_configuration could update the created task with the params hash and the conversion host id in the task context_data. That would also allow the UI to simply call /api/conversion_hosts to list all the conversion hosts...

@mturley, about filtering out SSH keys, would it be possible to ask the user to provide the VMware hypervisors SSH key when retrying ? That would prevent storing the private key in clear text.

@mturley
Copy link
Contributor

mturley commented Mar 11, 2019

@fdupont-redhat we could pop a modal when you click Retry asking for the key again, sure. @vconzola what do you think about that from a UX perspective?

Wouldn't it also need to ask them for the Conversion Host SSH key again? (and only ask about the VMware hypervisors key if they selected SSH for a transformation method?)

@vconzola
Copy link

@mturley I'm ok with your suggestion of asking the user to re-enter the SSH key information again on Retry. Not ideal from a UX perspective, but reasonable since we don't want to store the key. We should add some explanatory text to the modal explaining why we're asking the user to enter it again. "Because we care about you,..." :-)

@mturley
Copy link
Contributor

mturley commented Mar 11, 2019

Added a comment describing the prompt for re-entering SSH keys in ManageIQ/manageiq-v2v#901. @djberg96 that works for us if you just want to filter those keys out of the params here. I think they'll be ssh_key and vmware_ssh_private_key now, according to @fdupont-redhat 's last email.

@djberg96
Copy link
Contributor Author

I'll just filter out anything with _key in it. :)

@djberg96
Copy link
Contributor Author

@mturley Updated.

@djberg96
Copy link
Contributor Author

@fdupont-redhat If I had seen what a problem this coupling would have been I would have pushed back harder in my original PR for the rest API. I think that ship has sailed, so I'm going to look for other ways.

@agrare agrare self-assigned this Mar 13, 2019
@djberg96
Copy link
Contributor Author

@miq-bot add_label transformation, enhancement, hammer/yes

@mturley
Copy link
Contributor

mturley commented Mar 14, 2019

@djberg96 I just wanted to reference my other comment here: #18540 (comment)

If in that other PR there's no good way to use instance_id, maybe we need to use context_data for both the request params and the conversion host id, which would affect this PR.

@djberg96
Copy link
Contributor Author

@mturley Ok, I'll modify this one to include the conversion host id as part of the context data.

@mturley
Copy link
Contributor

mturley commented Mar 18, 2019

This should be listed in https://bugzilla.redhat.com/show_bug.cgi?id=1622728 I think

@mturley
Copy link
Contributor

mturley commented Mar 18, 2019

@djberg96 are you expecting to add conversion_host_id as a property alongside the request params in context_data, keeping it flat? or are we adding a nested object inside context_data for the request params? Either way is fine, just preparing a PR for the Retry button that will consume this.

@djberg96
Copy link
Contributor Author

@mturley Was going to make the params a nested property, e.g. {:conversion_host_id => 1, :request_params => { .... }.

@@ -24,7 +25,21 @@ def queue_configuration(op, instance_id, resource, params, auth_user = nil)
:zone => resource.ext_management_system.my_zone,
:args => params
}
MiqTask.generic_action_with_callback(task_opts, queue_opts)

task_id = MiqTask.generic_action_with_callback(task_opts, queue_opts)
Copy link
Member

Choose a reason for hiding this comment

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

@djberg96 how about adding :context_data to the options hash and pass it to the MiqTask.create! here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought about making modifications there - I think that method could use some refactoring in general - but was worried about introducing some sort of unexpected regression. I'd like to do that in a separate PR if you don't mind. If/when that happens, we can return to this and refactor 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'd rather fix it first even if it is in a separate PR, a quick search of the callers should be enough to see if anyone is doing anything strange like passing in invalid keys.

I'd expect to be able to control any of the task attributes in the first argument, so something like:

Task.create!(
  {
      :state   => STATE_QUEUED,
      :status  => STATUS_OK,
      :message => msg
  }.merge(options)
)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I actually had this already started, so I've created a WIP here: #18578

Copy link
Member

Choose a reason for hiding this comment

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

Awesome!

@miq-bot
Copy link
Member

miq-bot commented Mar 26, 2019

This pull request is not mergeable. Please rebase and repush.

@mturley
Copy link
Contributor

mturley commented Mar 26, 2019

I think this is now the only PR we're waiting for to enable the Conversion Hosts settings UI 🎉

@djberg96
Copy link
Contributor Author

I'll be focused on this one tomorrow. :)

@miq-bot
Copy link
Member

miq-bot commented Mar 27, 2019

Checked commits https://github.com/djberg96/manageiq/compare/54746a1c10e85f716b34e5ee449c5d421607d224~...af2795546536fefff0e6178cb9bea3a23c78ac5f with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
2 files checked, 0 offenses detected
Everything looks fine. ⭐

# any ssh key information. Useful for a retry option in the UI, and
# informational purposes in general.
#
MiqTask.find(task_id).tap do |task|
Copy link
Member

Choose a reason for hiding this comment

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

@djberg96 so you want to use the old method so this can be backported then followup with a refactoring PR to just pass in the context_data?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's the plan, yes.

@agrare agrare merged commit af27955 into ManageIQ:master Mar 29, 2019
agrare added a commit that referenced this pull request Mar 29, 2019
…data

[V2V] Set context data for the task associated with conversion host creation
@agrare agrare added this to the Sprint 108 Ending Apr 1, 2019 milestone Mar 29, 2019
@ghost
Copy link

ghost commented Apr 3, 2019

simaishi pushed a commit that referenced this pull request Apr 25, 2019
…data

[V2V] Set context data for the task associated with conversion host creation

(cherry picked from commit 65617fa)

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1702278
@simaishi
Copy link
Contributor

Hammer backport details:

$ git log -1
commit 7ee3e9b4a47192a0e7f452da0900b470e6b6d03f
Author: Adam Grare <agrare@redhat.com>
Date:   Fri Mar 29 07:42:23 2019 -0400

    Merge pull request #18541 from djberg96/conversion_host_task_context_data
    
    [V2V] Set context data for the task associated with conversion host creation
    
    (cherry picked from commit 65617fa67713a3e640fb8029685c41c27550a75d)
    
    Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1702278

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