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
a71abdc3
Commit
a71abdc3
authored
Nov 09, 2016
by
bprashanth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure health check exists before creating target pool
parent
82c488bd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
4 deletions
+11
-4
gce.go
pkg/cloudprovider/providers/gce/gce.go
+11
-4
No files found.
pkg/cloudprovider/providers/gce/gce.go
View file @
a71abdc3
...
@@ -608,6 +608,8 @@ func (gce *GCECloud) EnsureLoadBalancer(clusterName string, apiService *api.Serv
...
@@ -608,6 +608,8 @@ func (gce *GCECloud) EnsureLoadBalancer(clusterName string, apiService *api.Serv
// an IP, we assume they are managing it themselves. Otherwise, we will
// an IP, we assume they are managing it themselves. Otherwise, we will
// release the IP in case of early-terminating failure or upon successful
// release the IP in case of early-terminating failure or upon successful
// creating of the LB.
// creating of the LB.
// TODO(#36535): boil this logic down into a set of component functions
// and key the flag values off of errors returned.
isUserOwnedIP
:=
false
// if this is set, we never release the IP
isUserOwnedIP
:=
false
// if this is set, we never release the IP
isSafeToReleaseIP
:=
false
isSafeToReleaseIP
:=
false
defer
func
()
{
defer
func
()
{
...
@@ -735,7 +737,7 @@ func (gce *GCECloud) EnsureLoadBalancer(clusterName string, apiService *api.Serv
...
@@ -735,7 +737,7 @@ func (gce *GCECloud) EnsureLoadBalancer(clusterName string, apiService *api.Serv
return
nil
,
fmt
.
Errorf
(
"Error checking HTTP health check %s: %v"
,
loadBalancerName
,
err
)
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
!=
""
{
glog
.
V
(
4
)
.
Infof
(
"service %v
needs health checks on :%d/%s)"
,
apiService
.
Name
,
healthCheckNodePort
,
path
)
glog
.
V
(
4
)
.
Infof
(
"service %v
(%v) needs health checks on :%d%s)"
,
apiService
.
Name
,
loadBalancer
Name
,
healthCheckNodePort
,
path
)
if
err
!=
nil
{
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
...
@@ -1080,13 +1082,18 @@ func (gce *GCECloud) createTargetPool(name, serviceName, region string, hosts []
...
@@ -1080,13 +1082,18 @@ func (gce *GCECloud) createTargetPool(name, serviceName, region string, hosts []
for
_
,
host
:=
range
hosts
{
for
_
,
host
:=
range
hosts
{
instances
=
append
(
instances
,
makeHostURL
(
gce
.
projectID
,
host
.
Zone
,
host
.
Name
))
instances
=
append
(
instances
,
makeHostURL
(
gce
.
projectID
,
host
.
Zone
,
host
.
Name
))
}
}
// health check management is coupled with targetPools to prevent leaks. A
// target pool is the only thing that requires a health check, so we delete
// associated checks on teardown, and ensure checks on setup.
hcLinks
:=
[]
string
{}
hcLinks
:=
[]
string
{}
if
hc
!=
nil
{
if
hc
!=
nil
{
var
err
error
if
hc
,
err
=
gce
.
ensureHttpHealthCheck
(
name
,
hc
.
RequestPath
,
int32
(
hc
.
Port
));
err
!=
nil
||
hc
==
nil
{
return
fmt
.
Errorf
(
"Failed to ensure health check for %v port %d path %v: %v"
,
name
,
hc
.
Port
,
hc
.
RequestPath
,
err
)
}
hcLinks
=
append
(
hcLinks
,
hc
.
SelfLink
)
hcLinks
=
append
(
hcLinks
,
hc
.
SelfLink
)
}
}
if
len
(
hcLinks
)
>
0
{
glog
.
Infof
(
"Creating targetpool %v with %d healthchecks"
,
name
,
len
(
hcLinks
))
glog
.
Infof
(
"Creating targetpool %v with healthchecking"
,
name
)
}
pool
:=
&
compute
.
TargetPool
{
pool
:=
&
compute
.
TargetPool
{
Name
:
name
,
Name
:
name
,
Description
:
fmt
.
Sprintf
(
`{"kubernetes.io/service-name":"%s"}`
,
serviceName
),
Description
:
fmt
.
Sprintf
(
`{"kubernetes.io/service-name":"%s"}`
,
serviceName
),
...
...
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