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
5be3a5a9
Commit
5be3a5a9
authored
May 05, 2015
by
Alex Robinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7783 from GoogleCloudPlatform/revert-7609-lb
Revert "Truncate GCE load balancer names to 63 chars"
parents
5d7b33b8
1c7f6b82
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
21 deletions
+3
-21
gce.go
pkg/cloudprovider/gce/gce.go
+3
-21
No files found.
pkg/cloudprovider/gce/gce.go
View file @
5be3a5a9
...
@@ -17,7 +17,6 @@ limitations under the License.
...
@@ -17,7 +17,6 @@ limitations under the License.
package
gce_cloud
package
gce_cloud
import
(
import
(
"crypto/md5"
"fmt"
"fmt"
"io"
"io"
"io/ioutil"
"io/ioutil"
...
@@ -43,8 +42,6 @@ import (
...
@@ -43,8 +42,6 @@ import (
"google.golang.org/cloud/compute/metadata"
"google.golang.org/cloud/compute/metadata"
)
)
const
LOAD_BALANCER_NAME_MAX_LENGTH
=
63
// GCECloud is an implementation of Interface, TCPLoadBalancer and Instances for Google Compute Engine.
// GCECloud is an implementation of Interface, TCPLoadBalancer and Instances for Google Compute Engine.
type
GCECloud
struct
{
type
GCECloud
struct
{
service
*
compute
.
Service
service
*
compute
.
Service
...
@@ -269,23 +266,10 @@ func translateAffinityType(affinityType api.AffinityType) GCEAffinityType {
...
@@ -269,23 +266,10 @@ func translateAffinityType(affinityType api.AffinityType) GCEAffinityType {
}
}
}
}
func
normalizeName
(
name
string
)
string
{
// If it's short enough, just leave it.
if
len
(
name
)
<
LOAD_BALANCER_NAME_MAX_LENGTH
-
6
{
return
name
}
// Hash and truncate
hash
:=
md5
.
Sum
([]
byte
(
name
))
truncated
:=
name
[
0
:
LOAD_BALANCER_NAME_MAX_LENGTH
-
6
]
shortHash
:=
hash
[
0
:
6
]
return
fmt
.
Sprintf
(
"%s%s"
,
truncated
,
string
(
shortHash
))
}
// CreateTCPLoadBalancer is an implementation of TCPLoadBalancer.CreateTCPLoadBalancer.
// CreateTCPLoadBalancer is an implementation of TCPLoadBalancer.CreateTCPLoadBalancer.
// TODO(a-robinson): Don't just ignore specified IP addresses. Check if they're
// TODO(a-robinson): Don't just ignore specified IP addresses. Check if they're
// owned by the project and available to be used, and use them if they are.
// owned by the project and available to be used, and use them if they are.
func
(
gce
*
GCECloud
)
CreateTCPLoadBalancer
(
origName
,
region
string
,
externalIP
net
.
IP
,
ports
[]
int
,
hosts
[]
string
,
affinityType
api
.
AffinityType
)
(
string
,
error
)
{
func
(
gce
*
GCECloud
)
CreateTCPLoadBalancer
(
name
,
region
string
,
externalIP
net
.
IP
,
ports
[]
int
,
hosts
[]
string
,
affinityType
api
.
AffinityType
)
(
string
,
error
)
{
name
:=
normalizeName
(
origName
)
err
:=
gce
.
makeTargetPool
(
name
,
region
,
hosts
,
translateAffinityType
(
affinityType
))
err
:=
gce
.
makeTargetPool
(
name
,
region
,
hosts
,
translateAffinityType
(
affinityType
))
if
err
!=
nil
{
if
err
!=
nil
{
if
!
isHTTPErrorCode
(
err
,
http
.
StatusConflict
)
{
if
!
isHTTPErrorCode
(
err
,
http
.
StatusConflict
)
{
...
@@ -331,8 +315,7 @@ func (gce *GCECloud) CreateTCPLoadBalancer(origName, region string, externalIP n
...
@@ -331,8 +315,7 @@ func (gce *GCECloud) CreateTCPLoadBalancer(origName, region string, externalIP n
}
}
// UpdateTCPLoadBalancer is an implementation of TCPLoadBalancer.UpdateTCPLoadBalancer.
// UpdateTCPLoadBalancer is an implementation of TCPLoadBalancer.UpdateTCPLoadBalancer.
func
(
gce
*
GCECloud
)
UpdateTCPLoadBalancer
(
origName
,
region
string
,
hosts
[]
string
)
error
{
func
(
gce
*
GCECloud
)
UpdateTCPLoadBalancer
(
name
,
region
string
,
hosts
[]
string
)
error
{
name
:=
normalizeName
(
origName
)
pool
,
err
:=
gce
.
service
.
TargetPools
.
Get
(
gce
.
projectID
,
region
,
name
)
.
Do
()
pool
,
err
:=
gce
.
service
.
TargetPools
.
Get
(
gce
.
projectID
,
region
,
name
)
.
Do
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
@@ -377,8 +360,7 @@ func (gce *GCECloud) UpdateTCPLoadBalancer(origName, region string, hosts []stri
...
@@ -377,8 +360,7 @@ func (gce *GCECloud) UpdateTCPLoadBalancer(origName, region string, hosts []stri
}
}
// DeleteTCPLoadBalancer is an implementation of TCPLoadBalancer.DeleteTCPLoadBalancer.
// DeleteTCPLoadBalancer is an implementation of TCPLoadBalancer.DeleteTCPLoadBalancer.
func
(
gce
*
GCECloud
)
DeleteTCPLoadBalancer
(
origName
,
region
string
)
error
{
func
(
gce
*
GCECloud
)
DeleteTCPLoadBalancer
(
name
,
region
string
)
error
{
name
:=
normalizeName
(
origName
)
op
,
err
:=
gce
.
service
.
ForwardingRules
.
Delete
(
gce
.
projectID
,
region
,
name
)
.
Do
()
op
,
err
:=
gce
.
service
.
ForwardingRules
.
Delete
(
gce
.
projectID
,
region
,
name
)
.
Do
()
if
err
!=
nil
&&
isHTTPErrorCode
(
err
,
http
.
StatusNotFound
)
{
if
err
!=
nil
&&
isHTTPErrorCode
(
err
,
http
.
StatusNotFound
)
{
glog
.
Infof
(
"Forwarding rule %s already deleted. Continuing to delete target pool."
,
name
)
glog
.
Infof
(
"Forwarding rule %s already deleted. Continuing to delete target pool."
,
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