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

Load collect_data() even if we've already seen it #1224

Merged
merged 1 commit into from
Jul 13, 2018

Conversation

btm
Copy link
Contributor

@btm btm commented Jul 12, 2018

If we happen to load a plugin with the same name twice, we refuse to run #collect_data but we still
load the rest of the plugin, which means you get #collect_data from the first plugin and rest of the
plugin from the last plugin.

This makes it so you get #collect_data from the last plugin as well.

I don't know how to use the logger from the class method so I fell back to Ohai::Log. Happy to fix that
if someone knows the magic.

Fixes #1212

Signed-off-by: Bryan McLellan [email protected]

If we happen to load a plugin with the same name twice, we refuse to run #collect_data but we still
load the rest of the plugin, which means you get #collect_data from the first plugin and rest of the
plugin from the last plugin.

This makes it so you get #collect_data from the last plugin as well.

I don't know how to use the logger from the class method so I fell back to `Ohai::Log`. Happy to fix that
if someone knows the magic.

Fixes #1212

Signed-off-by: Bryan McLellan <[email protected]>
@btm btm requested a review from a team July 12, 2018 16:16
@lamont-granquist
Copy link
Contributor

Yeah, the better way would be to fail it hard in some way or other, but there might be a chicken+egg with chef being unable to clean it up once it got into this state. The ohai segment in cookbooks is probably the better way to fix this 'right'.

At least here there's some hope that the collect_data from the last-parsed plugin will use the methods from the last-parsed plugin and that will be halfway sane, although technically the object is going to get monkeypatched multiple times...

👍

@btm
Copy link
Contributor Author

btm commented Jul 13, 2018

Agree this isn't ideal, but it's also an edge case. hopefully anyone going down this path see's the warning and then avoids having multiple plugins with the same name.

@tas50 tas50 merged commit 2cb5c8e into master Jul 13, 2018
@btm btm deleted the btm/fix-multiple-plugin-loading branch July 16, 2018 16:18
@lock
Copy link

lock bot commented Jan 24, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ohai merges duplicate plugins in very dangerous ways
3 participants