Merge pull request #54196 from jingax10/fix_aliases_branch

Automatic merge from submit-queue (batch tested with PRs 54199, 54181, 54196). 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>.

 Pass zone name instead of zone url to GCE API to update NIC setting for alias range

**What this PR does / why we need it**:
Zone passed to gce.serviceAlpha.Instances.UpdateNetworkInterface(...) as a URL as it results the following error:

Could not add alias 10.64.3.0/24 for node "kubernetes-minion-group-mhhd": googleapi: Error 400: Invalid value 'http://www.googleapis.com/compute/alpha/projects/bigclustertestdev0-devconsole/zones/dev-central1-std'. Values must match the following regular expression: '[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?', invalidParameter

The fix is to extract (last component of URL) the zone name from the corresponding resource URL.

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #

No issue filed yet.

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```
This commit is contained in:
Kubernetes Submit Queue 2017-10-20 18:57:05 -07:00 committed by GitHub
commit 2425486b5e

View File

@ -371,7 +371,7 @@ func (gce *GCECloud) AddAliasToInstance(nodeName types.NodeName, alias *net.IPNe
mc := newInstancesMetricContext("addalias", v1instance.Zone)
op, err := gce.serviceAlpha.Instances.UpdateNetworkInterface(
gce.projectID, instance.Zone, instance.Name, iface.Name, iface).Do()
gce.projectID, lastComponent(instance.Zone), instance.Name, iface.Name, iface).Do()
if err != nil {
return mc.Observe(err)
}