Forward unlink option to request-package-add RPC#1412
Draft
shigechika wants to merge 2 commits into
Draft
Conversation
Add an explicit unlink keyword argument to SW.install() that is forwarded to the underlying request-package-add RPC so that <unlink/> appears in the request, matching the behavior of the "request system software add ... unlink" CLI option. Useful for low-flash devices (e.g. EX2300, EX3400) where major version upgrades may fail with "ERROR: insufficient space" during validation because the package tarball remains on disk while its contents are being expanded. With unlink, the tarball is removed during pkgadd, reducing peak filesystem usage. Related to issue Juniper#990. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Add test_sw_install_without_unlink verifying that the default (unlink=False) does not emit <unlink/>, guarding against future regressions. - Note in the docstring that unlink is intended for non-vmhost devices, since "request vmhost package add" does not document an unlink option. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add an explicit
unlinkkeyword argument toSW.install()that is forwarded to the underlyingrequest-package-addRPC so that<unlink/>appears in the request, matching the behavior of therequest system software add ... unlinkCLI option.Motivation
On low-flash devices such as EX2300 and EX3400 (
/dev/gpt/junos= 1.3 GB), major version JUNOS upgrades (e.g. 22.4 → 23.4) may fail at the validation stage with:The root cause is that PyEZ's default
SW.install()path issues arequest-package-addRPC without the<unlink/>element. The validation phase expands the tarball into/packages/db/...while the original.tgzstill occupies space in/var/tmp, causing the peak usage to exceed the available filesystem space.When
request system software add ... unlinkis invoked from the JUNOS CLI, the tarball is removed during pkgadd, reducing peak usage and letting the upgrade complete. This patch lets PyEZ callers reproduce that behavior.RPC schema verification
I verified on a JUNOS 22.4 device (EX-family) that
unlinkis a valid sibling element ofrequest-package-add, independent ofno-copy/no-validate:Changes
lib/jnpr/junos/utils/sw.pySW.install()gains a newunlink: bool = Falsekeyword argument.unlink=True, the option is injected intokwargsbeforepkgadd()is invoked, so every call site ininstall()(single RE, multi RE, VC, ISSU/NSSU, mixed VC, etc.) propagates it identically to other passthrough options likerouting_instance.tests/unit/utils/test_sw.pytest_sw_install_with_unlinkverifies thatinstall(no_copy=True, unlink=True)produces a<unlink/>element in the resulting RPC, mirroring the existingtest_sw_install_with_routing_instancestyle. Existing tests are left untouched.Backward compatibility:
unlink=Falseis the default and existing call sites are unaffected. All 127 unit tests intests/unit/utils/test_sw.pypass.Related
no-copyargument not passed further to RPC). I deliberately scoped this PR tounlinkonly to keep the diff minimal and the change uncontroversial; reusinginstall(no_copy=True)to also emit<no-copy/>would be a behavior change of an existing parameter and would require updating the order-permutation assertions intest_sw_install_kwargs_force_host. Happy to follow up in a separate PR if maintainers prefer that direction.Test plan
pytest tests/unit/utils/test_sw.py— 127 passed locally<unlink/>element appears in the generated RPC via mock execute| display xml rpc🤖 Generated with Claude Code