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

Warn when we're running fix_auth in dry run mode #17410

Merged
merged 1 commit into from
Jun 5, 2018

Conversation

jrafanie
Copy link
Member

@jrafanie jrafanie commented May 11, 2018

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

It's very easy to use -d incorrectly as the database name.
We should remove the short option -d (for dry run) since it
conflicts with pg_dump and other tooling for postgresql but
regardless, we should have obvious feedback that we're in dry run
mode.

Fix database.yml output with dry run

$ tools/fix_auth.rb -h localhost -U root --password smartvm --hardcode bogus vmdb_development -d --verbose -y
** fix_database_yml is executing in dry-run mode, and no actual changes will be made**
fixing /Users/joerafaniello/Code/manageiq/config/database.yml.yaml
  /Users/joerafaniello/Code/manageiq/config/database.yml:
    yaml:
viewed 1 records
** This was executed in dry-run, and no actual changes will be made to /Users/joerafaniello/Code/manageiq/config/database.yml **

Fix database passwords with dry run

$ tools/fix_auth.rb -h localhost -U root --password smartvm --hardcode bogus vmdb_development -d --verbose
** fix_database_passwords is executing in dry-run mode, and no actual changes will be made**
fixing authentications.password, auth_key
viewed 0 records
fixing miq_databases.registration_http_proxy_server, session_secret_token, csrf_secret_token
  1:
    session_secret_token: "v2:{...}" => v2:{...}
    csrf_secret_token: "v2:{...}" => v2:{...}
viewed 1 records
** This was executed in dry-run, and no actual changes will be made to miq_databases **
fixing miq_ae_values.value
viewed 0 records
fixing miq_ae_fields.default_value
viewed 0 records
fixing settings_changes.value
viewed 0 records
fixing miq_requests.options
viewed 0 records
fixing miq_request_tasks.options
viewed 0 records

@Fryguy
Copy link
Member

Fryguy commented May 11, 2018

I feel like you should add a banner liek "**This is executing in dry-run mode, and no actual changes will be made**"

The "fixing" vs "would fix" seems a little too subtle and those not reading every single line might just scan right past it (I know I would, as I'd probably just look at the table names), and the "Changes would be made to " gets buried (on first glance of the before/after I didn't even see it).

Alternately, prefix each line with something that stands out like **dry-run - would fix

Copy link
Member

@bdunne bdunne left a comment

Choose a reason for hiding this comment

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

👍

@jrafanie
Copy link
Member Author

I'll enhance the banner so it's clearer and LOUDER 👍

Copy link
Member

@kbrock kbrock left a comment

Choose a reason for hiding this comment

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

👍

@jrafanie jrafanie force-pushed the warn_when_fix_auth_is_in_dry_run branch from 905e51f to f20e13e Compare May 30, 2018 18:10
@jrafanie
Copy link
Member Author

Ok, finally updated with @Fryguy's suggestion

@jrafanie
Copy link
Member Author

  • Line 54, Col 16 - Performance/Caller - Use caller_locations(1..1).first instead of caller_locations.first.

Settle down @miq-bot, you're talking nonsense.

@miq-bot
Copy link
Member

miq-bot commented May 30, 2018

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

@jrafanie jrafanie force-pushed the warn_when_fix_auth_is_in_dry_run branch from f20e13e to 8ca1c79 Compare May 31, 2018 15:55
https://bugzilla.redhat.com/show_bug.cgi?id=1577303

It's very easy to use -d incorrectly as the database name.
We should remove the short option -d (for dry run) since it
conflicts with pg_dump and other tooling for postgresql but
regardless, we should have obvious feedback that we're in dry run
mode.

**Fix database.yml output with dry run**

```
$ tools/fix_auth.rb -h localhost -U root --password smartvm --hardcode bogus vmdb_development -d --verbose -y
** fix_database_yml is executing in dry-run mode, and no actual changes will be made**
fixing /Users/joerafaniello/Code/manageiq/config/database.yml.yaml
  /Users/joerafaniello/Code/manageiq/config/database.yml:
    yaml:
viewed 1 records
** This was executed in dry-run, and no actual changes will be made to /Users/joerafaniello/Code/manageiq/config/database.yml **
```

**Fix database passwords with dry run**

```
$ tools/fix_auth.rb -h localhost -U root --password smartvm --hardcode bogus vmdb_development -d --verbose
** fix_database_passwords is executing in dry-run mode, and no actual changes will be made**
fixing authentications.password, auth_key
viewed 0 records
fixing miq_databases.registration_http_proxy_server, session_secret_token, csrf_secret_token
  1:
    session_secret_token: "v2:{...}" => v2:{...}
    csrf_secret_token: "v2:{...}" => v2:{...}
viewed 1 records
** This was executed in dry-run, and no actual changes will be made to miq_databases **
fixing miq_ae_values.value
viewed 0 records
fixing miq_ae_fields.default_value
viewed 0 records
fixing settings_changes.value
viewed 0 records
fixing miq_requests.options
viewed 0 records
fixing miq_request_tasks.options
viewed 0 records
```
@jrafanie
Copy link
Member Author

Rebased after #17413 was merged.

@miq-bot
Copy link
Member

miq-bot commented May 31, 2018

Checked commit jrafanie@8935d78 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
2 files checked, 1 offense detected

tools/fix_auth/fix_auth.rb

Copy link
Member

@kbrock kbrock left a comment

Choose a reason for hiding this comment

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

I'm good with this.

I did notice that the cop seemed to make sense to me.

@@ -50,7 +50,15 @@ def generate_password
raise Errno::EEXIST, e.message
end

def print_dry_run_warning
method = caller_locations.first.label
Copy link
Member

Choose a reason for hiding this comment

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

@jrafanie Did you say that you didn't want to pass parameters to caller_locations?

I think the extra parameters let the kernel build a smaller array vs having to build a big array that is basically thrown away.

Looks like stack overflow also has a similar syntax:

caller_locations(1,1).first.label

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I'd rather not have ugly ruby internals leak into a place that will rarely if ever cause a performance problem. If they provided a convenience method to retrieve the first caller location, then it would make sense here but since the alternative (1,1 or a range) isn't exactly elegant, I prefer the original code.

Copy link
Member Author

Choose a reason for hiding this comment

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

Note, if it turns out to be a performance problem, we an always change it but I prefer readability here because I can't imagine this is the performance problem that will break us.

@kbrock kbrock merged commit 7dc93cd into ManageIQ:master Jun 5, 2018
@kbrock kbrock self-assigned this Jun 5, 2018
@kbrock kbrock added this to the Sprint 88 Ending Jun 18, 2018 milestone Jun 5, 2018
@jrafanie jrafanie deleted the warn_when_fix_auth_is_in_dry_run branch June 14, 2018 17:34
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.

5 participants