mirror of https://github.com/k3s-io/k3s
Merge pull request #59431 from agau4779/instance-comparable-host-path
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. [GCE] Instance comparable host path **What this PR does / why we need it**: When creating a new TargetPool, insert new instances with the comparable host path instead of the full path, e.g. /zone/%s/instances/%s instead of the full https://www.googleapis.com/compute/v1/projects/... url. With this change, `createTargetPoolAndHealthCheck` and `updateTargetPool` insert gceInstance paths in a consistent manner. **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes # **Release note**: ```release-note NONE ```pull/6/head
commit
bf73cdf4e7
|
@ -67,6 +67,11 @@ func getZone(n *v1.Node) string {
|
|||
return zone
|
||||
}
|
||||
|
||||
func makeHostURL(projectsApiEndpoint, projectID, zone, host string) string {
|
||||
host = canonicalizeInstanceName(host)
|
||||
return projectsApiEndpoint + strings.Join([]string{projectID, "zones", zone, "instances", host}, "/")
|
||||
}
|
||||
|
||||
// ToInstanceReferences returns instance references by links
|
||||
func (gce *GCECloud) ToInstanceReferences(zone string, instanceNames []string) (refs []*compute.InstanceReference) {
|
||||
for _, ins := range instanceNames {
|
||||
|
|
|
@ -535,7 +535,7 @@ func (gce *GCECloud) createTargetPoolAndHealthCheck(svc *v1.Service, name, servi
|
|||
|
||||
var instances []string
|
||||
for _, host := range hosts {
|
||||
instances = append(instances, makeHostURL(gce.service.BasePath, gce.projectID, host.Zone, host.Name))
|
||||
instances = append(instances, host.makeComparableHostPath())
|
||||
}
|
||||
glog.Infof("Creating targetpool %v with %d healthchecks", name, len(hcLinks))
|
||||
pool := &compute.TargetPool{
|
||||
|
@ -732,11 +732,6 @@ func nodeNames(nodes []*v1.Node) []string {
|
|||
return ret
|
||||
}
|
||||
|
||||
func makeHostURL(projectsApiEndpoint, projectID, zone, host string) string {
|
||||
host = canonicalizeInstanceName(host)
|
||||
return projectsApiEndpoint + strings.Join([]string{projectID, "zones", zone, "instances", host}, "/")
|
||||
}
|
||||
|
||||
func hostURLToComparablePath(hostURL string) string {
|
||||
idx := strings.Index(hostURL, "/zones/")
|
||||
if idx < 0 {
|
||||
|
|
Loading…
Reference in New Issue