Skip to content

Fix Junos timeout wrappers crashing on dev_timeout=None (#58108)#69789

Open
ggiesen wants to merge 1 commit into
saltstack:3006.xfrom
ggiesen:fix-58108-junos-timeout
Open

Fix Junos timeout wrappers crashing on dev_timeout=None (#58108)#69789
ggiesen wants to merge 1 commit into
saltstack:3006.xfrom
ggiesen:fix-58108-junos-timeout

Conversation

@ggiesen

@ggiesen ggiesen commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes the Junos timeout wrappers crashing when no timeout is requested.

napalm.junos_cli (and other napalm/junos calls) default dev_timeout to
None and forward it. The _timeout_decorator / _timeout_decorator_cleankwargs
wrappers in salt/modules/junos.py treated a present-but-None dev_timeout
as a real value:

if "dev_timeout" in kwargs or "timeout" in kwargs:
    ldev_timeout = max(kwargs.pop("dev_timeout", 0), kwargs.pop("timeout", 0))

so max(None, 0) raised TypeError: '>' not supported between instances of 'int' and 'NoneType' (and older junos-eznc raised RuntimeError: could not convert timeout value of None to an integer from conn.timeout = None).

The wrappers now coalesce None to 0 and only override the connection timeout
when a real (>0) dev_timeout/timeout is given; otherwise the call runs with
the connection's default timeout. An explicit dev_timeout/timeout is still
honoured.

What issues does this PR fix or reference?

Fixes #58108

This addresses the first (and reproducible) part of #58108 -- napalm.junos_cli "show version" failing with a timeout exception. It also makes dev_timeout
actually usable, which is the mechanism for setting a longer device RPC timeout
on slow operations (the second part of the report).

The earlier #63812 removed dev_timeout from junos_cli (which drops the
ability to set a per-call timeout); this instead makes dev_timeout work.

Previous Behavior

salt '*' napalm.junos_cli "show version"
    The minion function caused an exception: ... could not convert timeout
    value of None to an integer

(current tree: TypeError: '>' not supported between instances of 'int' and 'NoneType'.)

New Behavior

napalm.junos_cli "show version" runs with the connection's default timeout;
napalm.junos_cli "show version" dev_timeout=120 runs with a 120s device
timeout.

Merge requirements satisfied?

  • Docs
  • Changelog
  • Tests written/updated

tests/pytests/unit/modules/test_junos.py::test__timeout_decorator_none_dev_timeout
calls both wrappers with dev_timeout=None and asserts they do not raise and do
not touch the connection timeout. It fails against the current code with the
TypeError above. The existing test__timeout_decorator /
test__timeout_cleankwargs_decorator (explicit dev_timeout=10) still pass, so
a real timeout is still applied.

Commits signed with GPG?

No

)

napalm.junos_cli defaults dev_timeout to None and forwards it, so the Junos
_timeout_decorator / _timeout_decorator_cleankwargs wrappers hit
max(None, 0) -- which raises TypeError -- and would otherwise try to set the
junos-eznc connection timeout to None, which it rejects.

Coalesce None to 0 when computing the effective timeout, and only override the
connection timeout when a real (>0) dev_timeout/timeout is given; otherwise run
the command with the connection's default timeout. This makes junos_cli and the
other timeout-decorated calls work when no timeout is passed, while still
honouring an explicit dev_timeout/timeout.
@ggiesen ggiesen requested a review from a team as a code owner July 12, 2026 00:25
@ggiesen

ggiesen commented Jul 12, 2026

Copy link
Copy Markdown
Contributor Author

Confirmed on real hardware (a live Juniper EX3400, Junos 23.4R2-S5.8) via a napalm Junos proxy:

Before (current 3006.x):

# salt sw01 napalm.junos_cli "show version"
sw01:
    Passed invalid arguments to napalm.junos_cli: '>' not supported between instances of 'int' and 'NoneType'

After (this PR):

# salt sw01 napalm.junos_cli "show version"
sw01:
    ----------
    message:
        fpc0:
        --------------------------------------------------------------------------
        Hostname: sw1.tor1
        Model: ex3400-48p
        Junos: 23.4R2-S5.8
        ...
    out:
        True

And dev_timeout=120 is honoured (sets the NETCONF RPC timeout).

@dwoz dwoz added the test:full Run the full test suite label Jul 12, 2026
@dwoz dwoz requested a deployment to ci July 12, 2026 22:18 — with GitHub Actions Pending
@dwoz dwoz requested a deployment to ci July 12, 2026 22:18 — with GitHub Actions Pending
@dwoz dwoz requested a deployment to ci July 12, 2026 22:18 — with GitHub Actions Pending
@dwoz dwoz requested a deployment to ci July 12, 2026 22:18 — with GitHub Actions Pending
@dwoz dwoz requested a deployment to ci July 12, 2026 22:18 — with GitHub Actions Pending
@dwoz dwoz requested a deployment to ci July 12, 2026 22:18 — with GitHub Actions Pending
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:full Run the full test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants