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

Use rails deprecation behavior but log in production #18847

Conversation

jrafanie
Copy link
Member

  • Copy current edge rails defaults for test/dev
  • Log deprecations in production mode
    Change from rails :notify default since it's unlikely we'll have users setup notifications for deprecation warnings.

There is no technical difference but clean up the settings.
Change from rails :notify default since it's unlikely we'll have users setup
notifications for depecation warnings.

# Change from rails :notify default since it's unlikely we'll have users setup
# notifications for deprecation warnings.
config.active_support.deprecation = :log
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the 🍖 of the PR. The default of notify is great when hosted as you can setup notifications for these. Since most of our users are not hosted by us, it will be unlikely we'll ever get deprecations reported to us unless we get them by default from logging.

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure...see my comment below. What does this solve that we couldn't do previously?

Copy link
Member Author

Choose a reason for hiding this comment

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

Deprecations, especially rails ones, should be exceptional. I'd like to stay on top of them so future upgrades are easier. Note, this doesn't affect Vmdb::Deprecation as that will never log in production so this only logs rails deprecations, ones we should definitely stay on top of.

Copy link
Member

@kbrock kbrock Jun 10, 2019

Choose a reason for hiding this comment

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

Don't we have a lot of code suppressing the notifications in production? At least for our own deprecations.

UPDATE: ugh, you just said that

# Print deprecation notices to the stderr
#ActiveSupport::Deprecation.behavior = :stderr
# Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr
Copy link
Member Author

Choose a reason for hiding this comment

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

Fix the syntax for this to the defaults from rails.

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.

👍 LGTM

@Fryguy
Copy link
Member

Fryguy commented Jun 10, 2019

Does this work with the container logger? I ask because of the stderr bit. nvm...didn't catch that the stderr bit was for test only

@Fryguy
Copy link
Member

Fryguy commented Jun 10, 2019

We've classically had deprecations off because in production mode (i.e. at customers) it's just noise. It's not like they can fix it.

# Send deprecation notices to registered listeners
config.active_support.deprecation = :notify
# Send deprecation notices to registered listeners.
# config.active_support.deprecation = :notify
Copy link
Member

Choose a reason for hiding this comment

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

Does a vanilla production.rb have both lines, but one commented out? If not, then I would think we'd just delete this line.

Copy link
Member Author

Choose a reason for hiding this comment

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

Right. I left it because the comment is wrong with this line saying :log instead of :notify

Copy link
Member Author

Choose a reason for hiding this comment

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

If I drop the the line that ships with rails, I should drop the comment too. They should stay or go together.

@bdunne
Copy link
Member

bdunne commented Jun 10, 2019

We've classically had deprecations off because in production mode (i.e. at customers) it's just noise. It's not like they can fix it.

We shouldn't go out the door with any known Rails deprecation warnings, right? We need to find out about any that remain and fix them before those methods are removed or changed. (and add tests)

@miq-bot
Copy link
Member

miq-bot commented Jun 10, 2019

Checked commits jrafanie/manageiq@bac06ac~...201ebfe with ruby 2.3.3, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0
3 files checked, 0 offenses detected
Everything looks fine. ⭐

@jrafanie
Copy link
Member Author

We've classically had deprecations off because in production mode (i.e. at customers) it's just noise. It's not like they can fix it.

We shouldn't go out the door with any known Rails deprecation warnings, right? We need to find out about any that remain and fix them before those methods are removed or changed. (and add tests)

👍 The reason to do this is to stay on top of fixing deprecations so they're not noisy. Any logs we receive we can look for deprecations and try to stay in front of them so upgrades are easier.

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.

Printing out deprecations is great.

Not sure the best way to encourage people to actually fix these deprecations rather than just live with them.


# Change from rails :notify default since it's unlikely we'll have users setup
# notifications for deprecation warnings.
config.active_support.deprecation = :log
Copy link
Member

@kbrock kbrock Jun 10, 2019

Choose a reason for hiding this comment

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

Don't we have a lot of code suppressing the notifications in production? At least for our own deprecations.

UPDATE: ugh, you just said that

Copy link
Member

@NickLaMuro NickLaMuro left a comment

Choose a reason for hiding this comment

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

My 2Cents (aside from the snark): I think this is a fine approach. Effectively we are crowd source our deprecation hunting, and I think that is a reasonable approach since we won't usually be able catch this ourselves.

Something to think about as well: Possibly we put together a production log parsing script that we can take user submitted logs and spend some time looking for deprecation warnings as well that crop up. Maybe filters on uniqueness and uses counts?

@@ -19,7 +19,7 @@
# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = false

# Print deprecation notices to the Rails logger
# Print deprecation notices to the Rails logger.
Copy link
Member

Choose a reason for hiding this comment

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

Man, this line is SUPER important!

Copy link
Member Author

Choose a reason for hiding this comment

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

Man, this line is SUPER important!

Period.

@@ -10,8 +10,8 @@
config.cache_classes = true
config.eager_load = false

# Print deprecation notices to the stderr
#ActiveSupport::Deprecation.behavior = :stderr
# Print deprecation notices to the stderr.
Copy link
Member

Choose a reason for hiding this comment

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

Again, extremely important!

@jrafanie
Copy link
Member Author

Something to think about as well: Possibly we put together a production log parsing script that we can take user submitted logs and spend some time looking for deprecation warnings as well that crop up. Maybe filters on uniqueness and uses counts?

@NickLaMuro I used this for the logs generated from QE:
zgrep -E 'DEPRECATION' */log/*.log* | grep -oE "WARN.+" | sort | uniq -c

It's not perfect but grouped enough of them together to get a decent idea of how many times it happens.

@NickLaMuro
Copy link
Member

@NickLaMuro I used this for the logs generated from QE:

$ zgrep -E 'DEPRECATION' */log/*.log* | grep -oE "WARN.+" | sort | uniq -c

It's not perfect but grouped enough of them together to get a decent idea of how many times it happens.

That works, though this got me thinking: Does this make sense as something that runs as an after task in CI as well, and then we can hook it into the @miq-bot (via a webhook) or something that could then bug people on PRs directly?

Again, just tossing some ideas out there for consideration. Not in anyway something that needs to be actionable right now.

@bdunne bdunne merged commit 3899308 into ManageIQ:master Jun 10, 2019
@bdunne bdunne self-assigned this Jun 10, 2019
@bdunne bdunne added this to the Sprint 113 Ending Jun 10, 2019 milestone Jun 10, 2019
@jrafanie jrafanie deleted the use_rails_deprecation_behavior_but_log_in_production branch June 10, 2019 21:23
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