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
857c8164
Unverified
Commit
857c8164
authored
Aug 08, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
Aug 08, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #81063 from feiskyer/automated-cherry-pick-of-#80703-upstream-release-1.15
Automated cherry pick of #80703: Fix the public IP getting issues for VMSS nodes
parents
31819c55
ec3a043e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
20 deletions
+74
-20
azure_client.go
...g/src/k8s.io/legacy-cloud-providers/azure/azure_client.go
+18
-0
azure_fakes.go
...ng/src/k8s.io/legacy-cloud-providers/azure/azure_fakes.go
+15
-1
azure_vmss.go
...ing/src/k8s.io/legacy-cloud-providers/azure/azure_vmss.go
+41
-19
No files found.
staging/src/k8s.io/legacy-cloud-providers/azure/azure_client.go
View file @
857c8164
...
...
@@ -73,6 +73,7 @@ type PublicIPAddressesClient interface {
CreateOrUpdate
(
ctx
context
.
Context
,
resourceGroupName
string
,
publicIPAddressName
string
,
parameters
network
.
PublicIPAddress
)
(
resp
*
http
.
Response
,
err
error
)
Delete
(
ctx
context
.
Context
,
resourceGroupName
string
,
publicIPAddressName
string
)
(
resp
*
http
.
Response
,
err
error
)
Get
(
ctx
context
.
Context
,
resourceGroupName
string
,
publicIPAddressName
string
,
expand
string
)
(
result
network
.
PublicIPAddress
,
err
error
)
GetVirtualMachineScaleSetPublicIPAddress
(
ctx
context
.
Context
,
resourceGroupName
string
,
virtualMachineScaleSetName
string
,
virtualmachineIndex
string
,
networkInterfaceName
string
,
IPConfigurationName
string
,
publicIPAddressName
string
,
expand
string
)
(
result
network
.
PublicIPAddress
,
err
error
)
List
(
ctx
context
.
Context
,
resourceGroupName
string
)
(
result
[]
network
.
PublicIPAddress
,
err
error
)
}
...
...
@@ -568,6 +569,23 @@ func (az *azPublicIPAddressesClient) Get(ctx context.Context, resourceGroupName
return
}
func
(
az
*
azPublicIPAddressesClient
)
GetVirtualMachineScaleSetPublicIPAddress
(
ctx
context
.
Context
,
resourceGroupName
string
,
virtualMachineScaleSetName
string
,
virtualmachineIndex
string
,
networkInterfaceName
string
,
IPConfigurationName
string
,
publicIPAddressName
string
,
expand
string
)
(
result
network
.
PublicIPAddress
,
err
error
)
{
if
!
az
.
rateLimiterReader
.
TryAccept
()
{
err
=
createRateLimitErr
(
false
,
"VMSSPublicIPGet"
)
return
}
klog
.
V
(
10
)
.
Infof
(
"azPublicIPAddressesClient.GetVirtualMachineScaleSetPublicIPAddress(%q,%q): start"
,
resourceGroupName
,
publicIPAddressName
)
defer
func
()
{
klog
.
V
(
10
)
.
Infof
(
"azPublicIPAddressesClient.GetVirtualMachineScaleSetPublicIPAddress(%q,%q): end"
,
resourceGroupName
,
publicIPAddressName
)
}()
mc
:=
newMetricContext
(
"vmss_public_ip_addresses"
,
"get"
,
resourceGroupName
,
az
.
client
.
SubscriptionID
,
""
)
result
,
err
=
az
.
client
.
GetVirtualMachineScaleSetPublicIPAddress
(
ctx
,
resourceGroupName
,
virtualMachineScaleSetName
,
virtualmachineIndex
,
networkInterfaceName
,
IPConfigurationName
,
publicIPAddressName
,
expand
)
mc
.
Observe
(
err
)
return
}
func
(
az
*
azPublicIPAddressesClient
)
List
(
ctx
context
.
Context
,
resourceGroupName
string
)
([]
network
.
PublicIPAddress
,
error
)
{
if
!
az
.
rateLimiterReader
.
TryAccept
()
{
return
nil
,
createRateLimitErr
(
false
,
"PublicIPList"
)
...
...
staging/src/k8s.io/legacy-cloud-providers/azure/azure_fakes.go
View file @
857c8164
...
...
@@ -193,7 +193,21 @@ func (fAPC *fakeAzurePIPClient) Get(ctx context.Context, resourceGroupName strin
}
return
result
,
autorest
.
DetailedError
{
StatusCode
:
http
.
StatusNotFound
,
Message
:
"Not such PIP"
,
Message
:
"No such PIP"
,
}
}
func
(
fAPC
*
fakeAzurePIPClient
)
GetVirtualMachineScaleSetPublicIPAddress
(
ctx
context
.
Context
,
resourceGroupName
string
,
virtualMachineScaleSetName
string
,
virtualmachineIndex
string
,
networkInterfaceName
string
,
IPConfigurationName
string
,
publicIPAddressName
string
,
expand
string
)
(
result
network
.
PublicIPAddress
,
err
error
)
{
fAPC
.
mutex
.
Lock
()
defer
fAPC
.
mutex
.
Unlock
()
if
_
,
ok
:=
fAPC
.
FakeStore
[
resourceGroupName
];
ok
{
if
entity
,
ok
:=
fAPC
.
FakeStore
[
resourceGroupName
][
publicIPAddressName
];
ok
{
return
entity
,
nil
}
}
return
result
,
autorest
.
DetailedError
{
StatusCode
:
http
.
StatusNotFound
,
Message
:
"No such PIP"
,
}
}
...
...
staging/src/k8s.io/legacy-cloud-providers/azure/azure_vmss.go
View file @
857c8164
...
...
@@ -39,10 +39,11 @@ var (
// ErrorNotVmssInstance indicates an instance is not belongint to any vmss.
ErrorNotVmssInstance
=
errors
.
New
(
"not a vmss instance"
)
scaleSetNameRE
=
regexp
.
MustCompile
(
`.*/subscriptions/(?:.*)/Microsoft.Compute/virtualMachineScaleSets/(.+)/virtualMachines(?:.*)`
)
resourceGroupRE
=
regexp
.
MustCompile
(
`.*/subscriptions/(?:.*)/resourceGroups/(.+)/providers/Microsoft.Compute/virtualMachineScaleSets/(?:.*)/virtualMachines(?:.*)`
)
vmssMachineIDTemplate
=
"/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Compute/virtualMachineScaleSets/%s/virtualMachines/%s"
vmssIPConfigurationRE
=
regexp
.
MustCompile
(
`.*/subscriptions/(?:.*)/resourceGroups/(.+)/providers/Microsoft.Compute/virtualMachineScaleSets/(.+)/virtualMachines/(.+)/networkInterfaces(?:.*)`
)
scaleSetNameRE
=
regexp
.
MustCompile
(
`.*/subscriptions/(?:.*)/Microsoft.Compute/virtualMachineScaleSets/(.+)/virtualMachines(?:.*)`
)
resourceGroupRE
=
regexp
.
MustCompile
(
`.*/subscriptions/(?:.*)/resourceGroups/(.+)/providers/Microsoft.Compute/virtualMachineScaleSets/(?:.*)/virtualMachines(?:.*)`
)
vmssMachineIDTemplate
=
"/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Compute/virtualMachineScaleSets/%s/virtualMachines/%s"
vmssIPConfigurationRE
=
regexp
.
MustCompile
(
`.*/subscriptions/(?:.*)/resourceGroups/(.+)/providers/Microsoft.Compute/virtualMachineScaleSets/(.+)/virtualMachines/(.+)/networkInterfaces(?:.*)`
)
vmssPIPConfigurationRE
=
regexp
.
MustCompile
(
`.*/subscriptions/(?:.*)/resourceGroups/(.+)/providers/Microsoft.Compute/virtualMachineScaleSets/(.+)/virtualMachines/(.+)/networkInterfaces/(.+)/ipConfigurations/(.+)/publicIPAddresses/(.+)`
)
)
// scaleSet implements VMSet interface for Azure scale set.
...
...
@@ -313,26 +314,47 @@ func (ss *scaleSet) GetIPByNodeName(nodeName string) (string, string, error) {
publicIP
:=
""
if
ipConfig
.
PublicIPAddress
!=
nil
&&
ipConfig
.
PublicIPAddress
.
ID
!=
nil
{
pipID
:=
*
ipConfig
.
PublicIPAddress
.
ID
pipName
,
err
:=
getLastSegment
(
pipID
)
if
err
!=
nil
{
return
""
,
""
,
fmt
.
Errorf
(
"failed to get publicIP name for node %q with pipID %q"
,
nodeName
,
pipID
)
matches
:=
vmssPIPConfigurationRE
.
FindStringSubmatch
(
pipID
)
if
len
(
matches
)
==
7
{
resourceGroupName
:=
matches
[
1
]
virtualMachineScaleSetName
:=
matches
[
2
]
virtualmachineIndex
:=
matches
[
3
]
networkInterfaceName
:=
matches
[
4
]
IPConfigurationName
:=
matches
[
5
]
publicIPAddressName
:=
matches
[
6
]
pip
,
existsPip
,
err
:=
ss
.
getVMSSPublicIPAddress
(
resourceGroupName
,
virtualMachineScaleSetName
,
virtualmachineIndex
,
networkInterfaceName
,
IPConfigurationName
,
publicIPAddressName
)
if
err
!=
nil
{
klog
.
Errorf
(
"ss.getVMSSPublicIPAddress() failed with error: %v"
,
err
)
return
""
,
""
,
err
}
if
existsPip
&&
pip
.
IPAddress
!=
nil
{
publicIP
=
*
pip
.
IPAddress
}
}
else
{
klog
.
Warningf
(
"Failed to get VMSS Public IP with ID %s"
,
pipID
)
}
}
resourceGroup
,
err
:=
ss
.
GetNodeResourceGroup
(
nodeName
)
if
err
!=
nil
{
return
""
,
""
,
err
}
return
internalIP
,
publicIP
,
nil
}
pip
,
existsPip
,
err
:=
ss
.
getPublicIPAddress
(
resourceGroup
,
pipName
)
if
err
!=
nil
{
return
""
,
""
,
err
}
if
existsPip
{
publicIP
=
*
pip
.
IPAddress
}
func
(
ss
*
scaleSet
)
getVMSSPublicIPAddress
(
resourceGroupName
string
,
virtualMachineScaleSetName
string
,
virtualmachineIndex
string
,
networkInterfaceName
string
,
IPConfigurationName
string
,
publicIPAddressName
string
)
(
pip
network
.
PublicIPAddress
,
exists
bool
,
err
error
)
{
var
realErr
error
var
message
string
ctx
,
cancel
:=
getContextWithCancel
()
defer
cancel
()
pip
,
err
=
ss
.
PublicIPAddressesClient
.
GetVirtualMachineScaleSetPublicIPAddress
(
ctx
,
resourceGroupName
,
virtualMachineScaleSetName
,
virtualmachineIndex
,
networkInterfaceName
,
IPConfigurationName
,
publicIPAddressName
,
""
)
exists
,
message
,
realErr
=
checkResourceExistsFromError
(
err
)
if
realErr
!=
nil
{
return
pip
,
false
,
realErr
}
return
internalIP
,
publicIP
,
nil
if
!
exists
{
klog
.
V
(
2
)
.
Infof
(
"Public IP %q not found with message: %q"
,
publicIPAddressName
,
message
)
return
pip
,
false
,
nil
}
return
pip
,
exists
,
err
}
// This returns the full identifier of the primary NIC for the given VM.
...
...
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