Unistore : Ensure Watch works in HA mode. (#93428)

* Replace Watch with WatchNext

* remove watchset

* fix previous page and closing the channel

* Remove the broadcaster cache to prevent dupplicated events

* add watch bookmark

* add watch bookmark

* cleanup comments

* disable the tests for bookmarks for now

* Ensure we send previosu events

* lint

* re-introduce the cache

* load from cache

* disabling legacy test

* disabling legacy test

* Update pkg/storage/unified/resource/server.go

Co-authored-by: Diego Augusto Molina <diegoaugustomolina@gmail.com>

* Could not read previous events

* add proper migration

* Add previous_resource_version to both history and resource

* First event should have an RV of 2 and not 1

* Test both storage backends

* fix the inital RV for the sql backend

* ensure graceful stop of the stream decoder

* gocyclo

---------

Co-authored-by: Diego Augusto Molina <diegoaugustomolina@gmail.com>
This commit is contained in:
Georges Chaudy
2024-09-30 13:14:07 +02:00
committed by GitHub
co-authored by Diego Augusto Molina
parent e1146120f4
commit 0a26c9e9ae
28 changed files with 475 additions and 699 deletions
@@ -5,6 +5,7 @@ INSERT INTO `resource_history`
`resource`,
`namespace`,
`name`,
`previous_resource_version`,
`value`,
`action`
)
@@ -14,6 +15,7 @@ INSERT INTO `resource_history`
'',
'',
'',
1234,
'[]',
'UNKNOWN'
)
@@ -0,0 +1,16 @@
SELECT
`resource_version`,
`namespace`,
`group`,
`resource`,
`name`,
`value`,
`action`,
`previous_resource_version`
FROM `resource_history`
WHERE 1 = 1
AND `group` = 'group'
AND `resource` = 'res'
AND `resource_version` > 1234
ORDER BY `resource_version` ASC
;
@@ -5,6 +5,7 @@ INSERT INTO `resource`
`resource`,
`namespace`,
`name`,
`previous_resource_version`,
`value`,
`action`
)
@@ -14,6 +15,7 @@ INSERT INTO `resource`
'rr',
'nn',
'name',
123,
'[]',
'ADDED'
)
@@ -7,6 +7,6 @@ INSERT INTO `resource_version`
VALUES (
'',
'',
1
2
)
;
@@ -5,6 +5,7 @@ INSERT INTO "resource_history"
"resource",
"namespace",
"name",
"previous_resource_version",
"value",
"action"
)
@@ -14,6 +15,7 @@ INSERT INTO "resource_history"
'',
'',
'',
1234,
'[]',
'UNKNOWN'
)
@@ -0,0 +1,16 @@
SELECT
"resource_version",
"namespace",
"group",
"resource",
"name",
"value",
"action",
"previous_resource_version"
FROM "resource_history"
WHERE 1 = 1
AND "group" = 'group'
AND "resource" = 'res'
AND "resource_version" > 1234
ORDER BY "resource_version" ASC
;
@@ -5,6 +5,7 @@ INSERT INTO "resource"
"resource",
"namespace",
"name",
"previous_resource_version",
"value",
"action"
)
@@ -14,6 +15,7 @@ INSERT INTO "resource"
'rr',
'nn',
'name',
123,
'[]',
'ADDED'
)
@@ -7,6 +7,6 @@ INSERT INTO "resource_version"
VALUES (
'',
'',
1
2
)
;
@@ -5,6 +5,7 @@ INSERT INTO "resource_history"
"resource",
"namespace",
"name",
"previous_resource_version",
"value",
"action"
)
@@ -14,6 +15,7 @@ INSERT INTO "resource_history"
'',
'',
'',
1234,
'[]',
'UNKNOWN'
)
@@ -0,0 +1,16 @@
SELECT
"resource_version",
"namespace",
"group",
"resource",
"name",
"value",
"action",
"previous_resource_version"
FROM "resource_history"
WHERE 1 = 1
AND "group" = 'group'
AND "resource" = 'res'
AND "resource_version" > 1234
ORDER BY "resource_version" ASC
;
@@ -5,6 +5,7 @@ INSERT INTO "resource"
"resource",
"namespace",
"name",
"previous_resource_version",
"value",
"action"
)
@@ -14,6 +15,7 @@ INSERT INTO "resource"
'rr',
'nn',
'name',
123,
'[]',
'ADDED'
)
@@ -7,6 +7,6 @@ INSERT INTO "resource_version"
VALUES (
'',
'',
1
2
)
;