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
bb697cee
Commit
bb697cee
authored
May 22, 2015
by
Justin Santa Barbara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clear LoadBalancerStatus both on LB delete and on update in the API
Although it takes some time to destroy a load balancer, we hide this complexity from the user.
parent
a2717713
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
13 deletions
+19
-13
servicecontroller.go
pkg/cloudprovider/servicecontroller/servicecontroller.go
+13
-13
rest.go
pkg/registry/service/rest.go
+6
-0
No files found.
pkg/cloudprovider/servicecontroller/servicecontroller.go
View file @
bb697cee
...
...
@@ -256,33 +256,33 @@ func (s *ServiceController) createLoadBalancerIfNeeded(namespacedName types.Name
}
}
// Save the state so we can avoid a write if it doesn't change
previousState
:=
api
.
LoadBalancerStatusDeepCopy
(
&
service
.
Status
.
LoadBalancer
)
if
!
wantsExternalLoadBalancer
(
service
)
{
glog
.
Infof
(
"Not creating LB for service %s that doesn't want one."
,
namespacedName
)
return
nil
,
notRetryable
}
service
.
Status
.
LoadBalancer
=
api
.
LoadBalancerStatus
{}
}
else
{
glog
.
V
(
2
)
.
Infof
(
"Creating LB for service %s"
,
namespacedName
)
// The load balancer doesn't exist yet, so create it.
// Save the state so we can avoid a write if it doesn't change
previousState
:=
api
.
LoadBalancerStatusDeepCopy
(
&
service
.
Status
.
LoadBalancer
)
err
:=
s
.
createExternalLoadBalancer
(
service
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to create external load balancer for service %s: %v"
,
namespacedName
,
err
),
retryable
}
// Write the state if changed
if
api
.
LoadBalancerStatusEqual
(
previousState
,
&
service
.
Status
.
LoadBalancer
)
{
glog
.
Infof
(
"Not persisting unchanged service to registry."
)
return
nil
,
notRetryable
}
// If creating the load balancer succeeded, persist the updated service.
if
err
=
s
.
persistUpdate
(
service
);
err
!=
nil
{
// Write the state if changed
// TODO: Be careful here ... what if there were other changes to the service?
if
!
api
.
LoadBalancerStatusEqual
(
previousState
,
&
service
.
Status
.
LoadBalancer
)
{
if
err
:=
s
.
persistUpdate
(
service
);
err
!=
nil
{
return
fmt
.
Errorf
(
"Failed to persist updated status to apiserver, even after retries. Giving up: %v"
,
err
),
notRetryable
}
}
else
{
glog
.
Infof
(
"Not persisting unchanged LoadBalancerStatus to registry."
)
}
return
nil
,
notRetryable
}
...
...
pkg/registry/service/rest.go
View file @
bb697cee
...
...
@@ -265,6 +265,12 @@ func (rs *REST) Update(ctx api.Context, obj runtime.Object) (runtime.Object, boo
nodePortOp
.
ReleaseDeferred
(
oldNodePort
)
}
// Remove any LoadBalancerStatus now if Type != LoadBalancer;
// although loadbalancer delete is actually asynchronous, we don't need to expose the user to that complexity.
if
service
.
Spec
.
Type
!=
api
.
ServiceTypeLoadBalancer
{
service
.
Status
.
LoadBalancer
=
api
.
LoadBalancerStatus
{}
}
out
,
err
:=
rs
.
registry
.
UpdateService
(
ctx
,
service
)
if
err
==
nil
{
...
...
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