KeyError in kuryr-kubernetes

Bug #1890546 reported by Lê Minh Quân
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
kuryr-kubernetes
New
Undecided
Unassigned

Bug Description

I follow setup kuryr-kubernets on openstack and appear this problems

```
Aug 06 07:47:01 k8s-master kuryr-k8s-controller[11961]: 2020-08-06 07:47:01.220 11961 ERROR kuryr_kubernetes.handlers.logging [-] Failed to handle event {'type': 'MODIFIED', 'object': {'kind': 'Pod', 'apiVersion': 'v1', 'metadata': {'name': 'nginx-deployment-57d9684bf8-9tpbz', 'generateName': 'nginx-deployment-57d9684bf8-', 'namespace': 'default', 'selfLink': '/api/v1/name
Aug 06 07:47:01 k8s-master kuryr-k8s-controller[11961]: 2020-08-06 07:47:01.220 11961 ERROR kuryr_kubernetes.handlers.logging Traceback (most recent call last):
Aug 06 07:47:01 k8s-master kuryr-k8s-controller[11961]: 2020-08-06 07:47:01.220 11961 ERROR kuryr_kubernetes.handlers.logging File "/root/kuryr-k8s-controller/kuryr-kubernetes/kuryr_kubernetes/handlers/logging.py", line 37, in __call__
Aug 06 07:47:01 k8s-master kuryr-k8s-controller[11961]: 2020-08-06 07:47:01.220 11961 ERROR kuryr_kubernetes.handlers.logging self._handler(event)
Aug 06 07:47:01 k8s-master kuryr-k8s-controller[11961]: 2020-08-06 07:47:01.220 11961 ERROR kuryr_kubernetes.handlers.logging File "/root/kuryr-k8s-controller/kuryr-kubernetes/kuryr_kubernetes/handlers/retry.py", line 78, in __call__
Aug 06 07:47:01 k8s-master kuryr-k8s-controller[11961]: 2020-08-06 07:47:01.220 11961 ERROR kuryr_kubernetes.handlers.logging self._handler(event)
Aug 06 07:47:01 k8s-master kuryr-k8s-controller[11961]: 2020-08-06 07:47:01.220 11961 ERROR kuryr_kubernetes.handlers.logging File "/root/kuryr-k8s-controller/kuryr-kubernetes/kuryr_kubernetes/handlers/k8s_base.py", line 84, in __call__
Aug 06 07:47:01 k8s-master kuryr-k8s-controller[11961]: 2020-08-06 07:47:01.220 11961 ERROR kuryr_kubernetes.handlers.logging self.on_present(obj)
Aug 06 07:47:01 k8s-master kuryr-k8s-controller[11961]: 2020-08-06 07:47:01.220 11961 ERROR kuryr_kubernetes.handlers.logging File "/root/kuryr-k8s-controller/kuryr-kubernetes/kuryr_kubernetes/controller/handlers/vif.py", line 106, in on_present
Aug 06 07:47:01 k8s-master kuryr-k8s-controller[11961]: 2020-08-06 07:47:01.220 11961 ERROR kuryr_kubernetes.handlers.logging pod, project_id, subnets, security_groups)
Aug 06 07:47:01 k8s-master kuryr-k8s-controller[11961]: 2020-08-06 07:47:01.220 11961 ERROR kuryr_kubernetes.handlers.logging File "/root/kuryr-k8s-controller/kuryr-kubernetes/kuryr_kubernetes/controller/drivers/vif_pool.py", line 1065, in request_vif
Aug 06 07:47:01 k8s-master kuryr-k8s-controller[11961]: 2020-08-06 07:47:01.220 11961 ERROR kuryr_kubernetes.handlers.logging pod, project_id, subnets, security_groups)
Aug 06 07:47:01 k8s-master kuryr-k8s-controller[11961]: 2020-08-06 07:47:01.220 11961 ERROR kuryr_kubernetes.handlers.logging File "/root/kuryr-k8s-controller/kuryr-kubernetes/kuryr_kubernetes/controller/drivers/vif_pool.py", line 115, in request_vif
Aug 06 07:47:01 k8s-master kuryr-k8s-controller[11961]: 2020-08-06 07:47:01.220 11961 ERROR kuryr_kubernetes.handlers.logging security_groups)
Aug 06 07:47:01 k8s-master kuryr-k8s-controller[11961]: 2020-08-06 07:47:01.220 11961 ERROR kuryr_kubernetes.handlers.logging File "/root/kuryr-k8s-controller/kuryr-kubernetes/kuryr_kubernetes/controller/drivers/neutron_vif.py", line 42, in request_vif
Aug 06 07:47:01 k8s-master kuryr-k8s-controller[11961]: 2020-08-06 07:47:01.220 11961 ERROR kuryr_kubernetes.handlers.logging return ovu.neutron_to_osvif_vif(port.binding_vif_type, port, subnets)
Aug 06 07:47:01 k8s-master kuryr-k8s-controller[11961]: 2020-08-06 07:47:01.220 11961 ERROR kuryr_kubernetes.handlers.logging File "/root/kuryr-k8s-controller/kuryr-kubernetes/kuryr_kubernetes/os_vif_util.py", line 435, in neutron_to_osvif_vif
Aug 06 07:47:01 k8s-master kuryr-k8s-controller[11961]: 2020-08-06 07:47:01.220 11961 ERROR kuryr_kubernetes.handlers.logging return mgr.driver(vif_translator, os_port, subnets)
Aug 06 07:47:01 k8s-master kuryr-k8s-controller[11961]: 2020-08-06 07:47:01.220 11961 ERROR kuryr_kubernetes.handlers.logging File "/root/kuryr-k8s-controller/kuryr-kubernetes/kuryr_kubernetes/os_vif_util.py", line 265, in neutron_to_osvif_vif_ovs
Aug 06 07:47:01 k8s-master kuryr-k8s-controller[11961]: 2020-08-06 07:47:01.220 11961 ERROR kuryr_kubernetes.handlers.logging network = _make_vif_network(os_port, subnets)
Aug 06 07:47:01 k8s-master kuryr-k8s-controller[11961]: 2020-08-06 07:47:01.220 11961 ERROR kuryr_kubernetes.handlers.logging File "/root/kuryr-k8s-controller/kuryr-kubernetes/kuryr_kubernetes/os_vif_util.py", line 197, in _make_vif_network
Aug 06 07:47:01 k8s-master kuryr-k8s-controller[11961]: 2020-08-06 07:47:01.220 11961 ERROR kuryr_kubernetes.handlers.logging objects=_make_vif_subnets(neutron_port, subnets))
Aug 06 07:47:01 k8s-master kuryr-k8s-controller[11961]: 2020-08-06 07:47:01.220 11961 ERROR kuryr_kubernetes.handlers.logging File "/root/kuryr-k8s-controller/kuryr-kubernetes/kuryr_kubernetes/os_vif_util.py", line 145, in _make_vif_subnets
Aug 06 07:47:01 k8s-master kuryr-k8s-controller[11961]: 2020-08-06 07:47:01.220 11961 ERROR kuryr_kubernetes.handlers.logging ip_address = neutron_fixed_ip['ip_address']
Aug 06 07:47:01 k8s-master kuryr-k8s-controller[11961]: 2020-08-06 07:47:01.220 11961 ERROR kuryr_kubernetes.handlers.logging KeyError: 'ip_address'
```

Its a python keyerror problems, that make my pod cant be created

Revision history for this message
Michal Dulko (michal-dulko-f) wrote :

Hi,

This is a bit weird, Neutron API reference lists that "ip_address" field should always be there:

> The IP addresses for the port. If the port has multiple IP addresses,
> this field has multiple entries. Each entry consists of IP address
> (ip_address) and the subnet ID from which the IP address is assigned
> (subnet_id).

Can you share more about the setup? What Neutron plugin is being used? What version of OpenStack do you use?

Revision history for this message
Lê Minh Quân (quanlm1999) wrote :

Hmmm somehow I change somecode in here: ~/kuryr-k8s-controller/kuryr-kubernetes/kuryr_kubernetes/os_vif_util.py

```
 try:
        fixed_ips = neutron_port.get('fixed_ips', [])
        port_id = neutron_port.get('id')
    except TypeError:
        fixed_ips = neutron_port.fixed_ips
        port_id = neutron_port.get.id

    for neutron_fixed_ip in fixed_ips:
        subnet_id = neutron_fixed_ip['subnet_id']
        ip_address = neutron_fixed_ip['ip_address']

```

after some debug

```
 try:
        fixed_ips = neutron_port.fixed_ips
        LOG.info('========================neutron_port.get %s', neutron_port.fixed_ips)
        port_id = neutron_port.get('id')
    except TypeError:
        fixed_ips = neutron_port.fixed_ips
        port_id = neutron_port.get.id

    for neutron_fixed_ip in fixed_ips:
        LOG.info('debug============i %s', fixed_ips)
        subnet_id = neutron_fixed_ip['subnet_id']
        ip_address = neutron_fixed_ip['ip_address']
```

I change the

```
try:
         fixed_ips = neutron_port.get('fixed_ips', [])```

into

```
try:
        fixed_ips = neutron_port.fixed_ips

```

and it work normally although it already have try and expect

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.