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

Redfish: centralize payload inspection logic and OEM logic #5425

Merged
merged 5 commits into from
Nov 2, 2022
Merged

Redfish: centralize payload inspection logic and OEM logic #5425

merged 5 commits into from
Nov 2, 2022

Conversation

mraineri
Copy link
Contributor

SUMMARY

There is a great deal of copy/paste code that does this in many places prior to invoking a PATCH request to the service. Added common logic for performing inspection of payloads when performing modification requests, which allowed for this copy/paste code to be removed throughout the module. It also alleviated cases where multiple GET requests to the same URI are being made, so this improves the I/O efficiency.

I'm still running tests to make sure I didn't break anything. The intent is to make this 100% backwards compatible, so no users should see a functional change from a module API perspective.

I also still have an outstanding item to centralize OEM checking for performing workarounds. I wanted eyes on these changes while I had them ready to ensure folks like what I'm doing.

Fixes #5210

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

redfish_utils

ADDITIONAL INFORMATION

@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added WIP Work in progress bug This issue/PR relates to a bug module_utils module_utils plugins plugin (any type) labels Oct 25, 2022
@ansibullbot

This comment was marked as outdated.

@ansibullbot ansibullbot added the ci_verified Push fixes to PR branch to re-run CI label Oct 25, 2022
@ansibullbot ansibullbot removed the ci_verified Push fixes to PR branch to re-run CI label Oct 26, 2022
@felixfontein felixfontein added the check-before-release PR will be looked at again shortly before release and merged if possible. label Oct 29, 2022
@mraineri
Copy link
Contributor Author

Update: Everything has checked out with my unit testing with the current changes. Remaining item is to add common vendor checking for various workaround logic.

@mraineri
Copy link
Contributor Author

@felixfontein would it be possible to remove the image_only=False found in the virtual_media_insert_via_patch and virtual_media_eject_via_patch methods at this point? I was expecting those to be marked as private methods (and only invoked by the public virtual_media_insert and virtual_media_eject methods), but it looks like they were defined as public methods. It's not a problem if we can't at this point, but it would've been good to clean that up to simplify the interface for callers into the module.

@felixfontein
Copy link
Collaborator

@mraineri we should probably deprecate them before removing, something like this:

  1. Define some object _SENTRY = object() at the top of the file.
  2. Define the default value of image_only to be _SENTRY.
  3. Add if image_only is not _SENTRY: self.module.deprecate('The image_only paramete will be removed from XXX in redfish module utils', version='7.0.0', collection_name='community.general'); else: image_only = False at the beginning of the function body.

@felixfontein
Copy link
Collaborator

@mraineri btw, do you think you can complete this by the end of this week, so we can make sure it will make it into the 6.0.0 release on next Monday?

@mraineri
Copy link
Contributor Author

mraineri commented Nov 1, 2022

@mraineri we should probably deprecate them before removing, something like this:

1. Define some object `_SENTRY = object()` at the top of the file.

2. Define the default value of `image_only` to be `_SENTRY`.

3. Add `if image_only is not _SENTRY: self.module.deprecate('The image_only paramete will be removed from XXX in redfish module utils', version='7.0.0', collection_name='community.general'); else: image_only = False` at the beginning of the function body.

Thanks; I'll do that!

@mraineri btw, do you think you can complete this by the end of this week, so we can make sure it will make it into the 6.0.0 release on next Monday?

Yup, I should have everything in before then; just testing the OEM check changes now.

@mraineri
Copy link
Contributor Author

mraineri commented Nov 1, 2022

@mraineri we should probably deprecate them before removing, something like this:

1. Define some object `_SENTRY = object()` at the top of the file.

2. Define the default value of `image_only` to be `_SENTRY`.

3. Add `if image_only is not _SENTRY: self.module.deprecate('The image_only paramete will be removed from XXX in redfish module utils', version='7.0.0', collection_name='community.general'); else: image_only = False` at the beginning of the function body.

Would it be possible to do something similar to turn public methods into private methods? I'd like to take some of the via_patch methods private since external callers really should be using the top-level method, which will determine the best procedure to take. I could also save this for future clean-up; I'm seeing more things that I think can be done more optimally.

@felixfontein
Copy link
Collaborator

Sure, you could rename the method (leading underscore) and add another method with the old name that calls module.deprecate() and then the private method.

@mraineri
Copy link
Contributor Author

mraineri commented Nov 2, 2022

Sure, you could rename the method (leading underscore) and add another method with the old name that calls module.deprecate() and then the private method.

Thanks! I'll save that for a future change so I can get the critical portion in.

@mraineri mraineri changed the title [WIP] Redfish: centralize payload inspection logic and OEM logic Redfish: centralize payload inspection logic and OEM logic Nov 2, 2022
@mraineri
Copy link
Contributor Author

mraineri commented Nov 2, 2022

OEM workaround logic has been tested.

It's worth noting that the pattern I'd like to establish is for the module to always try the "correct" approach first, and then fall back to workaround logic when errors are encountered. That way if a vendor patches their BMC to support the correct method of implementing the API, no changes are needed in the module to make use of the better approach.

@ansibullbot ansibullbot removed the WIP Work in progress label Nov 2, 2022
@github-actions

This comment was marked as off-topic.

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.

I only glanced over the code, but it looks good to me.

@felixfontein felixfontein removed the check-before-release PR will be looked at again shortly before release and merged if possible. label Nov 2, 2022
@felixfontein felixfontein merged commit ea3550d into ansible-collections:main Nov 2, 2022
@felixfontein
Copy link
Collaborator

@mraineri thanks a lot for improving this!

rekup pushed a commit to rekup/community.general that referenced this pull request Nov 3, 2022
…ollections#5425)

* Redfish: centralize payload checking when performing modification requests to a Redfish service

* CI fixes

* Updates based on unit testing

* CI fix

* Modified vendor-specific logic to establish common pattern for workarounds
russoz pushed a commit to russoz-ansible/community.general that referenced this pull request Nov 5, 2022
…ollections#5425)

* Redfish: centralize payload checking when performing modification requests to a Redfish service

* CI fixes

* Updates based on unit testing

* CI fix

* Modified vendor-specific logic to establish common pattern for workarounds
bratwurzt pushed a commit to bratwurzt/community.general that referenced this pull request Nov 7, 2022
…ollections#5425)

* Redfish: centralize payload checking when performing modification requests to a Redfish service

* CI fixes

* Updates based on unit testing

* CI fix

* Modified vendor-specific logic to establish common pattern for workarounds
bratwurzt pushed a commit to bratwurzt/community.general that referenced this pull request Nov 7, 2022
…ollections#5425)

* Redfish: centralize payload checking when performing modification requests to a Redfish service

* CI fixes

* Updates based on unit testing

* CI fix

* Modified vendor-specific logic to establish common pattern for workarounds
russoz pushed a commit to russoz-ansible/community.general that referenced this pull request Nov 10, 2022
…ollections#5425)

* Redfish: centralize payload checking when performing modification requests to a Redfish service

* CI fixes

* Updates based on unit testing

* CI fix

* Modified vendor-specific logic to establish common pattern for workarounds
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 module_utils module_utils plugins plugin (any type)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cleanup Redfish module based on growth of functionality
3 participants