Adding IP address to device after deleting primary IP address fails due to caching #4647
Labels
status: accepted
This issue has been accepted for implementation
type: bug
A confirmed report of unexpected behavior in the application
Environment
Steps to Reproduce
PLUGINS
setting inconfiguration.py
.Expected Behavior
The new, non-primary address to be added to the interface and to be redirected back to the device page.
Observed Behavior
The IP address is created and assigned to the interface but the request fails, stating the old primary IP address cannot be found.
This is due to a caching invalidation bug that was uncovered when fixing #3304. The internals of the IPAddressForm.save() method makes use of the interface's parent attribute to access the primary_ip4/ip6 attributes. This issue is the access to that attribute crosses a FK relation which is not linked by cacheops for invalidation. This is very similar to the root cause described in #3304 and the fix is equally similar.
This highlights again that we need to make sure we are using
prefetch_related()
for all FK relationships to ensure invalidation linking forSET_NULL
conditions.The text was updated successfully, but these errors were encountered: