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 - State machines - Initial work #248

Merged

Conversation

ghost
Copy link

@ghost ghost commented Feb 8, 2018

This is the initial work to integrate the state machines and methods required to transform virtual machines.
There are three main areas:

  • Transformation Host:
    • Enable/disable role (provision host)
    • Methods to assign and track transformation hosts in tasks
  • Transformation Request:
    • Approve the request, i.e. select the VM to be transformed and create tasks
    • Schedule tasks based on dependencies, capacity, throttling rules...
  • Transformation Task:
    • Execute the transformation
    • Track completion and provide machine readable progress for UI

@ghost
Copy link
Author

ghost commented Feb 8, 2018

@miq-bot add_label v2v

@miq-bot
Copy link
Member

miq-bot commented Feb 8, 2018

@fdupont-redhat Cannot apply the following label because they are not recognized: v2v

@miq-bot miq-bot added the wip label Feb 8, 2018
@gmcculloug
Copy link
Member

@bzwei Please review

scope: instance
language: ruby
location: inline
options: {}
Copy link
Contributor

Choose a reason for hiding this comment

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

@fdupont-redhat Is this missing the embedded methods data since your method is using the embedded methods

Copy link
Author

Choose a reason for hiding this comment

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

Where do you see it using an embedded method ? That one doesn't. Anyway, I see I forgot to rename the module from ConversionHost to TransformationHost.

Copy link
Contributor

Choose a reason for hiding this comment

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

@fdupont-redhat in your earlier ruby code you had

if @debug
      ManageIQ::Automate::System::CommonMethods::MIQ_AE::Debug.new.dump_object
      ManageIQ::Automate::System::CommonMethods::MIQ_AE::Debug.new.dump_root
end

which would have needed the embedded methods, now that you have removed it, its not relevant.

scope: instance
language: ruby
location: inline
options: {}
Copy link
Contributor

Choose a reason for hiding this comment

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

@fdupont-redhat This might also be missing the embedded_methods names.

end

def get_runners_count_by_host(host)
return @handle.vmdb(:vm).all.select { |v| v.custom_get('Transformation Host') == host.name }.size
Copy link
Contributor

Choose a reason for hiding this comment

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

@fdupont-redhat dont need the return here

Copy link
Contributor

Choose a reason for hiding this comment

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

@fdupont-redhat This can be an expensive call fetching all the vms and then fetching/comparing host name.
Its good in the sense that it doesn't require locking the host record to add/remove vms being transformed

Copy link
Author

Choose a reason for hiding this comment

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

If you have a less expensive approach, I take.

Copy link
Member

Choose a reason for hiding this comment

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

@fdupont-redhat You could lookup the CustomAttribute records that has the matching name and value properties and get the count from there. If needed you can limit the result set to just VMs by only returning ones with resource_type => VmOrTemplate.

Maybe @handle.vmdb(:custom_attribute).where(:name => 'Transformation Host', :value => host.name).size

@gmcculloug
Copy link
Member

@fdupont-redhat It would be good if you could run through the rubocop warning/errors and address those as a first pass.

return @handle.vmdb(:vm).all.select { |v| v.custom_get('Transformation Host') == host.name }.size
end

def get_runners_count_by_ems(ems)
Copy link
Contributor

Choose a reason for hiding this comment

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

@fdupont-redhat

def get_runners_count_by_ems
  get_transformation_hosts.inject(0){|sum,host| sum + get_runners_count_by_host(host) }
end

@handle.log(:info, "No transformation host found.")
else
@handle.log(:info, "Least busy transformation host: #{transformation_host}")
vm.custom_set('Transformation Host', transformation_host.guid)
Copy link
Contributor

Choose a reason for hiding this comment

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

@fdupont-redhat are transformation_host.guid and transformation_host.name the same, since in line # 19 you are using name.

Copy link
Author

Choose a reason for hiding this comment

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

It will be changed, as the transformation host will be part of the options hash of the transformation task, rather that the VM.

end

def unset_transformation_host(vm)
vm.custom_set('Transformation Host', nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

@fdupont-redhat can the custom attribute be deleted instead of being set to nil. Will the nil logic be used elsewhere to compare completed transformations.

Copy link
Member

Choose a reason for hiding this comment

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

This is how you do it. There are only three methods exposed custom_keys, custom_get and custom_set.

See /app/models/mixins/custom_attribute_mixin.rb#L82

Copy link
Author

Choose a reason for hiding this comment

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

It will be changed, as the transformation host will be part of the options hash of the transformation task, rather that the VM.

max_runners = factory_config['transformation_host_max_runners'] if max_runners.blank?
next if runners_count == max_runners
( transformation_host = host ; break ) if runners_count == 0
if transformation_host.nil? || runners_count < min_runners
Copy link
Contributor

Choose a reason for hiding this comment

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

@fdupont-redhat How is the min_runners being set, it starts out as nil and only gets set inside of the if block to the runner count. The || logic seems odd.

fields:
- State1:
value: "/Transformation/TransformationHost/${#transformation_host_type}/RoleCheck"
on_error: "/Transformation/TransformationHost/${#transformation_host_type}/MarkAsDisabled"
Copy link
Contributor

Choose a reason for hiding this comment

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

@fdupont-redhat
We dont support paths in on_error/on_exit/on_entry slots?

Copy link
Author

Choose a reason for hiding this comment

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

Well, a typo while copying. It should be /Transformation/TransformationHost/${#transformation_host_type}.MarkAsDisabled.

datatype: string
priority: 0
owner:
default_value: bastion.v2v.example.com
Copy link
Contributor

Choose a reason for hiding this comment

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

@fdupont-redhat the default value should be empty

datatype: string
priority: 1
owner:
default_value: http://bastion.v2v.example.com/vddk/VMware-vix-disklib-6.5.2-6195444.x86_64.tar.gz
Copy link
Contributor

Choose a reason for hiding this comment

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

@fdupont-redhat please check default value

@gmcculloug
Copy link
Member

@fdupont-redhat Can you cleanup the two Style/YodaCondition rubocop issues and un-wip if this is ready?

Not sure why we are seeing the other rubocop about parameters at the moment.

@ghost
Copy link
Author

ghost commented Feb 14, 2018

@gmcculloug These errors are strange, as this syntax is found in all the methods that implement the module layout. For example: https://github.com/ManageIQ/manageiq-content/blob/master/content/automate/ManageIQ/Cloud/Orchestration/Operations/Methods.class/__methods__/available_tenants.rb.

@gmcculloug
Copy link
Member

Correct, the YodaCondition is a more recent rubocop check so we were not seeing that when the new method type was introduced.

Ultimately we will want to go through and correct them all, but the goal is not to introduce more warnings.

@ghost ghost changed the title [WIP] V2V - State machines - Initial work V2V - State machines - Initial work Feb 14, 2018
@miq-bot miq-bot removed the wip label Feb 14, 2018
@ghost
Copy link
Author

ghost commented Feb 14, 2018

@gmcculloug WIP label removed and all lights green on rubocop side.

@gmcculloug
Copy link
Member

@tinaafitz @mkanoor Can you give this another look after changes?

@ghost
Copy link
Author

ghost commented Feb 14, 2018

Forgot to add the request entrypoints for the role check/enable/disable state machines.
@miq-bot add_label wip

@tinaafitz @lfu What would you advise for the request names ?

@miq-bot miq-bot changed the title V2V - State machines - Initial work [WIP] V2V - State machines - Initial work Feb 14, 2018
@miq-bot miq-bot added the wip label Feb 14, 2018
fields:
- State1:
value: "/Transformation/TransformationHosts/${#transformation_host_type}/RoleCheck"
on_error: "/Transformation/TransformationHosts/${#transformation_host_type}.MarkAsDisabled"
Copy link
Member

Choose a reason for hiding this comment

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

Where is MarkAsDisabled defined?

Copy link
Contributor

Choose a reason for hiding this comment

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

There is a TagAsEnabled? Does this needs to be renamed.

Copy link
Author

Choose a reason for hiding this comment

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

You're right. It is TagAsDisabled. I have renamed it.

value: "/Transformation/TransformationHosts/${#transformation_host_type}/RoleCheck"
on_error: "/Transformation/TransformationHosts/${#transformation_host_type}.MarkAsDisabled"
- State2:
value: "/Transformation/TransformationHosts/${#transformation_host_type}.MarkAsEnabled"
Copy link
Member

Choose a reason for hiding this comment

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

Same here.

Copy link
Contributor

Choose a reason for hiding this comment

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

@fdupont-redhat Does this need a METHOD:: since its a call to a class method

Copy link
Contributor

Choose a reason for hiding this comment

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

@fdupont-redhat Also is this TagAsEnabled?

Copy link
Author

Choose a reason for hiding this comment

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

You're right. It is TagAsDisabled. I have renamed it.

@mkanoor METHOD:: is not needed because on_error expects method(s). I don't know how it is coded internally, but experimentally it works without it. If you think I should make it explicit, I'll change it.

@miq-bot
Copy link
Member

miq-bot commented Feb 15, 2018

Checked commits fabiendupont/manageiq-content@2082d92~...8ef9427 with ruby 2.3.3, rubocop 0.52.0, haml-lint 0.20.0, and yamllint 1.10.0
20 files checked, 1 offense detected

**

  • 💣 💥 🔥 🚒 - Linter/Yaml - missing config files

@ghost
Copy link
Author

ghost commented Feb 15, 2018

@miq-bot remove_label wip

@miq-bot miq-bot changed the title [WIP] V2V - State machines - Initial work V2V - State machines - Initial work Feb 15, 2018
@miq-bot miq-bot removed the wip label Feb 15, 2018
Copy link
Member

@tinaafitz tinaafitz left a comment

Choose a reason for hiding this comment

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

@fdupont-redhat Looks good.

@gmcculloug gmcculloug merged commit 15b3a0e into ManageIQ:master Feb 15, 2018
@gmcculloug gmcculloug added this to the Sprint 80 Ending Feb 26, 2018 milestone Feb 15, 2018
ghost pushed a commit to fabiendupont/v2v-automate that referenced this pull request Mar 22, 2018
…Q/manageiq-content/pull/248.

Removed code for sysprep state, as we won't use them.
Moved the code to a sub directory to ease import.
simaishi pushed a commit that referenced this pull request May 29, 2018
…machines_init

V2V - State machines - Initial work
(cherry picked from commit 15b3a0e)
@simaishi
Copy link
Contributor

Gaprindashvili backport details:

$ git log -1
commit cfa1f77759fdd22e75ff7e19a770cb6d9bd0d0da
Author: Greg McCullough <gmccullo@redhat.com>
Date:   Thu Feb 15 15:55:17 2018 -0500

    Merge pull request #248 from fdupont-redhat/v2v_transformation_state_machines_init
    
    V2V - State machines - Initial work
    (cherry picked from commit 15b3a0e8e859ced52cd66c6ff0ecce91cf47a581)

@ghost ghost deleted the v2v_transformation_state_machines_init branch July 11, 2018 07:07
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.

None yet

7 participants