Skip to content

[show/fgnhg] Fix crash bug#1272

Merged
jleveque merged 1 commit intosonic-net:masterfrom
jleveque:fix_fgnhg_bugs
Dec 1, 2020
Merged

[show/fgnhg] Fix crash bug#1272
jleveque merged 1 commit intosonic-net:masterfrom
jleveque:fix_fgnhg_bugs

Conversation

@jleveque
Copy link
Contributor

@jleveque jleveque commented Nov 25, 2020

- What I did

Fix crashes like the following:

Traceback (most recent call last):
  File "/usr/local/bin/show", line 10, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/show/fgnhg.py", line 56, in active_hops
    click.echo(tabulate(table, header, tablefmt="grid"))
UnboundLocalError: local variable 'header' referenced before assignment

- How I did it

Define table header outside the loop which processes the rows

- How to verify it

Run the following commands, confirm they don't crash like above:

show fgnhg active-hops
show fgnhg hash-view

Example output with this fix:

admin@sonic:~$ show fgnhg active-hops
+-----------------+--------------------+
| FG_NHG_PREFIX   | Active Next Hops   |
+=================+====================+
+-----------------+--------------------+

admin@sonic:~$ show fgnhg hash-view
+-----------------+------------+----------------+
| FG_NHG_PREFIX   | Next Hop   | Hash buckets   |
+=================+============+================+
+-----------------+------------+----------------+

@kktheballer
Copy link
Contributor

retest this please

@jleveque
Copy link
Contributor Author

Retest this please

@jleveque jleveque merged commit a4f663e into sonic-net:master Dec 1, 2020
@jleveque jleveque deleted the fix_fgnhg_bugs branch December 1, 2020 00:57
stepanblyschak pushed a commit to stepanblyschak/sonic-utilities that referenced this pull request Apr 28, 2022
[routeorch] Handle the empty "nexthop" field for backward compatibility (sonic-net#1263)
[vnet] Set MTU for the VNET bridge RIF in BITMAP implementation (sonic-net#1271)
 [vnet] Verify if BITMAP route exists before creating new one to avoid
 dublication (sonic-net#1272)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants