-
Notifications
You must be signed in to change notification settings - Fork 896
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
[POC][WIP] Slim evm rake tasks (alternative to #14916) #15342
Conversation
Allows the DatabaseConfigurationPatch to be loaded without haven't the lib/ dir in the load path.
This class is in charge of making a simple connection for scripts and workers that don't go through `config/environment.rb` (like rake tasks and anything using `bin/rails`). Allows for checking if a connection exists, and creating a connection if needed, optionally being able to pass a block to close the created connection after it has been executed. This includes a ConnectionConfig class for simply pulling the connection information from that `config/database.yml` in the same fashion as what would be done in a regular rails process.
Each of the lib/vmdb/loggers/* files use the `Vmdb::Loggers` name space when defining themselves, but that namespace has not been defined yet if `vmdb/loggers` is required on it's own. By using moving the Dir.glob to the bottom of the file (after the namespace has been setup), we can load the files just fine and not have to change how the namespacing is done in the individual logger files.
Non of this code needs rails, and is just file system calls and a little SecureRandom if needed, so moving this to the ManageIQ module allows it to be used without loading Rails. Maintained the MiqServer.my_guid method for now since it is used by MiqServer.my_server and that is used in many places.
The Vmdb::Settings.decrypt_passwords is just a convenience method and just calls out to Vmdb::Settings::Walker.decrypt_passwords, and also Vmdb::Settings::Walker doesn't require any external dependencies to function, so using this makes the database_configuration_patch more portable.
Use a new task called evm_connect as a pre-req to build an ActiveRecord connection (if one doesn't exist) and allow the tasks to make DB calls. Also converts the MiqServer calls to vanilla Arel (a little bit gross... I know) to allow them to make DB calls without the model (and Rails) being loaded.
Adds helpers to the evm_rake_helper to dynamically load portions of the application depending of what rake tasks are being required. Drastically speeds up the time it takes for task to be executed and the time taken to do so. Before ------ $ bin/rake evm:status_full Checking EVM status... Zone | Server | Status | ID ... ---------+--------+---------+---- ... default | EVM | stopped | 1 ... TOTAL_MEMORY_USED: 164.75390625MiB Timings ------- real 0m5.196s user 0m4.000s sys 0m1.160s cuser 0m0.000s csys 0m0.000s After ------ $ bin/rake evm:status_full Checking EVM status... Zone | Server | Status | ID ... ---------+--------+---------+---- ... default | EVM | stopped | 1 ... TOTAL_MEMORY_USED: 58.84375MiB Timings ------- real 0m1.131s user 0m0.740s sys 0m0.380s cuser 0m0.000s csys 0m0.000s
Some comments on commits NickLaMuro/manageiq@db99d24~...f41564b spec/lib/manageiq/active_record_connector_spec.rb
|
Checked commits NickLaMuro/manageiq@db99d24~...f41564b with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 app/models/miq_server.rb
lib/manageiq/active_record_connector.rb
lib/tasks/evm_application.rb
lib/tasks/evm_rake_helper.rb
spec/lib/manageiq/active_record_connector_spec.rb
|
This pull request is not mergeable. Please rebase and repush. |
This pull request has been automatically closed because it has not been updated for at least 6 months. Feel free to reopen this pull request if these changes are still valid. Thank you for all your contributions! |
An alternative approach to #14916, which had a lot of model changes and mixin splitting.
Changes
This approach does to major things differently:
evm:status
calls. While gross, I admit, it completely removes the need to include the MiqServer at allCurrently, the tasks besides
evm:status
andevm:status_full
are not updated, and that is a work in progress still.Benchmarks
Before:
After:
Links
Steps for Testing/QA
Mostly confirm the
rake evm:
based tasks still work as expected (depending on how many were converted in this PR).