-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ordering to nat changeset (#5036)
When querying the DB for nat entries, it is not sufficient to filter for entries with a version_added and version_removed greater than a specified value, then order. The sorted columns need to be interleaved as well during the query, or we may accidentally skip entries. This commit adds a view to the db that enables such a query.
- Loading branch information
1 parent
dcbc9cb
commit 887a91e
Showing
7 changed files
with
369 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* A view of the ipv4 nat change history | ||
* used to summarize changes for external viewing | ||
*/ | ||
CREATE VIEW IF NOT EXISTS omicron.public.ipv4_nat_changes | ||
AS | ||
WITH interleaved_versions AS ( | ||
SELECT | ||
external_address, | ||
first_port, | ||
last_port, | ||
sled_address, | ||
vni, | ||
mac, | ||
version_added AS version, | ||
(version_removed IS NOT NULL) as deleted | ||
FROM ipv4_nat_entry | ||
WHERE version_removed IS NULL | ||
|
||
UNION | ||
|
||
SELECT | ||
external_address, | ||
first_port, | ||
last_port, | ||
sled_address, | ||
vni, | ||
mac, | ||
version_added AS version, | ||
(version_removed IS NOT NULL) as deleted | ||
FROM ipv4_nat_entry WHERE version_removed IS NOT NULL | ||
) | ||
SELECT | ||
external_address, | ||
first_port, | ||
last_port, | ||
sled_address, | ||
vni, | ||
mac, | ||
version, | ||
deleted | ||
FROM interleaved_versions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DROP VIEW IF EXISTS omicron.public.ipv4_nat_changes; |
Oops, something went wrong.