Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
d880f8c1
Commit
d880f8c1
authored
Jan 23, 2019
by
wojtekt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Couple fixes to DeltaFIFO machinery
parent
27e5971c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
5 deletions
+10
-5
controller.go
staging/src/k8s.io/client-go/tools/cache/controller.go
+3
-3
delta_fifo.go
staging/src/k8s.io/client-go/tools/cache/delta_fifo.go
+5
-1
delta_fifo_test.go
staging/src/k8s.io/client-go/tools/cache/delta_fifo_test.go
+2
-1
No files found.
staging/src/k8s.io/client-go/tools/cache/controller.go
View file @
d880f8c1
...
@@ -28,9 +28,9 @@ import (
...
@@ -28,9 +28,9 @@ import (
// Config contains all the settings for a Controller.
// Config contains all the settings for a Controller.
type
Config
struct
{
type
Config
struct
{
// The queue for your objects
; either a FIFO or
// The queue for your objects
- has to be a DeltaFIFO due to
// a
DeltaFIFO. Your Process() function should accept
// a
ssumptions in the implementation. Your Process() function
// the output of this Queue's Pop() method.
//
should accept
the output of this Queue's Pop() method.
Queue
Queue
// Something that can list and watch your objects.
// Something that can list and watch your objects.
...
...
staging/src/k8s.io/client-go/tools/cache/delta_fifo.go
View file @
d880f8c1
...
@@ -466,6 +466,7 @@ func (f *DeltaFIFO) Replace(list []interface{}, resourceVersion string) error {
...
@@ -466,6 +466,7 @@ func (f *DeltaFIFO) Replace(list []interface{}, resourceVersion string) error {
if
f
.
knownObjects
==
nil
{
if
f
.
knownObjects
==
nil
{
// Do deletion detection against our own list.
// Do deletion detection against our own list.
queuedDeletions
:=
0
for
k
,
oldItem
:=
range
f
.
items
{
for
k
,
oldItem
:=
range
f
.
items
{
if
keys
.
Has
(
k
)
{
if
keys
.
Has
(
k
)
{
continue
continue
...
@@ -474,6 +475,7 @@ func (f *DeltaFIFO) Replace(list []interface{}, resourceVersion string) error {
...
@@ -474,6 +475,7 @@ func (f *DeltaFIFO) Replace(list []interface{}, resourceVersion string) error {
if
n
:=
oldItem
.
Newest
();
n
!=
nil
{
if
n
:=
oldItem
.
Newest
();
n
!=
nil
{
deletedObj
=
n
.
Object
deletedObj
=
n
.
Object
}
}
queuedDeletions
++
if
err
:=
f
.
queueActionLocked
(
Deleted
,
DeletedFinalStateUnknown
{
k
,
deletedObj
});
err
!=
nil
{
if
err
:=
f
.
queueActionLocked
(
Deleted
,
DeletedFinalStateUnknown
{
k
,
deletedObj
});
err
!=
nil
{
return
err
return
err
}
}
...
@@ -481,7 +483,9 @@ func (f *DeltaFIFO) Replace(list []interface{}, resourceVersion string) error {
...
@@ -481,7 +483,9 @@ func (f *DeltaFIFO) Replace(list []interface{}, resourceVersion string) error {
if
!
f
.
populated
{
if
!
f
.
populated
{
f
.
populated
=
true
f
.
populated
=
true
f
.
initialPopulationCount
=
len
(
list
)
// While there shouldn't be any queued deletions in the initial
// population of the queue, it's better to be on the safe side.
f
.
initialPopulationCount
=
len
(
list
)
+
queuedDeletions
}
}
return
nil
return
nil
...
...
staging/src/k8s.io/client-go/tools/cache/delta_fifo_test.go
View file @
d880f8c1
...
@@ -338,6 +338,7 @@ func TestDeltaFIFO_HasSyncedCorrectOnDeletion(t *testing.T) {
...
@@ -338,6 +338,7 @@ func TestDeltaFIFO_HasSyncedCorrectOnDeletion(t *testing.T) {
// Since "bar" didn't have a delete event and wasn't in the Replace list
// Since "bar" didn't have a delete event and wasn't in the Replace list
// it should get a tombstone key with the right Obj.
// it should get a tombstone key with the right Obj.
{{
Deleted
,
DeletedFinalStateUnknown
{
Key
:
"bar"
,
Obj
:
mkFifoObj
(
"bar"
,
6
)}}},
{{
Deleted
,
DeletedFinalStateUnknown
{
Key
:
"bar"
,
Obj
:
mkFifoObj
(
"bar"
,
6
)}}},
{{
Deleted
,
DeletedFinalStateUnknown
{
Key
:
"baz"
,
Obj
:
mkFifoObj
(
"baz"
,
7
)}}},
}
}
for
_
,
expected
:=
range
expectedList
{
for
_
,
expected
:=
range
expectedList
{
...
@@ -349,7 +350,7 @@ func TestDeltaFIFO_HasSyncedCorrectOnDeletion(t *testing.T) {
...
@@ -349,7 +350,7 @@ func TestDeltaFIFO_HasSyncedCorrectOnDeletion(t *testing.T) {
t
.
Errorf
(
"Expected %#v, got %#v"
,
e
,
a
)
t
.
Errorf
(
"Expected %#v, got %#v"
,
e
,
a
)
}
}
}
}
if
f
.
HasSynced
()
{
if
!
f
.
HasSynced
()
{
t
.
Errorf
(
"Expected HasSynced to be true"
)
t
.
Errorf
(
"Expected HasSynced to be true"
)
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment