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
618c5c56
Commit
618c5c56
authored
May 18, 2015
by
Victor Marmol
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8400 from a-robinson/bug
Properly handle nil cached services in the service controller's node reconciler
parents
3b10d828
3cf80e76
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
1 deletion
+21
-1
servicecontroller.go
pkg/cloudprovider/servicecontroller/servicecontroller.go
+11
-1
servicecontroller_test.go
...cloudprovider/servicecontroller/servicecontroller_test.go
+10
-0
No files found.
pkg/cloudprovider/servicecontroller/servicecontroller.go
View file @
618c5c56
...
@@ -203,7 +203,10 @@ func (s *ServiceController) processDelta(delta *cache.Delta) (error, bool) {
...
@@ -203,7 +203,10 @@ func (s *ServiceController) processDelta(delta *cache.Delta) (error, bool) {
if
err
!=
nil
{
if
err
!=
nil
{
return
err
,
retry
return
err
,
retry
}
}
// Always update the cache upon success
// Always update the cache upon success.
// NOTE: Since we update the cached service if and only if we successully
// processed it, a cached service being nil implies that it hasn't yet
// been successfully processed.
cachedService
.
service
=
service
cachedService
.
service
=
service
s
.
cache
.
set
(
namespacedName
.
String
(),
cachedService
)
s
.
cache
.
set
(
namespacedName
.
String
(),
cachedService
)
case
cache
.
Deleted
:
case
cache
.
Deleted
:
...
@@ -554,6 +557,13 @@ func (s *ServiceController) updateLoadBalancerHosts(services []*cachedService, h
...
@@ -554,6 +557,13 @@ func (s *ServiceController) updateLoadBalancerHosts(services []*cachedService, h
func
()
{
func
()
{
service
.
mu
.
Lock
()
service
.
mu
.
Lock
()
defer
service
.
mu
.
Unlock
()
defer
service
.
mu
.
Unlock
()
// If the service is nil, that means it hasn't yet been successfully dealt
// with by the load balancer reconciler. We can trust the load balancer
// reconciler to ensure the service's load balancer is created to target
// the correct nodes.
if
service
.
service
==
nil
{
return
}
if
err
:=
s
.
lockedUpdateLoadBalancerHosts
(
service
.
service
,
hosts
);
err
!=
nil
{
if
err
:=
s
.
lockedUpdateLoadBalancerHosts
(
service
.
service
,
hosts
);
err
!=
nil
{
glog
.
Errorf
(
"External error while updating TCP load balancer: %v."
,
err
)
glog
.
Errorf
(
"External error while updating TCP load balancer: %v."
,
err
)
servicesToRetry
=
append
(
servicesToRetry
,
service
)
servicesToRetry
=
append
(
servicesToRetry
,
service
)
...
...
pkg/cloudprovider/servicecontroller/servicecontroller_test.go
View file @
618c5c56
...
@@ -184,6 +184,16 @@ func TestUpdateNodesInExternalLoadBalancer(t *testing.T) {
...
@@ -184,6 +184,16 @@ func TestUpdateNodesInExternalLoadBalancer(t *testing.T) {
{
Name
:
"a999"
,
Region
:
region
,
Hosts
:
[]
string
{
"node0"
,
"node1"
,
"node73"
}},
{
Name
:
"a999"
,
Region
:
region
,
Hosts
:
[]
string
{
"node0"
,
"node1"
,
"node73"
}},
},
},
},
},
{
// One service has an external load balancer and one is nil: one call.
services
:
[]
*
api
.
Service
{
newService
(
"s0"
,
"234"
,
true
),
nil
,
},
expectedUpdateCalls
:
[]
fake_cloud
.
FakeUpdateBalancerCall
{
{
Name
:
"a234"
,
Region
:
region
,
Hosts
:
[]
string
{
"node0"
,
"node1"
,
"node73"
}},
},
},
}
}
for
_
,
item
:=
range
table
{
for
_
,
item
:=
range
table
{
cloud
:=
&
fake_cloud
.
FakeCloud
{}
cloud
:=
&
fake_cloud
.
FakeCloud
{}
...
...
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