Comment 1 for bug 1874400

Revision history for this message
Brian Haley (brian-haley) wrote :

I think this was slightly broken with https://review.opendev.org/#/c/373566/ a few years ago:

     def is_port_message_stale(self, payload):
- orig = self.get_port_by_id(payload['id'])
- if orig and orig.get('revision', 0) > payload.get('revision', 0):
+ orig = self.get_port_by_id(payload['id']) or {}
+ if orig.get('revision_number', 0) > payload.get('revision_number', 0):
             return True
         if payload['id'] in self.deleted_ports:
             return True

If the line had stayed 'if orig and orig.get(... ' then it would have also returned False if there was no original port, where now it can return True. So I think you are correct and something like this works better:

if orig and orig.get('revision_number', 0) >= payload.get('revision_number', 0):
    return True

We can then add tests to cover the two new cases:

1) original port not found
2) revision numbers the same