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

KeyError: 'alias' when we try to use "show" command after shut / unshut the interface using config interface [InterfaceName] [shutdown | startup] #268

Closed
chaitanc opened this issue Oct 22, 2018 · 12 comments
Assignees
Labels

Comments

@chaitanc
Copy link

chaitanc commented Oct 22, 2018

Observed below error log when I try to use the "show" command after shut / unshut the interface using

config interface [InterfaceName] [shutdown | startup]

  1. After loading latest build, tried to check the interface status using show interface status command. Observed that interface list showing fine.
  2. Now shutdown | startup the Ethernet20 interface using config interface Ethernet20 [shutdown | startup] command.
  3. Observed that interface status changing as per the provided command.
  4. Now tried to see the interface status again, observed below error log
root@sonic-testing:/home/admin# show interface status
Traceback (most recent call last):
  File "/usr/bin/show", line 9, in <module>
    load_entry_point('sonic-utilities==1.2', 'console_scripts', 'show')()
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 561, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2631, in load_entry_point
    return ep.load()
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2291, in load
    return self.resolve()
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2297, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/python2.7/dist-packages/show/main.py", line 193, in <module>
    iface_alias_converter = InterfaceAliasConverter()
  File "/usr/lib/python2.7/dist-packages/show/main.py", line 58, in __init__
    self.port_dict[port_name]['alias']):
KeyError: 'alias'

From this point, getting same error log for all show commands. Tried few for reference

root@sonic-testing:/home/admin# show version
Traceback (most recent call last):
  File "/usr/bin/show", line 9, in <module>
    load_entry_point('sonic-utilities==1.2', 'console_scripts', 'show')()
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 561, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2631, in load_entry_point
    return ep.load()
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2291, in load
    return self.resolve()
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2297, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/python2.7/dist-packages/show/main.py", line 193, in <module>
    iface_alias_converter = InterfaceAliasConverter()
  File "/usr/lib/python2.7/dist-packages/show/main.py", line 58, in __init__
    self.port_dict[port_name]['alias']):
KeyError: 'alias'
root@sonic-testing:/home/admin# show acl table
Traceback (most recent call last):
  File "/usr/bin/show", line 9, in <module>
    load_entry_point('sonic-utilities==1.2', 'console_scripts', 'show')()
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 561, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2631, in load_entry_point
    return ep.load()
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2291, in load
    return self.resolve()
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2297, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/python2.7/dist-packages/show/main.py", line 193, in <module>
    iface_alias_converter = InterfaceAliasConverter()
  File "/usr/lib/python2.7/dist-packages/show/main.py", line 58, in __init__
    self.port_dict[port_name]['alias']):
KeyError: 'alias'
root@sonic-testing:/home/admin# show acl rule
Traceback (most recent call last):
  File "/usr/bin/show", line 9, in <module>
    load_entry_point('sonic-utilities==1.2', 'console_scripts', 'show')()
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 561, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2631, in load_entry_point
    return ep.load()
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2291, in load
    return self.resolve()
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2297, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/python2.7/dist-packages/show/main.py", line 193, in <module>
    iface_alias_converter = InterfaceAliasConverter()
  File "/usr/lib/python2.7/dist-packages/show/main.py", line 58, in __init__
    self.port_dict[port_name]['alias']):
KeyError: 'alias'

This error log is getting cleared when we do config reload or reboot. This is a blocker, even though we have an workaround which is time consuming.

SONIC Version:

root@sonic-testing:/home/admin# show version
SONiC Software Version: SONiC.HEAD.748-dirty-20181021.115113
Distribution: Debian 9.5
Kernel: 4.9.0-7-amd64
Build commit: 5c65c77
Build date: Sun Oct 21 14:57:29 UTC 2018
Built by: johnar@jenkins-worker-3
@jleveque
Copy link
Contributor

A couple questions:

  1. Do the show commands work as expected before you shutdown/startup the interface?
  2. Do you have an alias column specified in your port_config.ini file?

P.S. I modified your original post to format the output for easier reading.

@chaitanc
Copy link
Author

Yes, show command is working fine before shutdown / startup the interface.

Yes, I have alias column in my port_config.ini file, see below snippet of my port_config.ini file.

# name          lanes             alias
Ethernet0       29,30,31,32       fortyGigE0/0
Ethernet4       25,26,27,28       fortyGigE0/4
Ethernet8       37,38,39,40       fortyGigE0/8
Ethernet12      33,34,35,36       fortyGigE0/12
Ethernet16      41,42,43,44       fortyGigE0/16
Ethernet20      45,46,47,48       fortyGigE0/20
Ethernet24      5,6,7,8           fortyGigE0/24
Ethernet28      1,2,3,4           fortyGigE0/28
Ethernet32      9,10,11,12        fortyGigE0/32
Ethernet36      13,14,15,16       fortyGigE0/36
Ethernet40      21,22,23,24       fortyGigE0/40
Ethernet44      17,18,19,20       fortyGigE0/44
Ethernet48      49,50,51,52       fortyGigE0/48
Ethernet52      53,54,55,56       fortyGigE0/52
Ethernet56      61,62,63,64       fortyGigE0/56
Ethernet60      57,58,59,60       fortyGigE0/60
Ethernet64      65,66,67,68       fortyGigE0/64
Ethernet68      69,70,71,72       fortyGigE0/68
Ethernet72      77,78,79,80       fortyGigE0/72

@vemulabalaji
Copy link

I tried on mellanox target, and it's working fine.

root@test-bed-1:#
root@test-bed-1:
# show interface status
Interface Lanes Speed MTU Alias Oper Admin


Ethernet0 0 25G N/A Ethernet0 down N/A
Ethernet4 4 25G N/A Ethernet4 down N/A
Ethernet8 8 25G N/A Ethernet8 down N/A
Ethernet12 12 25G N/A Ethernet12 down N/A
Ethernet16 16 25G N/A Ethernet16 down N/A
Ethernet20 20 25G N/A Ethernet20 down N/A
Ethernet24 24 25G N/A Ethernet24 down N/A
Ethernet28 28 25G N/A Ethernet28 down N/A
Ethernet32 32 25G N/A Ethernet32 down N/A
Ethernet36 36 25G N/A Ethernet36 down N/A
Ethernet40 40 25G N/A Ethernet40 down N/A
Ethernet44 44 25G N/A Ethernet44 down N/A
Ethernet48 48 25G N/A Ethernet48 down N/A
Ethernet52 52 25G N/A Ethernet52 down N/A
Ethernet56 56 25G N/A Ethernet56 down N/A
Ethernet60 60 25G N/A Ethernet60 down N/A
Ethernet64 64 25G N/A Ethernet64 down N/A
Ethernet68 68 25G N/A Ethernet68 down N/A
Ethernet72 72 25G N/A Ethernet72 down N/A
Ethernet76 76 25G N/A Ethernet76 down N/A
Ethernet80 80 25G N/A Ethernet80 down N/A
Ethernet84 84 25G N/A Ethernet84 down N/A
Ethernet88 88 25G N/A Ethernet88 down N/A
Ethernet92 92 25G N/A Ethernet92 down N/A
Ethernet96 96 25G N/A Ethernet96 down N/A
Ethernet100 100 25G N/A Ethernet100 down N/A
Ethernet104 104 25G N/A Ethernet104 down N/A
Ethernet108 108 25G N/A Ethernet108 down N/A
Ethernet112 112 25G N/A Ethernet112 down N/A
Ethernet116 116 25G N/A Ethernet116 down N/A
Ethernet120 120 25G N/A Ethernet120 down N/A
Ethernet124 124 25G N/A Ethernet124 down N/A
Ethernet128 128 25G N/A Ethernet128 down N/A
Ethernet132 132 25G N/A Ethernet132 down N/A
Ethernet136 136 25G N/A Ethernet136 down N/A
Ethernet140 140 25G N/A Ethernet140 down N/A
Ethernet144 144 25G N/A Ethernet144 down N/A
Ethernet148 148 25G N/A Ethernet148 down N/A
Ethernet152 152 25G N/A Ethernet152 down N/A
Ethernet156 156 25G N/A Ethernet156 down N/A
Ethernet160 160 25G N/A Ethernet160 down N/A
Ethernet164 164 25G N/A Ethernet164 down N/A
Ethernet168 168 25G N/A Ethernet168 down N/A
Ethernet172 172 25G N/A Ethernet172 down N/A
Ethernet176 176 25G N/A Ethernet176 down N/A
Ethernet180 180 25G N/A Ethernet180 down N/A
Ethernet184 184 25G N/A Ethernet184 down N/A
Ethernet188 188 25G N/A Ethernet188 down N/A
Ethernet192 192,193,194,195 100G N/A Ethernet192 down N/A
Ethernet196 196,197,198,199 100G N/A Ethernet196 down N/A
Ethernet200 200,201,202,203 100G N/A Ethernet200 down N/A
Ethernet204 204,205,206,207 100G N/A Ethernet204 down N/A
Ethernet208 208,209,210,211 100G N/A Ethernet208 down N/A
Ethernet212 212,213,214,215 100G N/A Ethernet212 down N/A
Ethernet216 216,217,218,219 100G N/A Ethernet216 down N/A
Ethernet220 220,221,222,223 100G N/A Ethernet220 down N/A
root@test-bed-1:# config interface Ethernet40 shutdown
root@test-bed-1:
# show interface status
Interface Lanes Speed MTU Alias Oper Admin


Ethernet0 0 25G N/A Ethernet0 down N/A
Ethernet4 4 25G N/A Ethernet4 down N/A
Ethernet8 8 25G N/A Ethernet8 down N/A
Ethernet12 12 25G N/A Ethernet12 down N/A
Ethernet16 16 25G N/A Ethernet16 down N/A
Ethernet20 20 25G N/A Ethernet20 down N/A
Ethernet24 24 25G N/A Ethernet24 down N/A
Ethernet28 28 25G N/A Ethernet28 down N/A
Ethernet32 32 25G N/A Ethernet32 down N/A
Ethernet36 36 25G N/A Ethernet36 down N/A
Ethernet40 40 25G N/A Ethernet40 down down
Ethernet44 44 25G N/A Ethernet44 down N/A
Ethernet48 48 25G N/A Ethernet48 down N/A
Ethernet52 52 25G N/A Ethernet52 down N/A
Ethernet56 56 25G N/A Ethernet56 down N/A
Ethernet60 60 25G N/A Ethernet60 down N/A
Ethernet64 64 25G N/A Ethernet64 down N/A
Ethernet68 68 25G N/A Ethernet68 down N/A
Ethernet72 72 25G N/A Ethernet72 down N/A
Ethernet76 76 25G N/A Ethernet76 down N/A
Ethernet80 80 25G N/A Ethernet80 down N/A
Ethernet84 84 25G N/A Ethernet84 down N/A
Ethernet88 88 25G N/A Ethernet88 down N/A
Ethernet92 92 25G N/A Ethernet92 down N/A
Ethernet96 96 25G N/A Ethernet96 down N/A
Ethernet100 100 25G N/A Ethernet100 down N/A
Ethernet104 104 25G N/A Ethernet104 down N/A
Ethernet108 108 25G N/A Ethernet108 down N/A
Ethernet112 112 25G N/A Ethernet112 down N/A
Ethernet116 116 25G N/A Ethernet116 down N/A
Ethernet120 120 25G N/A Ethernet120 down N/A
Ethernet124 124 25G N/A Ethernet124 down N/A
Ethernet128 128 25G N/A Ethernet128 down N/A
Ethernet132 132 25G N/A Ethernet132 down N/A
Ethernet136 136 25G N/A Ethernet136 down N/A
Ethernet140 140 25G N/A Ethernet140 down N/A
Ethernet144 144 25G N/A Ethernet144 down N/A
Ethernet148 148 25G N/A Ethernet148 down N/A
Ethernet152 152 25G N/A Ethernet152 down N/A
Ethernet156 156 25G N/A Ethernet156 down N/A
Ethernet160 160 25G N/A Ethernet160 down N/A
Ethernet164 164 25G N/A Ethernet164 down N/A
Ethernet168 168 25G N/A Ethernet168 down N/A
Ethernet172 172 25G N/A Ethernet172 down N/A
Ethernet176 176 25G N/A Ethernet176 down N/A
Ethernet180 180 25G N/A Ethernet180 down N/A
Ethernet184 184 25G N/A Ethernet184 down N/A
Ethernet188 188 25G N/A Ethernet188 down N/A
Ethernet192 192,193,194,195 100G N/A Ethernet192 down N/A
Ethernet196 196,197,198,199 100G N/A Ethernet196 down N/A
Ethernet200 200,201,202,203 100G N/A Ethernet200 down N/A
Ethernet204 204,205,206,207 100G N/A Ethernet204 down N/A
Ethernet208 208,209,210,211 100G N/A Ethernet208 down N/A
Ethernet212 212,213,214,215 100G N/A Ethernet212 down N/A
Ethernet216 216,217,218,219 100G N/A Ethernet216 down N/A
Ethernet220 220,221,222,223 100G N/A Ethernet220 down N/A
root@test-bed-1:~#

@vemulabalaji
Copy link

root@test-bed-1:~# show version
SONiC Software Version: SONiC.master.0-dirty-20181107.174143
Distribution: Debian 9.5
Kernel: 4.9.0-7-amd64
Build commit: 1bc8e4b
Build date: Wed Nov 7 17:10:31 UTC 2018

@chaitanc
Copy link
Author

I am having this issue on DELL S 6000 device.

@jleveque
Copy link
Contributor

Should be fixed with sonic-net/sonic-utilities#362.

PR open here: sonic-net/sonic-buildimage#2252 to update the sonic-utilites submodule. Once this PR is merged, please check again and provide your feedback.

@jleveque
Copy link
Contributor

@chaitanc: The PR has been merged. Can you please try imaging with a new build from the head of the master branch and confirm this is fixed for you?

@chaitanc
Copy link
Author

chaitanc commented Nov 19, 2018

Verified on build:

root@sonic-testing:/home/admin#
root@sonic-testing:/home/admin# show version
SONiC Software Version: SONiC.HEAD.778-0b3a885
Distribution: Debian 9.6
Kernel: 4.9.0-7-amd64
Build commit: 0b3a885
Build date: Sun Nov 18 10:29:43 UTC 2018
Built by: johnar@jenkins-worker-3

Issue not seen.

Hence closing the issue.

@chaitanc
Copy link
Author

chaitanc commented Jan 2, 2019

Issue observed in below scenario

  1. Shutdown / startup non existing interface.
  2. Check interface status using show interface status command. Below error will be seen

root@AG9032V1-Leaf-23:~# show interface status
Traceback (most recent call last):
File "/usr/bin/show", line 9, in
load_entry_point('sonic-utilities==1.2', 'console_scripts', 'show')()
File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 561, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 2631, in load_entry_point
return ep.load()
File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 2291, in load
return self.resolve()
File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 2297, in resolve
module = import(self.module_name, fromlist=['name'], level=0)
File "/usr/lib/python2.7/dist-packages/show/main.py", line 199, in
iface_alias_converter = InterfaceAliasConverter()
File "/usr/lib/python2.7/dist-packages/show/main.py", line 64, in init
self.port_dict[port_name]['alias']):
KeyError: 'alias'

TO BE DONE:

  1. Application should not allow any operations on non-existing interfaces.
  2. If it is not following the step 1 then application should not throw this error.

Hence reopening the issue.

@chaitanc chaitanc reopened this Jan 2, 2019
@kirankella
Copy link
Contributor

Though the interface name is invalid, the interface is getting added into the PORT_TABLE in Config DB, with admin status attribute only. Later during show commands when we query the PORT_TABLE it is throwing error on missing alias.

We should prevent adding invalid interface names into the PORT_TABLE during config commands.
The following fix worked. It throws an error to the user prompting to enter a valid interface name.
The callers of the interface_name_to_alias() function should handle the error return value.

==========
--- a/config/main.py
+++ b/config/main.py
@@ -99,7 +99,6 @@ def interface_name_to_alias(interface_name):
for port_name in natsorted(port_dict.keys()):
if interface_name == port_name:
return port_dict[port_name]['alias']

  •    click.echo("Invalid interface {}".format(interface_alias))
    

    return None

@@ -823,6 +822,10 @@ def startup(ctx):
config_db = ctx.obj['config_db']
interface_name = ctx.obj['interface_name']

  • alias = interface_name_to_alias(interface_name)

  • if alias is None:

  •    ctx.fail("Enter valid interface name!!")
    
  • if interface_name.startswith("Ethernet"):
    config_db.mod_entry("PORT", interface_name, {"admin_status": "up"})
    elif interface_name.startswith("PortChannel"):
    @@ -838,6 +841,10 @@ def shutdown(ctx):
    config_db = ctx.obj['config_db']
    interface_name = ctx.obj['interface_name']

  • alias = interface_name_to_alias(interface_name)

  • if alias is None:

  •    ctx.fail("Enter valid interface name!!")
    
  • if interface_name.startswith("Ethernet"):
    config_db.mod_entry("PORT", interface_name, {"admin_status": "down"})
    elif interface_name.startswith("PortChannel"):
    ==========

@kirankella
Copy link
Contributor

Hi Joe, I am submitting the config prevention fix (error checking) as mentioned above as part of pull request sonic-net/sonic-utilities#424

@jleveque
Copy link
Contributor

Fixed by sonic-net/sonic-utilities#424

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants