-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Cleanup Redfish module based on growth of functionality #5210
Comments
Files identified in the description: If these files are incorrect, please update the |
@felixfontein I'd like your opinion on one thing I'm finding. There are some cases where checks are made for both "is the property supported" as well as "is the property in the desired state already". For example, take a look at the code starting here: https://github.com/ansible-collections/community.general/blob/main/plugins/module_utils/redfish_utils.py#L1171 I wanted to delete the block at line 1171 since a PATCH with unsupported properties will result in a 400 from the service, which also means we can save a GET request and simply send a PATCH right away. However, there's a dependence on performing a GET starting at line 1181 to see if a PATCH is even needed in the first place. Is it important from an Ansible perspective to avoid sending unnecessary configuration requests? If it's not important, then |
@mraineri from the Ansible perspective, it's important that a change does not break backwards compatibility (for example, if the module simply didn't apply changes that were not supported in the past, and now fails, that would be bad). Another thing that are potentially important is check mode support. If a module was using checks to first determine (conclusively) whether the change is needed, and only applies it when needed, it usually supports check mode. If you change that to "do the change and then ask the API whether something changed" this would be a problem. But the way I understand the code and your proposed change, I think neither of these two apply, so it should be good. It might be a change that affects the observable result for the user in case of errors, but that's fine IMO. |
Thanks for the feedback. I think in this case pulling out these checks should be okay since none of the code performs a follow-up check to see if the properties really changed. At least stepping through the code paths to the different results, the outcomes should be the same, with the exception of 'changed' always returning 'true' in the success path. Scenario 1: User provides unsupported property
Scenario 2: User provides property that is different from the existing configuration
Scenario 3: User provides property that is already configured to the desired state
|
@felixfontein one more question: how important is the usage of 'changed' in results? I'm finding inconsistencies where some methods that perform a property modification in an API request don't return 'changed' in the results, where as others do. |
I think in the interest of maintaining the 'changed' behavior, I'll be revising my course of action. I'll certainly be looking to have more generic "is change needed" code to avoid all of the copying/pasting there is right now. |
Doing changes without indicating
👍 |
Not that I could find; it just seems like a gap in some of the methods. |
Looks like you were right; I found at the very end of redfish_command.py it will apply "changed=True" by default. |
Summary
I would like to review and clean redfish_utils.py to ensure it aligns with best practices for the standard. Some examples of things to cleanup:
Issue Type
Feature Idea
Component Name
redfish_utils
Additional Information
Some logic I've seen copy/pasted around the module looks like a good candidate to prune/remove altogether. This block of code is a good example of the type of logic we have in the module today for many of the generic "set" routines:
This type of code does up-front comparisons between the API response containing the current state of the resource to change and the requested changes by the user. It performs two types of checks: does the API support the requested property and is the property of the correct format. In both cases, the API is expected to return an HTTP 400 Bad Request for either of these cases. So, this type of upfront checks really just saves us a request/response cycle. In my opinion, it's not worth adding this much bloat to the module since it can lead to future bugs if not done correctly.
There was also a recent addition to add a
_get_vendor
method to redfish_utils. I think this is a good thing to enhance and use in a more common manner in the module. There are some checks in various methods to perform workarounds if a given vendor or other firmware identifier is detected. Some workarounds exist today in virtual media methods for various vendors, and there is an open issue for defining a workaround for one-time boot override for a particular Dell implementation.Code of Conduct
The text was updated successfully, but these errors were encountered: