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
ddbf851b
Commit
ddbf851b
authored
May 22, 2015
by
Dawn Chen
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8000 from bprashanth/rc_ttl_cleanup
Delete expectations of a deleted rc instead of letting them expire
parents
7c80f3d9
c0a8981b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
0 deletions
+46
-0
controller_utils.go
pkg/controller/controller_utils.go
+10
-0
replication_controller.go
pkg/controller/replication_controller.go
+1
-0
replication_controller_test.go
pkg/controller/replication_controller_test.go
+35
-0
No files found.
pkg/controller/controller_utils.go
View file @
ddbf851b
...
...
@@ -63,6 +63,7 @@ var expKeyFunc = func(obj interface{}) (string, error) {
type
RCExpectationsManager
interface
{
GetExpectations
(
rc
*
api
.
ReplicationController
)
(
*
PodExpectations
,
bool
,
error
)
SatisfiedExpectations
(
rc
*
api
.
ReplicationController
)
bool
DeleteExpectations
(
rcKey
string
)
ExpectCreations
(
rc
*
api
.
ReplicationController
,
adds
int
)
error
ExpectDeletions
(
rc
*
api
.
ReplicationController
,
dels
int
)
error
CreationObserved
(
rc
*
api
.
ReplicationController
)
...
...
@@ -87,6 +88,15 @@ func (r *RCExpectations) GetExpectations(rc *api.ReplicationController) (*PodExp
}
}
// DeleteExpectations deletes the expectations of the given RC from the TTLStore.
func
(
r
*
RCExpectations
)
DeleteExpectations
(
rcKey
string
)
{
if
podExp
,
exists
,
err
:=
r
.
GetByKey
(
rcKey
);
err
==
nil
&&
exists
{
if
err
:=
r
.
Delete
(
podExp
);
err
!=
nil
{
glog
.
V
(
2
)
.
Infof
(
"Error deleting expectations for rc %v: %v"
,
rcKey
,
err
)
}
}
}
// SatisfiedExpectations returns true if the replication manager has observed the required adds/dels
// for the given rc. Add/del counts are established by the rc at sync time, and updated as pods
// are observed by the replication manager's podController.
...
...
pkg/controller/replication_controller.go
View file @
ddbf851b
...
...
@@ -354,6 +354,7 @@ func (rm *ReplicationManager) syncReplicationController(key string) error {
obj
,
exists
,
err
:=
rm
.
controllerStore
.
Store
.
GetByKey
(
key
)
if
!
exists
{
glog
.
Infof
(
"Replication Controller has been deleted %v"
,
key
)
rm
.
expectations
.
DeleteExpectations
(
key
)
return
nil
}
if
err
!=
nil
{
...
...
pkg/controller/replication_controller_test.go
View file @
ddbf851b
...
...
@@ -990,3 +990,38 @@ func TestRCSyncExpectations(t *testing.T) {
manager
.
syncReplicationController
(
getKey
(
controllerSpec
,
t
))
validateSyncReplication
(
t
,
&
fakePodControl
,
0
,
0
)
}
func
TestDeleteControllerAndExpectations
(
t
*
testing
.
T
)
{
client
:=
client
.
NewOrDie
(
&
client
.
Config
{
Host
:
""
,
Version
:
testapi
.
Version
()})
manager
:=
NewReplicationManager
(
client
,
10
)
rc
:=
newReplicationController
(
1
)
manager
.
controllerStore
.
Store
.
Add
(
rc
)
fakePodControl
:=
FakePodControl
{}
manager
.
podControl
=
&
fakePodControl
// This should set expectations for the rc
manager
.
syncReplicationController
(
getKey
(
rc
,
t
))
validateSyncReplication
(
t
,
&
fakePodControl
,
1
,
0
)
fakePodControl
.
clear
()
// This is to simulate a concurrent addPod, that has a handle on the expectations
// as the controller deletes it.
podExp
,
exists
,
err
:=
manager
.
expectations
.
GetExpectations
(
rc
)
if
!
exists
||
err
!=
nil
{
t
.
Errorf
(
"No expectations found for rc"
)
}
manager
.
controllerStore
.
Delete
(
rc
)
manager
.
syncReplicationController
(
getKey
(
rc
,
t
))
if
_
,
exists
,
err
=
manager
.
expectations
.
GetExpectations
(
rc
);
exists
{
t
.
Errorf
(
"Found expectaions, expected none since the rc has been deleted."
)
}
// This should have no effect, since we've deleted the rc.
podExp
.
Seen
(
1
,
0
)
manager
.
podStore
.
Store
.
Replace
(
make
([]
interface
{},
0
))
manager
.
syncReplicationController
(
getKey
(
rc
,
t
))
validateSyncReplication
(
t
,
&
fakePodControl
,
0
,
0
)
}
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