[ansible-openwisp2] Upgrade pip deps from requirements on rerun #575
[ansible-openwisp2] Upgrade pip deps from requirements on rerun #575Piyushrathoree wants to merge 6 commits intoopenwisp:masterfrom
Conversation
|
@pandafy PTAL |
pandafy
left a comment
There was a problem hiding this comment.
Good start @Piyushrathoree!
I am afraid that --upgrade might not always work when we use tarball URL as source. E.g. when we set openwisp-controller version in the ansible playbook
openwisp2_controller_version: openwisp-controller @ https://github.com/openwisp/openwisp-controller/tarball/masterIn such scenarios, we would need to use state: forcereinstall.
Using forcereinstall by default will slow down the playbook, since it will make pip reinstall packages even when the latest package have been installed.
I can think of exposing pip.extra_args argument through ansible variable openwisp2_pip_extra_args. The default value for this argument will be openwisp2_pip_extra_args: "--upgrade". When needed, the user can override the variable in the playbook to use `openwisp2_pip_extra_args: "--upgrade --force-reinstall" which will force-reinstall the packages.
We will need to add this new variable in https://github.com/openwisp/ansible-openwisp2/blob/master/docs/user/role-variables.rst, and explain the usage with a comment. You can take reference from other settings mentioned in the file.
value --upgrade and can be overridden with --upgrade --force-reinstall
This reverts commit 98367c9.
015e499 to
73ed71d
Compare
thanks @pandafy |
Co-authored-by: Gagan Deep <the.one.above.all.titan@gmail.com>
| # Extra arguments passed to pip when reinstalling Python packages with --force-reinstall | ||
| # By default, packages are upgraded on each playbook run. | ||
| # Can be overridden, for example: | ||
| # openwisp2_pip_extra_args: "--upgrade --force-reinstall" |
There was a problem hiding this comment.
| # Extra arguments passed to pip when reinstalling Python packages with --force-reinstall | |
| # By default, packages are upgraded on each playbook run. | |
| # Can be overridden, for example: | |
| # openwisp2_pip_extra_args: "--upgrade --force-reinstall" | |
| # Extra arguments passed to pip when installing Python packages. | |
| # By default, packages are upgraded on each playbook run. | |
| # Can be overridden, for example: | |
| # openwisp2_pip_extra_args: "--upgrade --force-reinstall" |
📝 WalkthroughWalkthroughThis PR introduces a new Ansible variable Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
♻️ Duplicate comments (1)
docs/user/role-variables.rst (1)
34-38:⚠️ Potential issue | 🟡 MinorClarify the
openwisp2_pip_extra_argsdescription to match actual default behavior.Line 34 implies
--force-reinstallis part of the normal behavior, but Line 38 sets default to--upgrade. Please describe--force-reinstallas an optional override example only.✏️ Proposed doc wording
- # Extra arguments passed to pip when reinstalling Python packages with --force-reinstall + # Extra arguments passed to pip when installing Python packages. # By default, packages are upgraded on each playbook run. # Can be overridden, for example: # openwisp2_pip_extra_args: "--upgrade --force-reinstall"As per coding guidelines, "Changes: If the change affects behavior that is already documented, the documentation must be updated to reflect the new behavior".
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@docs/user/role-variables.rst` around lines 34 - 38, The documentation incorrectly implies --force-reinstall is part of default behavior for openwisp2_pip_extra_args; update the description to state that the default value of openwisp2_pip_extra_args is "--upgrade" (packages are upgraded on each playbook run) and mention --force-reinstall only as an optional override example (e.g., openwisp2_pip_extra_args: "--upgrade --force-reinstall") so the docs reflect actual default behavior rather than suggesting force-reinstall is applied by default.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@docs/user/role-variables.rst`:
- Around line 34-38: The documentation incorrectly implies --force-reinstall is
part of default behavior for openwisp2_pip_extra_args; update the description to
state that the default value of openwisp2_pip_extra_args is "--upgrade"
(packages are upgraded on each playbook run) and mention --force-reinstall only
as an optional override example (e.g., openwisp2_pip_extra_args: "--upgrade
--force-reinstall") so the docs reflect actual default behavior rather than
suggesting force-reinstall is applied by default.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: d421369a-1cb6-4428-aafd-6c7db36bfc06
📒 Files selected for processing (3)
defaults/main.ymldocs/user/role-variables.rsttasks/pip.yml
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Build debian12
- GitHub Check: Build ubuntu2204
- GitHub Check: Build ubuntu2404
- GitHub Check: Build debian13
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{md,rst,txt}
📄 CodeRabbit inference engine (Custom checks)
**/*.{md,rst,txt}: Changes: If the change affects behavior that is already documented, the documentation must be updated to reflect the new behavior
Features: Documentation must mention the new feature; for heavily UI-related features, a new section or page is appropriate
Files:
docs/user/role-variables.rst
🔇 Additional comments (2)
defaults/main.yml (1)
237-238: Good default and variable exposure.Introducing
openwisp2_pip_extra_argswith default--upgradeis a clean, backward-compatible way to make reruns upgrade-aware while preserving override flexibility.tasks/pip.yml (1)
46-46: Nice reuse of configurable pip args across requirements installs.The additions consistently parameterize pip
extra_argsin the affected requirement-based tasks, which improves maintainability and supports override scenarios from inventory/group vars.Also applies to: 126-126, 158-158, 177-177, 217-217
Checklist
Reference to Existing Issue
Closes #572
Description of Changes
update the pip.yml file with extra-args:"--upgrade" which make sure that every dependency is updated.