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

[Fine] Fixauth handles serialized objects #17428

Closed
wants to merge 2 commits into from

Conversation

kbrock
Copy link
Member

@kbrock kbrock commented May 16, 2018

allow rails to be loaded in fix auth

When objects are serialized into yaml blobs in tables,
we need to load our whole environment to handle the deserialization

This typically happens with miq_requests.options

  • add --allow-failures flag
  • add note where error was found
  • require standard rails when allow failures
  • continue despite errors when allow failures
  • display status, counts, and # errors
  • change order of fixes
  • reduce columns brought back
  • sending error output to STDERR
  • only bring back request/task records that have v1/2 encoded passwords

related to #17413

Performance implication: For one customer, it is taking a multi hour process down to 3 minutes

to access MiqPassword from a manageiq-gems-pending
@@ -24,6 +24,7 @@ def parse(args, env = {})
opt :databaseyml, "Rewrite database.yml", :type => :boolean, :short => "y", :default => false
opt :db, "Upgrade database", :type => :boolean, :short => 'x', :default => false
opt :legacy_key, "Legacy Key", :type => :string, :short => "K"
opt :resilient, "Run through all records, even with errors", :type => :boolean, :short => nil, :default => false
Copy link
Member

Choose a reason for hiding this comment

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

Maybe something like pg_restore's exit on error, but default it to true so it won't blindly continue on

 -e
--exit-on-error

https://www.postgresql.org/docs/9.6/static/app-pgrestore.html

@kbrock kbrock force-pushed the fix_auth_fixup_f branch from 1f3f27e to 1939eaa Compare May 16, 2018 19:46
@kbrock
Copy link
Member Author

kbrock commented May 16, 2018

@jrafanie so if --exit-on-error defaults to true then you have to pass --no-exit-on-error ?

@jrafanie
Copy link
Member

@jrafanie so if --exit-on-error defaults to true then you have to pass --no-exit-on-error ?

Good point. I don't like how trollop does no-.... I see why you did --resilient. How about --allow-failures or something like that

@kbrock kbrock force-pushed the fix_auth_fixup_f branch 4 times, most recently from f38b546 to 118034a Compare May 17, 2018 21:56
@kbrock
Copy link
Member Author

kbrock commented May 17, 2018

--allow-failures or something like that
@jrafanie

done

puts "potentially bad yaml:"
puts old_value
unless options[:allow_failures]
puts "potentially bad yaml:"
Copy link
Member

Choose a reason for hiding this comment

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

Would STDERR.puts be better?

rescue
errors += 1
unless options[:allow_failures]
puts "unable to fix #{r.class.table_name}:#{r.id}" if !options[:silent]
Copy link
Member

Choose a reason for hiding this comment

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

Same with STDERR

@@ -89,6 +93,7 @@ def run

generate_password if options[:key]
fix_database_yml if options[:databaseyml]
load_rails if options[:allow_failures]
Copy link
Member

Choose a reason for hiding this comment

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

I don't get why you load rails only when you allow failures

Copy link
Member Author

@kbrock kbrock May 18, 2018

Choose a reason for hiding this comment

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

@Fryguy we have never loaded rails before. As long as the database.yml is fixed (fix_database_yml) I guess we could always load rails.

It certainly would mask some issues but would simplify this process (typically performed in a critical window).

@kbrock kbrock force-pushed the fix_auth_fixup_f branch 4 times, most recently from fe4895a to e25e943 Compare May 21, 2018 15:13
When objects are serialized into yaml blobs in tables,
we need to load our whole environment to handle the deserialization

This typically happens with miq_requests.options

- add --allow-failures flag
- add note where error was found
- require standard rails when allow failures
- continue despite errors when allow failures
- display status, counts, and # errors
- change order of fixes
- reduce columns brought back
- sending error output to STDERR
- only bring back request/task records that have v2 encoded passwords
- drop tests for v0 encoded passwords
@kbrock kbrock force-pushed the fix_auth_fixup_f branch from e25e943 to dc11ba7 Compare May 21, 2018 18:30
@miq-bot
Copy link
Member

miq-bot commented May 21, 2018

Checked commits kbrock/manageiq@f044013~...dc11ba7 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
7 files checked, 2 offenses detected

tools/fix_auth/auth_model.rb

@carbonin
Copy link
Member

Ah, I didn't see the comments here before I merged the PR to master ... were there issues you wanted addressed there @Fryguy @jrafanie ?

@@ -75,6 +75,10 @@ def fix_database_yml
FixDatabaseYml.run({:hardcode => options[:password]}.merge(run_options))
end

def load_rails
require File.expand_path("../../../config/application.rb", __FILE__)
Copy link
Member

Choose a reason for hiding this comment

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

Don't you want to run the initializers? Typically, tools in the tools directory require config/environment to load rails, which is the same as above ^ but it also calls Vmdb::Application.initialize!

Copy link
Member

Choose a reason for hiding this comment

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

I'll move this comment to the master PR

@kbrock
Copy link
Member Author

kbrock commented Aug 9, 2018

closing - this is too late to be backported to Fine

@kbrock kbrock closed this Aug 9, 2018
@kbrock kbrock deleted the fix_auth_fixup_f branch August 9, 2018 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants