ipdevpoll inventory job fails when deleting old router addresses

Bug #1540839 reported by Morten Brekkevold
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Network Administration Visualized
Fix Released
High
Morten Brekkevold

Bug Description

In NAV 4.4.1, the ipdevpoll inventory job crashes when attempting to delete router port addresses that have disappeared from the running config.

Traceback looks like this:

2016-01-31 06:39:34,378 [1033] [INFO shadows.gwportprefix] deleting 1 missing addresses from big-gsw.example.org: 10.1.1.1
2016-01-31 06:39:34,381 [1033] [ERROR jobs.jobhandler] [inventory big-gsw.example.org] Caught exception during cleanup. Last manager = DefaultManager(<class 'nav.ipdevpoll.shadows.GwPortPrefix'>, 'ContainerRepository'(...))
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/nav/ipdevpoll/jobs.py", line 389, in cleanup_containers_after_save
    manager.cleanup()
  File "/usr/lib/python2.7/dist-packages/nav/ipdevpoll/storage.py", line 88, in cleanup
    self.cls.cleanup_after_save(self.containers)
  File "/usr/lib/python2.7/dist-packages/nav/ipdevpoll/shadows/__init__.py", line 444, in cleanup_after_save
    cls._delete_missing_addresses(containers)
  File "/usr/lib/python2.7/dist-packages/nav/ipdevpoll/shadows/__init__.py", line 457, in _delete_missing_addresses
    missing_addresses.delete()
  File "/usr/lib/python2.7/dist-packages/django/db/models/query.py", line 557, in delete
    collector.delete()
  File "/usr/lib/python2.7/dist-packages/django/db/models/deletion.py", line 262, in delete
    qs._raw_delete(using=self.using)
  File "/usr/lib/python2.7/dist-packages/django/db/models/query.py", line 569, in _raw_delete
    sql.DeleteQuery(self.model).delete_qs(self, using)
  File "/usr/lib/python2.7/dist-packages/django/db/models/sql/subqueries.py", line 85, in delete_qs
    self.get_compiler(using).execute_sql(NO_RESULTS)
  File "/usr/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 786, in execute_sql
    cursor.execute(sql, params)
  File "/usr/lib/python2.7/dist-packages/django/db/backends/utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
  File "/usr/lib/python2.7/dist-packages/django/db/utils.py", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/usr/lib/python2.7/dist-packages/django/db/backends/utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
ProgrammingError: operator does not exist: text = inet
LINE 1: ... "gwportprefix" WHERE HOST("gwportprefix"."gwip") IN (SELECT...
                                                             ^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.

Tags: ipdevpoll
Revision history for this message
Morten Brekkevold (mbrekkevold) wrote :

Apparently, this is due to some changes in how Django handles IPAddressFields. It casts the gwportprefix.gwip field (an INET data type) using the HOST() function, which turns the address into a string, and then proceeds to compare it with a list of un-cast INET values. It is very reminiscent of tjhis Django bug, which was supposedly fixed years ago: https://code.djangoproject.com/ticket/11442

NAV is affected by this due to the transition from Django 1.4 to Django 1.7.

It seems our best option for fixing this is to change the GwPortPrefix.gw_ip attribute from Django's IPAddressField type into NAV's own CIDRField type (which was created explicitly to work around Django's issues with handling IP address fields in PostgreSQL).

Revision history for this message
Morten Brekkevold (mbrekkevold) wrote :
Changed in nav:
status: Confirmed → Fix Committed
Changed in nav:
status: Fix Committed → Fix Released
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.