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

Fix linode inventory filtering #4336

Merged

Conversation

stvnjacobs
Copy link
Contributor

SUMMARY

There was a regression introduced in the addition of caching. The
_consume_options method was added and provided the config_data
dictionary. This pops every entry, resulting in an empty config_data
dict, which was then reused and expected to be populated.

After reviewing, _consume_data doesn't need to be called. Also, once
the _read_config_data method has been called, we no longer need the
config_data dict, and can instead use the get_option method
throughout.

Once those were removed, the filtering function seemed a bit odd, since
we were no longer using the file. I used that opportunity to move the
filter calls into the populate function directly.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

community.general.linode

There was a regression introduced in the addition of caching. The
`_consume_options` method was added and provided the `config_data`
dictionary. This `pop`s every entry, resulting in an empty `config_data`
dict, which was then reused and expected to be populated.

After reviewing, `_consume_data` doesn't need to be called. Also, once
the ``_read_config_data` method has been called, we no longer need the
config_data dict, and can instead use the `get_option` method throughout.

Once those were removed, the filtering function seemed a bit odd, since
we were no longer using the file. I used that opportunity to move the
filter calls into the populate function directly.
@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added bug This issue/PR relates to a bug cloud inventory inventory plugin new_contributor Help guide this first time contributor plugins plugin (any type) needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR labels Mar 9, 2022
@stvnjacobs
Copy link
Contributor Author

Realized I missed updating the tests and changelog entries. I will have those up shortly, and will mark this as a draft until it is ready for review.

@stvnjacobs stvnjacobs marked this pull request as draft March 9, 2022 17:50
@ansibullbot ansibullbot added the WIP Work in progress label Mar 9, 2022
This removes tests that targeted some custom methods on configuration
file handling. These are no longer necessary since they are now handled
by the BaseInventoryPlugin `_read_config_data` method.
@ansibullbot ansibullbot added tests tests unit tests/unit labels Mar 9, 2022
@stvnjacobs stvnjacobs marked this pull request as ready for review March 9, 2022 18:37
@ansibullbot ansibullbot removed WIP Work in progress needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR labels Mar 9, 2022
@stvnjacobs
Copy link
Contributor Author

Alright. Removed the tests that targeted some custom methods on configuration file handling which are no longer necessary and added the changelog fragment.

Copy link
Collaborator

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution!

plugins/inventory/linode.py Show resolved Hide resolved
@felixfontein felixfontein added backport-4 check-before-release PR will be looked at again shortly before release and merged if possible. labels Mar 9, 2022
This moves filters back into their own method, but now uses the
get_option calls to pull filter configuration items.
@ansibullbot ansibullbot added the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR label Mar 10, 2022
Copy link
Collaborator

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

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

Looks good as far as I can tell.

@felixfontein
Copy link
Collaborator

@wbh1 since you actually use this plugin (I hope :D ), could you take a look at this PR? Since you left a reaction I guess you already glanced at it (and apparently liked it), but some more explicit feedback would also be nice :)

@ansibullbot ansibullbot removed the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR label Mar 10, 2022
@felixfontein
Copy link
Collaborator

Ok, if nobody minds I'll merge by tomorrow morning.

@wbh1
Copy link
Contributor

wbh1 commented Mar 14, 2022

@wbh1 since you actually use this plugin (I hope :D ), could you take a look at this PR?

Can confirm that this works as expected / fixes the bug I introduced 😅

@felixfontein felixfontein removed the check-before-release PR will be looked at again shortly before release and merged if possible. label Mar 14, 2022
@felixfontein felixfontein merged commit 386bb4b into ansible-collections:main Mar 14, 2022
@patchback
Copy link

patchback bot commented Mar 14, 2022

Backport to stable-4: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-4/386bb4bdd5c15a80319c0647cf5066d65a27738a/pr-4336

Backported as #4356

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request Mar 14, 2022
* Fix linode inventory filtering

There was a regression introduced in the addition of caching. The
`_consume_options` method was added and provided the `config_data`
dictionary. This `pop`s every entry, resulting in an empty `config_data`
dict, which was then reused and expected to be populated.

After reviewing, `_consume_data` doesn't need to be called. Also, once
the ``_read_config_data` method has been called, we no longer need the
config_data dict, and can instead use the `get_option` method throughout.

Once those were removed, the filtering function seemed a bit odd, since
we were no longer using the file. I used that opportunity to move the
filter calls into the populate function directly.

* Remove tests that target removed methods

This removes tests that targeted some custom methods on configuration
file handling. These are no longer necessary since they are now handled
by the BaseInventoryPlugin `_read_config_data` method.

* Add changelog entry for linode inventory bugfix

* Revert filters back to their own method

This moves filters back into their own method, but now uses the
get_option calls to pull filter configuration items.

(cherry picked from commit 386bb4b)
@felixfontein
Copy link
Collaborator

@stvnjacobs thanks for fixing this!
@wbh1 thanks for reviewing!

felixfontein pushed a commit that referenced this pull request Mar 14, 2022
* Fix linode inventory filtering

There was a regression introduced in the addition of caching. The
`_consume_options` method was added and provided the `config_data`
dictionary. This `pop`s every entry, resulting in an empty `config_data`
dict, which was then reused and expected to be populated.

After reviewing, `_consume_data` doesn't need to be called. Also, once
the ``_read_config_data` method has been called, we no longer need the
config_data dict, and can instead use the `get_option` method throughout.

Once those were removed, the filtering function seemed a bit odd, since
we were no longer using the file. I used that opportunity to move the
filter calls into the populate function directly.

* Remove tests that target removed methods

This removes tests that targeted some custom methods on configuration
file handling. These are no longer necessary since they are now handled
by the BaseInventoryPlugin `_read_config_data` method.

* Add changelog entry for linode inventory bugfix

* Revert filters back to their own method

This moves filters back into their own method, but now uses the
get_option calls to pull filter configuration items.

(cherry picked from commit 386bb4b)

Co-authored-by: steven jacobs <stjacobs@fastmail.fm>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug cloud inventory inventory plugin new_contributor Help guide this first time contributor plugins plugin (any type) tests tests unit tests/unit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants