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
81b36aab
Commit
81b36aab
authored
Sep 06, 2016
by
Girish Kalele
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add NotFound safety check to the HealthCheck reconciler
parent
87a02759
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
5 deletions
+13
-5
gce.go
pkg/cloudprovider/providers/gce/gce.go
+13
-5
No files found.
pkg/cloudprovider/providers/gce/gce.go
View file @
81b36aab
...
@@ -724,9 +724,13 @@ func (gce *GCECloud) EnsureLoadBalancer(clusterName string, apiService *api.Serv
...
@@ -724,9 +724,13 @@ func (gce *GCECloud) EnsureLoadBalancer(clusterName string, apiService *api.Serv
// health checks. This needs to be prior to the forwarding rule deletion below otherwise it is not possible
// health checks. This needs to be prior to the forwarding rule deletion below otherwise it is not possible
// to delete just the target pool or http health checks later.
// to delete just the target pool or http health checks later.
var
hcToCreate
*
compute
.
HttpHealthCheck
var
hcToCreate
*
compute
.
HttpHealthCheck
hcExisting
,
_
:=
gce
.
GetHttpHealthCheck
(
loadBalancerName
)
hcExisting
,
err
:=
gce
.
GetHttpHealthCheck
(
loadBalancerName
)
if
err
!=
nil
&&
!
isHTTPErrorCode
(
err
,
http
.
StatusNotFound
)
{
return
nil
,
fmt
.
Errorf
(
"Error checking HTTP health check %s: %v"
,
loadBalancerName
,
err
)
}
if
path
,
healthCheckNodePort
:=
apiservice
.
GetServiceHealthCheckPathPort
(
apiService
);
path
!=
""
{
if
path
,
healthCheckNodePort
:=
apiservice
.
GetServiceHealthCheckPathPort
(
apiService
);
path
!=
""
{
if
hcExisting
==
nil
{
glog
.
V
(
4
)
.
Infof
(
"service %v needs health checks on :%d/%s)"
,
apiService
.
Name
,
healthCheckNodePort
,
path
)
if
err
!=
nil
{
// This logic exists to detect a transition for a pre-existing service and turn on
// This logic exists to detect a transition for a pre-existing service and turn on
// the tpNeedsUpdate flag to delete/recreate fwdrule/tpool adding the health check
// the tpNeedsUpdate flag to delete/recreate fwdrule/tpool adding the health check
// to the target pool.
// to the target pool.
...
@@ -735,14 +739,13 @@ func (gce *GCECloud) EnsureLoadBalancer(clusterName string, apiService *api.Serv
...
@@ -735,14 +739,13 @@ func (gce *GCECloud) EnsureLoadBalancer(clusterName string, apiService *api.Serv
apiservice
.
AnnotationValueExternalTrafficLocal
)
apiservice
.
AnnotationValueExternalTrafficLocal
)
tpNeedsUpdate
=
true
tpNeedsUpdate
=
true
}
}
glog
.
V
(
4
)
.
Infof
(
"service %v needs health checks on :%d/%s)"
,
apiService
.
Name
,
healthCheckNodePort
,
path
)
hcToCreate
,
err
=
gce
.
ensureHttpHealthCheck
(
loadBalancerName
,
path
,
healthCheckNodePort
)
hcToCreate
,
err
=
gce
.
ensureHttpHealthCheck
(
loadBalancerName
,
path
,
healthCheckNodePort
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"Failed to
creat
e health check for localized service %v on node port %v: %v"
,
loadBalancerName
,
healthCheckNodePort
,
err
)
return
nil
,
fmt
.
Errorf
(
"Failed to
ensur
e health check for localized service %v on node port %v: %v"
,
loadBalancerName
,
healthCheckNodePort
,
err
)
}
}
}
else
{
}
else
{
glog
.
V
(
4
)
.
Infof
(
"service %v does not need health checks"
,
apiService
.
Name
)
glog
.
V
(
4
)
.
Infof
(
"service %v does not need health checks"
,
apiService
.
Name
)
if
hcExisting
!
=
nil
{
if
err
=
=
nil
{
glog
.
V
(
2
)
.
Infof
(
"Deleting stale health checks for service %v LB %v"
,
apiService
.
Name
,
loadBalancerName
)
glog
.
V
(
2
)
.
Infof
(
"Deleting stale health checks for service %v LB %v"
,
apiService
.
Name
,
loadBalancerName
)
tpNeedsUpdate
=
true
tpNeedsUpdate
=
true
}
}
...
@@ -1464,7 +1467,12 @@ func (gce *GCECloud) deleteTargetPool(name, region string, hc *compute.HttpHealt
...
@@ -1464,7 +1467,12 @@ func (gce *GCECloud) deleteTargetPool(name, region string, hc *compute.HttpHealt
return
err
return
err
}
}
}
else
{
}
else
{
// This is a HC cleanup attempt to prevent stale HCs when errors are encountered
// during HC deletion in a prior pass through EnsureLoadBalancer.
// The HC name matches the load balancer name - normally this is expected to fail.
if
err
:=
gce
.
DeleteHttpHealthCheck
(
name
);
err
==
nil
{
if
err
:=
gce
.
DeleteHttpHealthCheck
(
name
);
err
==
nil
{
// We only print a warning if this deletion actually succeeded (which
// means there was indeed a stale health check with the LB name.
glog
.
Warningf
(
"Deleted stale http health check for LB: %s"
,
name
)
glog
.
Warningf
(
"Deleted stale http health check for LB: %s"
,
name
)
}
}
}
}
...
...
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