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

dcnm_image_policy: fix for issue #347 #348

Merged
merged 2 commits into from
Dec 3, 2024
Merged

Conversation

allenrobel
Copy link
Collaborator

@allenrobel allenrobel commented Nov 21, 2024

Summary

The dcnm_image_policy module was not handling overridden state correctly.

It was correctly deleting image policies that were not in the playbook, but it was merging image policy configurations from the playbook with the image policy configurations on the controller. It should have been REPLACING these configurations.

Fix

This PR addresses this by modifying the Overridden() class within dcnm_image_policy.py to call Replaced().commit() rather than Merged().commit().

No changes are required for unit tests since the individual support modules are all doing what they are supposed to do. The only issue here was that dcnm_image_policy.py (main module) was instantiating, and calling commit() on, the wrong class.

Other changes

  1. Updated dcnm_image_policy integration test.

a. For overridden state, added a packages dictionary to the created image policy's configuration (this adds packageName and rpmimages to the image policy).

b. Added verifications that the task for overridden state removes packageName and rpmimages from the image policy.

c. Updated asserts for metadata to verify that metadata.action is "replace" rather than "update"

Closes

Closes issue #347

Manually tested this to verify.

Still need to update integration and unit tests.
@allenrobel allenrobel added the Work in Progress Code not ready for review. label Nov 21, 2024
@allenrobel allenrobel self-assigned this Nov 21, 2024
@allenrobel allenrobel changed the title Fix for issue #347 dcnm_image_policy: fix for issue #347 Nov 21, 2024
Update integration test for overridden state.

1. playbooks/roles/dcnm_image_policy/dcnm_tests.yaml

- Add vars
    - install_package_1
    - uninstall_package_1

2. test/integration/targets/dcnm_image_policy/tests/dcnm_image_policy_overridden.yaml

- Add packages.install and packages.uninstall configuration
- Verify that merged state adds these packages to the controller config
- Verify that overridden state removes packages.install and packages.uninstall
- Verify that overridden state metadata.action is "replace" instead of "update"
@allenrobel allenrobel added ready for review PR is ready to be reviewed and removed Work in Progress Code not ready for review. labels Nov 21, 2024
@mikewiebe mikewiebe merged commit cae4142 into develop Dec 3, 2024
9 checks passed
allenrobel added a commit that referenced this pull request Dec 3, 2024
* Fix for issue 347

Manually tested this to verify.

Still need to update integration and unit tests.

* dcnm_image_policy: Update integration test

Update integration test for overridden state.

1. playbooks/roles/dcnm_image_policy/dcnm_tests.yaml

- Add vars
    - install_package_1
    - uninstall_package_1

2. test/integration/targets/dcnm_image_policy/tests/dcnm_image_policy_overridden.yaml

- Add packages.install and packages.uninstall configuration
- Verify that merged state adds these packages to the controller config
- Verify that overridden state removes packages.install and packages.uninstall
- Verify that overridden state metadata.action is "replace" instead of "update"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready for review PR is ready to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dcnm_image_policy: overridden state should replace rather than merge image policy configurations
2 participants