netenglabs / suzieq

Using network observability to operate and design healthier networks
https://www.stardustsystems.net/
Apache License 2.0
792 stars 106 forks source link

path show on suzieq-data returns a weird error #98

Closed jopietsch closed 4 years ago

jopietsch commented 4 years ago

this is the data from the suzieq-data repository

(suzieq) jpiet@a1:/tmp/pycharm_project_304/suzieq$ python3 suzieq/cli/suzieq-cli  -c ~/suzieq_data.yml path show --src=172.16.1.101 --dest=172.16.253.1 --namespace=dual-evpn
                                               error
0  ERROR: <lambda>() takes 1 positional argument ...
jopietsch commented 4 years ago

weirdly, on the same data (but different dest, path summarize works

- command: path summarize --dest=172.16.2.104 --src=172.16.1.101 --namespace=dual-evpn
    --format=json
  data-directory: /home/jpiet/suzieq-data/cloud-native-data-center-networking/parquet-out
  marks: path summarize
  output: '[{"dual-evpn": 4}, {"dual-evpn": [1, 4, 1]}, {"dual-evpn": 2}, {"dual-evpn":
    2.0}, {"dual-evpn": 6}, {"dual-evpn": 9000}, {"dual-evpn": false}, {"dual-evpn":
    false}]'
jopietsch commented 4 years ago

so does path show on the same dest as the path summarize above

(suzieq) jpiet@a1:/tmp/pycharm_project_304/suzieq$ python3 suzieq/cli/suzieq-cli  -c ~/suzieq_data.yml path show --src=172.16.1.101 --dest=172.16.2.104 --namespace=dual-evpn
    pathid  hopCount  namespace   hostname  ... overlay mtuMatch   mtu               timestamp
0        1         0  dual-evpn  server101  ...   False      NaN  9000 2020-04-22 22:59:21.728
1        1         1  dual-evpn     leaf01  ...   False     True  9000 2020-04-22 22:59:21.728
2        1         2  dual-evpn  server104  ...   False      NaN  9000 2020-04-22 22:59:21.728
3        2         0  dual-evpn  server101  ...   False      NaN  9000 2020-04-22 22:59:21.728
4        2         1  dual-evpn     leaf02  ...   False     True  9000 2020-04-22 22:59:21.728
5        2         2  dual-evpn  server104  ...   False      NaN  9000 2020-04-22 22:59:21.728
6        3         0  dual-evpn  server101  ...   False      NaN  9000 2020-04-22 22:59:21.728
7        3         1  dual-evpn     leaf03  ...   False     True  9000 2020-04-22 22:59:21.728
8        3         2  dual-evpn  server104  ...   False      NaN  9000 2020-04-22 22:59:21.728
9        4         0  dual-evpn  server101  ...   False      NaN  9000 2020-04-22 22:59:21.728
10       4         1  dual-evpn     leaf04  ...   False     True  9000 2020-04-22 22:59:21.728
11       4         2  dual-evpn  server104  ...   False      NaN  9000 2020-04-22 22:59:21.728

[12 rows x 10 columns]
jopietsch commented 4 years ago

when I remove the try/except, the traceback I see is:

(suzieq) jpiet@a1:/tmp/pycharm_project_304/suzieq$ python3 suzieq/cli/suzieq-cli  -c ~/suzieq_data.yml path show --src=172.16.1.101 --dest=172.16.253.1 --namespace=dual-evpn
Error running command: <lambda>() takes 1 positional argument but 4 were given
------------------------------------------------------------
Traceback (most recent call last):
  File "/home/jpiet/.local/share/virtualenvs/suzieq-zI29E9ll/lib/python3.7/site-packages/nubia/internal/cmdbase.py", line 448, in run_cli
    return fn(**kwargs)
  File "/tmp/pycharm_project_304/suzieq/suzieq/cli/sqcmds/PathCmd.py", line 54, in show
    vrf=vrf
  File "/tmp/pycharm_project_304/suzieq/suzieq/sqobjects/path.py", line 337, in get
    for nexthop in self._get_nh_with_peer(host, ivrf, dest):
  File "/tmp/pycharm_project_304/suzieq/suzieq/sqobjects/path.py", line 236, in _get_nh_with_peer
    args=nexthops, axis=1)
  File "/home/jpiet/.local/share/virtualenvs/suzieq-zI29E9ll/lib/python3.7/site-packages/pandas/core/frame.py", line 6878, in apply
    return op.get_result()
  File "/home/jpiet/.local/share/virtualenvs/suzieq-zI29E9ll/lib/python3.7/site-packages/pandas/core/apply.py", line 186, in get_result
    return self.apply_standard()
  File "/home/jpiet/.local/share/virtualenvs/suzieq-zI29E9ll/lib/python3.7/site-packages/pandas/core/apply.py", line 313, in apply_standard
    results, res_index = self.apply_series_generator()
  File "/home/jpiet/.local/share/virtualenvs/suzieq-zI29E9ll/lib/python3.7/site-packages/pandas/core/apply.py", line 341, in apply_series_generator
    results[i] = self.f(v)
  File "/home/jpiet/.local/share/virtualenvs/suzieq-zI29E9ll/lib/python3.7/site-packages/pandas/core/apply.py", line 113, in f
    return func(x, *args, **kwds)
TypeError: <lambda>() takes 1 positional argument but 4 were given

the problem is in sqobjects/path starting at line 234

                df.apply(lambda x: nexthops.append((iface, x['hostname'],
                                                    x['ifname'],  overlay))
                         if (x['namespace'] in self.namespace) else None,
                         args=nexthops, axis=1)

I don't know what this is trying to do, but it isn't doing it. It's not capturing the work it's doing, plus the args=nexthops means that you are applying multiple arguments to lambda, which is what the error is. I don't understand the logic this deep so I'm not sure how to fix it.