Skip to content

Commit

Permalink
Merge pull request #51588 from karataliu/accm
Browse files Browse the repository at this point in the history
Automatic merge from submit-queue

Fix splitProviderID for Azure

**What this PR does / why we need it**:
#46940 add 'splitProviderID' for Azure to get node name from provider, but it captures the resource id instead of node name.

Functions such as NodeAddresses are accepting node names:
https://github.com/kubernetes/kubernetes/blob/84d9778f225cdf8046774d56d47b1e264e47499f/pkg/cloudprovider/providers/azure/azure_instances.go#L32

With current implementation, it takes in a resource ID, and will result in following error
```
E0830 04:15:09.877143   10427 azure_instances.go:63] error: az.NodeAddresses, az.getIPForMachine(/subscriptions/{id}/resourceGroups/{id}/providers/Microsoft.Compute/virtualMachines/k8s-master-0), err=instance not found
```

This fix makes is return node names instead.


**Which issue this PR fixes**

**Special notes for your reviewer**:

**Release note**:
`NONE`


@brendandburns  @realfake @wlan0
  • Loading branch information
Kubernetes Submit Queue authored Sep 8, 2017
2 parents a5b3e50 + 623d32a commit a5f7660
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/cloudprovider/providers/azure/azure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ func TestSplitProviderID(t *testing.T) {
}{
{
providerID: CloudProviderName + ":///subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroupName/providers/Microsoft.Compute/virtualMachines/k8s-agent-AAAAAAAA-0",
name: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroupName/providers/Microsoft.Compute/virtualMachines/k8s-agent-AAAAAAAA-0",
name: "k8s-agent-AAAAAAAA-0",
fail: false,
},
{
Expand Down
2 changes: 1 addition & 1 deletion pkg/cloudprovider/providers/azure/azure_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const (
securityRuleIDTemplate = "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkSecurityGroups/%s/securityRules/%s"
)

var providerIDRE = regexp.MustCompile(`^` + CloudProviderName + `://(.+)$`)
var providerIDRE = regexp.MustCompile(`^` + CloudProviderName + `://(?:.*)/Microsoft.Compute/virtualMachines/(.+)$`)

// returns the full identifier of a machine
func (az *Cloud) getMachineID(machineName string) string {
Expand Down

0 comments on commit a5f7660

Please sign in to comment.