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

Nornir and Thread Safety Question #23

Open
netdemux opened this issue May 18, 2023 · 0 comments
Open

Nornir and Thread Safety Question #23

netdemux opened this issue May 18, 2023 · 0 comments

Comments

@netdemux
Copy link

Expected Behavior

This is more of a question than an expectation. I'm attempting to use napalm-arubaos-switch with nornir (with multithreading). I'm seeing non-deterministic output and suspect that some part of the arubaoss napalm library is not thread-safe. I think the issue may arise from the way api connections are implemented. If this is the case, I expect it would be no simple task to rewrite; I'd just like to confirm whether I'm on the right track or if there's a gap in my understanding somewhere.

Actual Behavior

When called through Nornir, napalm-arubaos-switch exhibits seemingly non-deterministic behavior. Hosts will return the expected output some of the time, but then return empty dictionaries when the same script is run again immediately after. No errors are logged, no exceptions are raised, and the maximum number of https/rest sessions is not exceeded. The non-deterministic behavior affects all different devices in nornir's hosts.yml file; it is not isolated to one specific host. No host returns expected output 100% of the time.

Steps to Reproduce the Problem

  1. Run a basic Nornir task with napalm_get on two or more hosts with platform="arubaoss"
nr = InitNornir(
        runner={
            "plugin": "threaded",
            "options": {
                "num_workers": 20,
            },
        },
        inventory={

...
<SNIP>
...

)

results = nr.run(
        task=napalm_get,
        getters=["lldp_neighbors"]
)

print_result(results)
nr.close_connections()
  1. Repeat step 1 to see variation in the output.
  2. Edit the script to use a single thread with "num_workers": 1
  3. Note that tasks now consistently return expected results for all hosts

Specifications

  • Version:
    napalm-arubaos-switch 0.2.0
    nornir 3.3.0
    Python 3.10.6
  • Platform: Windows 10 22H2
  • Subsystem: WSL 0.2.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant