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

[DPB] show interface breakout throws error when BREAKOUT_CFG table not present #7957

Open
alexrallen opened this issue Jun 23, 2021 · 2 comments

Comments

@alexrallen
Copy link
Contributor

When the user upgrades from a previous version of SONiC such as 202012 the table BREAKOUT_CFG is not automatically imported which is required for certain dynamic port breakout commands to function such as show interface breakout and config interface breakout

While the absence of BREAKOUT_CFG is an intentional design decision (see this comment on #7402) these commands are present and should elegantly handle error and inform the end user they should run config reload -l in order to enable this feature on an upgraded switch.

Experienced Result

admin@r-bulldog-03:~$ show int break
Traceback (most recent call last):
  File "/usr/local/bin/show", line 8, in
    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 1114, in invoke
    return Command.invoke(self, 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/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/show/interfaces/__init__.py", line 204, in breakout
    cur_brkout_mode = cur_brkout_tbl[port_name]["brkout_mode"]
KeyError: 'Ethernet0'

Desired Result

Some type of human readable error message.
e.g. CONFIG_DB does not contain the required information to complete this action please run config reload -l to import this from the platform files to enable dynamic breakout features

Version

SONiC Software Version: SONiC.master.140-a4b31fcb7_Internal
Distribution: Debian 10.9
Kernel: 4.19.0-12-2-amd64
Build commit: a4b31fcb7
Build date: Mon Jun 14 15:31:01 UTC 2021
Built by: sw-r2d2-bot@r-build-sonic-ci02

Platform: x86_64-mlnx_msn4700-r0
HwSKU: ACS-MSN4700
ASIC: mellanox
ASIC Count: 1
Serial Number: MT2022X08597
Uptime: 21:11:29 up 16:58,  3 users,  load average: 0.32, 0.25, 0.26

Docker images:
REPOSITORY                                        TAG                             IMAGE ID            SIZE
harbor.mellanox.com/sonic-lc-manager/lc-manager   0.0.6                           07dab0396238        554MB
docker-syncd-mlnx                                 latest                          41d9f031f17d        670MB
docker-syncd-mlnx                                 master.140-a4b31fcb7_Internal   41d9f031f17d        670MB
docker-snmp                                       latest                          93bd11cff0c5        454MB
docker-snmp                                       master.140-a4b31fcb7_Internal   93bd11cff0c5        454MB
docker-teamd                                      latest                          39519881ce7e        423MB
docker-teamd                                      master.140-a4b31fcb7_Internal   39519881ce7e        423MB
docker-nat                                        latest                          094f94d8687c        426MB
docker-nat                                        master.140-a4b31fcb7_Internal   094f94d8687c        426MB
docker-router-advertiser                          latest                          d31730f2d8a1        412MB
docker-router-advertiser                          master.140-a4b31fcb7_Internal   d31730f2d8a1        412MB
docker-platform-monitor                           latest                          6708eb3468f2        701MB
docker-platform-monitor                           master.140-a4b31fcb7_Internal   6708eb3468f2        701MB
docker-lldp                                       latest                          e699b0e15f80        452MB
docker-lldp                                       master.140-a4b31fcb7_Internal   e699b0e15f80        452MB
docker-dhcp-relay                                 latest                          9139ad1c1bfc        419MB
docker-dhcp-relay                                 master.140-a4b31fcb7_Internal   9139ad1c1bfc        419MB
docker-database                                   latest                          7dcb114a2d7a        412MB
docker-database                                   master.140-a4b31fcb7_Internal   7dcb114a2d7a        412MB
docker-orchagent                                  latest                          9f289a7b96c3        442MB
docker-orchagent                                  master.140-a4b31fcb7_Internal   9f289a7b96c3        442MB
docker-macsec                                     latest                          0ddeec697dbc        426MB
docker-macsec                                     master.140-a4b31fcb7_Internal   0ddeec697dbc        426MB
docker-sonic-telemetry                            latest                          4e07a8ec7a64        501MB
docker-sonic-telemetry                            master.140-a4b31fcb7_Internal   4e07a8ec7a64        501MB
docker-sonic-mgmt-framework                       latest                          52b04ff3a071        570MB
docker-sonic-mgmt-framework                       master.140-a4b31fcb7_Internal   52b04ff3a071        570MB
docker-fpm-frr                                    latest                          1aa221bda051        441MB
docker-fpm-frr                                    master.140-a4b31fcb7_Internal   1aa221bda051        441MB
docker-sflow                                      latest                          1540482a009e        424MB
docker-sflow                                      master.140-a4b31fcb7_Internal   1540482a009e        424MB
docker-sonic-restapi                              latest                          6f4fdb26f843        355MB
docker-sonic-restapi                              master.140-a4b31fcb7_Internal   6f4fdb26f843        355MB
@zhangyanzhao
Copy link
Collaborator

@zhenggen-xu please evaluate this suggestion to improve the error message. Thanks.

@zhenggen-xu
Copy link
Collaborator

@samaity Please take a look.

qiluo-msft pushed a commit to sonic-net/sonic-utilities that referenced this issue Dec 24, 2021
…le (#1765)

#### What I did

This PR fixed issue for [show interface breakout](sonic-net/sonic-buildimage#7957) issue

**Before this fix**
removed `Ethernet60` from breakout_cfg table for unit testing and got the issue
```
 
admin@lnos-x1-a-asw04:~$ sudo redis-cli -n 4 del "BREAKOUT_CFG|Ethernet60"
(integer) 1
admin@lnos-x1-a-asw04:~$ sudo redis-cli -n 4 hgetall "BREAKOUT_CFG|Ethernet60"
(empty array)
admin@lnos-x1-a-asw04:~$ show int breakout
Traceback (most recent call last):
  File "/usr/local/bin/show", line 8, 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 1114, in invoke
    return Command.invoke(self, 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/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/show/interfaces/__init__.py", line 181, in breakout
    cur_brkout_mode = cur_brkout_tbl[port_name]["brkout_mode"]
KeyError: 'Ethernet60'

```

**After the fix**
```

admin@lnos-x1-a-asw04:~$ show int breakout current-mode Ethernet60
+-------------+-------------------------+
| Interface   | Current Breakout Mode   |
+=============+=========================+
| Ethernet60  | Not Available           |
+-------------+-------------------------+
```
#### How I did it
Gracefully handle the error when port/interface is not present in `BREAKOUT_CFG` table.

#### How to verify it
```
show interface breakout 
show int interface current-mode

```
**_Added unit test case for negetive Test case_**
judyjoseph pushed a commit to sonic-net/sonic-utilities that referenced this issue Jan 9, 2022
…le (#1765)

#### What I did

This PR fixed issue for [show interface breakout](sonic-net/sonic-buildimage#7957) issue

**Before this fix**
removed `Ethernet60` from breakout_cfg table for unit testing and got the issue
```
 
admin@lnos-x1-a-asw04:~$ sudo redis-cli -n 4 del "BREAKOUT_CFG|Ethernet60"
(integer) 1
admin@lnos-x1-a-asw04:~$ sudo redis-cli -n 4 hgetall "BREAKOUT_CFG|Ethernet60"
(empty array)
admin@lnos-x1-a-asw04:~$ show int breakout
Traceback (most recent call last):
  File "/usr/local/bin/show", line 8, 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 1114, in invoke
    return Command.invoke(self, 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/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/show/interfaces/__init__.py", line 181, in breakout
    cur_brkout_mode = cur_brkout_tbl[port_name]["brkout_mode"]
KeyError: 'Ethernet60'

```

**After the fix**
```

admin@lnos-x1-a-asw04:~$ show int breakout current-mode Ethernet60
+-------------+-------------------------+
| Interface   | Current Breakout Mode   |
+=============+=========================+
| Ethernet60  | Not Available           |
+-------------+-------------------------+
```
#### How I did it
Gracefully handle the error when port/interface is not present in `BREAKOUT_CFG` table.

#### How to verify it
```
show interface breakout 
show int interface current-mode

```
**_Added unit test case for negetive Test case_**
malletvapid23 added a commit to malletvapid23/Sonic-Utility that referenced this issue Aug 3, 2023
…le (#1765)

#### What I did

This PR fixed issue for [show interface breakout](sonic-net/sonic-buildimage#7957) issue

**Before this fix**
removed `Ethernet60` from breakout_cfg table for unit testing and got the issue
```
 
admin@lnos-x1-a-asw04:~$ sudo redis-cli -n 4 del "BREAKOUT_CFG|Ethernet60"
(integer) 1
admin@lnos-x1-a-asw04:~$ sudo redis-cli -n 4 hgetall "BREAKOUT_CFG|Ethernet60"
(empty array)
admin@lnos-x1-a-asw04:~$ show int breakout
Traceback (most recent call last):
  File "/usr/local/bin/show", line 8, 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 1114, in invoke
    return Command.invoke(self, 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/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/show/interfaces/__init__.py", line 181, in breakout
    cur_brkout_mode = cur_brkout_tbl[port_name]["brkout_mode"]
KeyError: 'Ethernet60'

```

**After the fix**
```

admin@lnos-x1-a-asw04:~$ show int breakout current-mode Ethernet60
+-------------+-------------------------+
| Interface   | Current Breakout Mode   |
+=============+=========================+
| Ethernet60  | Not Available           |
+-------------+-------------------------+
```
#### How I did it
Gracefully handle the error when port/interface is not present in `BREAKOUT_CFG` table.

#### How to verify it
```
show interface breakout 
show int interface current-mode

```
**_Added unit test case for negetive Test case_**
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants