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
1c689c2f
Unverified
Commit
1c689c2f
authored
May 13, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
May 13, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #77491 from andyzhangx/azuredisk-metrics
add operation name for vm/vmss update operations in prometheus metrics
parents
3bc595e3
00c972ce
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
18 additions
and
29 deletions
+18
-29
azure_backoff.go
.../src/k8s.io/legacy-cloud-providers/azure/azure_backoff.go
+2
-14
azure_client.go
...g/src/k8s.io/legacy-cloud-providers/azure/azure_client.go
+0
-0
azure_controller_standard.go
...legacy-cloud-providers/azure/azure_controller_standard.go
+2
-2
azure_controller_vmss.go
....io/legacy-cloud-providers/azure/azure_controller_vmss.go
+2
-2
azure_fakes.go
...ng/src/k8s.io/legacy-cloud-providers/azure/azure_fakes.go
+2
-2
azure_metrics.go
.../src/k8s.io/legacy-cloud-providers/azure/azure_metrics.go
+3
-2
azure_metrics_test.go
...k8s.io/legacy-cloud-providers/azure/azure_metrics_test.go
+2
-2
azure_test.go
...ing/src/k8s.io/legacy-cloud-providers/azure/azure_test.go
+1
-1
azure_vmss.go
...ing/src/k8s.io/legacy-cloud-providers/azure/azure_vmss.go
+4
-4
No files found.
staging/src/k8s.io/legacy-cloud-providers/azure/azure_backoff.go
View file @
1c689c2f
...
...
@@ -550,25 +550,13 @@ func (az *Cloud) deleteRouteWithRetry(routeName string) error {
})
}
// CreateOrUpdateVMWithRetry invokes az.VirtualMachinesClient.CreateOrUpdate with exponential backoff retry
func
(
az
*
Cloud
)
CreateOrUpdateVMWithRetry
(
resourceGroup
,
vmName
string
,
newVM
compute
.
VirtualMachine
)
error
{
return
wait
.
ExponentialBackoff
(
az
.
requestBackoff
(),
func
()
(
bool
,
error
)
{
ctx
,
cancel
:=
getContextWithCancel
()
defer
cancel
()
resp
,
err
:=
az
.
VirtualMachinesClient
.
CreateOrUpdate
(
ctx
,
resourceGroup
,
vmName
,
newVM
)
klog
.
V
(
10
)
.
Infof
(
"VirtualMachinesClient.CreateOrUpdate(%s): end"
,
vmName
)
return
az
.
processHTTPRetryResponse
(
nil
,
""
,
resp
,
err
)
})
}
// UpdateVmssVMWithRetry invokes az.VirtualMachineScaleSetVMsClient.Update with exponential backoff retry
func
(
az
*
Cloud
)
UpdateVmssVMWithRetry
(
resourceGroupName
string
,
VMScaleSetName
string
,
instanceID
string
,
parameters
compute
.
VirtualMachineScaleSetVM
)
error
{
func
(
az
*
Cloud
)
UpdateVmssVMWithRetry
(
resourceGroupName
string
,
VMScaleSetName
string
,
instanceID
string
,
parameters
compute
.
VirtualMachineScaleSetVM
,
source
string
)
error
{
return
wait
.
ExponentialBackoff
(
az
.
requestBackoff
(),
func
()
(
bool
,
error
)
{
ctx
,
cancel
:=
getContextWithCancel
()
defer
cancel
()
resp
,
err
:=
az
.
VirtualMachineScaleSetVMsClient
.
Update
(
ctx
,
resourceGroupName
,
VMScaleSetName
,
instanceID
,
parameters
)
resp
,
err
:=
az
.
VirtualMachineScaleSetVMsClient
.
Update
(
ctx
,
resourceGroupName
,
VMScaleSetName
,
instanceID
,
parameters
,
source
)
klog
.
V
(
10
)
.
Infof
(
"VirtualMachinesClient.CreateOrUpdate(%s,%s): end"
,
VMScaleSetName
,
instanceID
)
return
az
.
processHTTPRetryResponse
(
nil
,
""
,
resp
,
err
)
})
...
...
staging/src/k8s.io/legacy-cloud-providers/azure/azure_client.go
View file @
1c689c2f
This diff is collapsed.
Click to expand it.
staging/src/k8s.io/legacy-cloud-providers/azure/azure_controller_standard.go
View file @
1c689c2f
...
...
@@ -84,7 +84,7 @@ func (as *availabilitySet) AttachDisk(isManagedDisk bool, diskName, diskURI stri
// Invalidate the cache right after updating
defer
as
.
cloud
.
vmCache
.
Delete
(
vmName
)
_
,
err
=
as
.
VirtualMachinesClient
.
CreateOrUpdate
(
ctx
,
nodeResourceGroup
,
vmName
,
newVM
)
_
,
err
=
as
.
VirtualMachinesClient
.
CreateOrUpdate
(
ctx
,
nodeResourceGroup
,
vmName
,
newVM
,
"attach_disk"
)
if
err
!=
nil
{
klog
.
Errorf
(
"azureDisk - attach disk(%s, %s) failed, err: %v"
,
diskName
,
diskURI
,
err
)
detail
:=
err
.
Error
()
...
...
@@ -151,7 +151,7 @@ func (as *availabilitySet) DetachDisk(diskName, diskURI string, nodeName types.N
// Invalidate the cache right after updating
defer
as
.
cloud
.
vmCache
.
Delete
(
vmName
)
return
as
.
VirtualMachinesClient
.
CreateOrUpdate
(
ctx
,
nodeResourceGroup
,
vmName
,
newVM
)
return
as
.
VirtualMachinesClient
.
CreateOrUpdate
(
ctx
,
nodeResourceGroup
,
vmName
,
newVM
,
"detach_disk"
)
}
// GetDataDisks gets a list of data disks attached to the node.
...
...
staging/src/k8s.io/legacy-cloud-providers/azure/azure_controller_vmss.go
View file @
1c689c2f
...
...
@@ -89,7 +89,7 @@ func (ss *scaleSet) AttachDisk(isManagedDisk bool, diskName, diskURI string, nod
defer
ss
.
vmssVMCache
.
Delete
(
key
)
klog
.
V
(
2
)
.
Infof
(
"azureDisk - update(%s): vm(%s) - attach disk(%s, %s)"
,
nodeResourceGroup
,
nodeName
,
diskName
,
diskURI
)
_
,
err
=
ss
.
VirtualMachineScaleSetVMsClient
.
Update
(
ctx
,
nodeResourceGroup
,
ssName
,
instanceID
,
newVM
)
_
,
err
=
ss
.
VirtualMachineScaleSetVMsClient
.
Update
(
ctx
,
nodeResourceGroup
,
ssName
,
instanceID
,
newVM
,
"attach_disk"
)
if
err
!=
nil
{
detail
:=
err
.
Error
()
if
strings
.
Contains
(
detail
,
errLeaseFailed
)
||
strings
.
Contains
(
detail
,
errDiskBlobNotFound
)
{
...
...
@@ -159,7 +159,7 @@ func (ss *scaleSet) DetachDisk(diskName, diskURI string, nodeName types.NodeName
defer
ss
.
vmssVMCache
.
Delete
(
key
)
klog
.
V
(
2
)
.
Infof
(
"azureDisk - update(%s): vm(%s) - detach disk(%s, %s)"
,
nodeResourceGroup
,
nodeName
,
diskName
,
diskURI
)
return
ss
.
VirtualMachineScaleSetVMsClient
.
Update
(
ctx
,
nodeResourceGroup
,
ssName
,
instanceID
,
newVM
)
return
ss
.
VirtualMachineScaleSetVMsClient
.
Update
(
ctx
,
nodeResourceGroup
,
ssName
,
instanceID
,
newVM
,
"detach_disk"
)
}
// GetDataDisks gets a list of data disks attached to the node.
...
...
staging/src/k8s.io/legacy-cloud-providers/azure/azure_fakes.go
View file @
1c689c2f
...
...
@@ -290,7 +290,7 @@ func newFakeAzureVirtualMachinesClient() *fakeAzureVirtualMachinesClient {
return
fVMC
}
func
(
fVMC
*
fakeAzureVirtualMachinesClient
)
CreateOrUpdate
(
ctx
context
.
Context
,
resourceGroupName
string
,
VMName
string
,
parameters
compute
.
VirtualMachine
)
(
resp
*
http
.
Response
,
err
error
)
{
func
(
fVMC
*
fakeAzureVirtualMachinesClient
)
CreateOrUpdate
(
ctx
context
.
Context
,
resourceGroupName
string
,
VMName
string
,
parameters
compute
.
VirtualMachine
,
source
string
)
(
resp
*
http
.
Response
,
err
error
)
{
fVMC
.
mutex
.
Lock
()
defer
fVMC
.
mutex
.
Unlock
()
...
...
@@ -550,7 +550,7 @@ func (fVMC *fakeVirtualMachineScaleSetVMsClient) GetInstanceView(ctx context.Con
return
result
,
nil
}
func
(
fVMC
*
fakeVirtualMachineScaleSetVMsClient
)
Update
(
ctx
context
.
Context
,
resourceGroupName
string
,
VMScaleSetName
string
,
instanceID
string
,
parameters
compute
.
VirtualMachineScaleSetVM
)
(
resp
*
http
.
Response
,
err
error
)
{
func
(
fVMC
*
fakeVirtualMachineScaleSetVMsClient
)
Update
(
ctx
context
.
Context
,
resourceGroupName
string
,
VMScaleSetName
string
,
instanceID
string
,
parameters
compute
.
VirtualMachineScaleSetVM
,
source
string
)
(
resp
*
http
.
Response
,
err
error
)
{
fVMC
.
mutex
.
Lock
()
defer
fVMC
.
mutex
.
Unlock
()
...
...
staging/src/k8s.io/legacy-cloud-providers/azure/azure_metrics.go
View file @
1c689c2f
...
...
@@ -33,6 +33,7 @@ var (
"request"
,
// API function that is being invoked
"resource_group"
,
// Resource group of the resource being monitored
"subscription_id"
,
// Subscription ID of the resource being monitored
"source"
,
// Oeration source(optional)
}
apiMetrics
=
registerAPIMetrics
(
metricLabels
...
)
...
...
@@ -43,10 +44,10 @@ type metricContext struct {
attributes
[]
string
}
func
newMetricContext
(
prefix
,
request
,
resourceGroup
,
subscriptionID
string
)
*
metricContext
{
func
newMetricContext
(
prefix
,
request
,
resourceGroup
,
subscriptionID
,
source
string
)
*
metricContext
{
return
&
metricContext
{
start
:
time
.
Now
(),
attributes
:
[]
string
{
prefix
+
"_"
+
request
,
strings
.
ToLower
(
resourceGroup
),
subscriptionID
},
attributes
:
[]
string
{
prefix
+
"_"
+
request
,
strings
.
ToLower
(
resourceGroup
),
subscriptionID
,
source
},
}
}
...
...
staging/src/k8s.io/legacy-cloud-providers/azure/azure_metrics_test.go
View file @
1c689c2f
...
...
@@ -23,12 +23,12 @@ import (
)
func
TestAzureMetricLabelCardinality
(
t
*
testing
.
T
)
{
mc
:=
newMetricContext
(
"test"
,
"create"
,
"resource_group"
,
"subscription_id"
)
mc
:=
newMetricContext
(
"test"
,
"create"
,
"resource_group"
,
"subscription_id"
,
"source"
)
assert
.
Len
(
t
,
mc
.
attributes
,
len
(
metricLabels
),
"cardinalities of labels and values must match"
)
}
func
TestAzureMetricLabelPrefix
(
t
*
testing
.
T
)
{
mc
:=
newMetricContext
(
"prefix"
,
"request"
,
"resource_group"
,
"subscription_id"
)
mc
:=
newMetricContext
(
"prefix"
,
"request"
,
"resource_group"
,
"subscription_id"
,
"source"
)
found
:=
false
for
_
,
attribute
:=
range
mc
.
attributes
{
if
attribute
==
"prefix_request"
{
...
...
staging/src/k8s.io/legacy-cloud-providers/azure/azure_test.go
View file @
1c689c2f
...
...
@@ -1108,7 +1108,7 @@ func getClusterResources(az *Cloud, vmCount int, availabilitySetCount int) (clus
vmCtx
,
vmCancel
:=
getContextWithCancel
()
defer
vmCancel
()
_
,
err
:=
az
.
VirtualMachinesClient
.
CreateOrUpdate
(
vmCtx
,
az
.
Config
.
ResourceGroup
,
vmName
,
newVM
)
_
,
err
:=
az
.
VirtualMachinesClient
.
CreateOrUpdate
(
vmCtx
,
az
.
Config
.
ResourceGroup
,
vmName
,
newVM
,
""
)
if
err
!=
nil
{
}
// add to kubernetes
...
...
staging/src/k8s.io/legacy-cloud-providers/azure/azure_vmss.go
View file @
1c689c2f
...
...
@@ -712,10 +712,10 @@ func (ss *scaleSet) EnsureHostInPool(service *v1.Service, nodeName types.NodeNam
ctx
,
cancel
:=
getContextWithCancel
()
defer
cancel
()
klog
.
V
(
2
)
.
Infof
(
"EnsureHostInPool begins to update vmssVM(%s) with new backendPoolID %s"
,
vmName
,
backendPoolID
)
resp
,
err
:=
ss
.
VirtualMachineScaleSetVMsClient
.
Update
(
ctx
,
nodeResourceGroup
,
ssName
,
instanceID
,
newVM
)
resp
,
err
:=
ss
.
VirtualMachineScaleSetVMsClient
.
Update
(
ctx
,
nodeResourceGroup
,
ssName
,
instanceID
,
newVM
,
"network_update"
)
if
ss
.
CloudProviderBackoff
&&
shouldRetryHTTPRequest
(
resp
,
err
)
{
klog
.
V
(
2
)
.
Infof
(
"EnsureHostInPool update backing off vmssVM(%s) with new backendPoolID %s, err: %v"
,
vmName
,
backendPoolID
,
err
)
retryErr
:=
ss
.
UpdateVmssVMWithRetry
(
nodeResourceGroup
,
ssName
,
instanceID
,
newVM
)
retryErr
:=
ss
.
UpdateVmssVMWithRetry
(
nodeResourceGroup
,
ssName
,
instanceID
,
newVM
,
"network_update"
)
if
retryErr
!=
nil
{
err
=
retryErr
klog
.
Errorf
(
"EnsureHostInPool update abort backoff vmssVM(%s) with new backendPoolID %s, err: %v"
,
vmName
,
backendPoolID
,
err
)
...
...
@@ -841,10 +841,10 @@ func (ss *scaleSet) ensureBackendPoolDeletedFromNode(service *v1.Service, nodeNa
ctx
,
cancel
:=
getContextWithCancel
()
defer
cancel
()
klog
.
V
(
2
)
.
Infof
(
"ensureBackendPoolDeletedFromNode begins to update vmssVM(%s) with backendPoolID %s"
,
nodeName
,
backendPoolID
)
resp
,
err
:=
ss
.
VirtualMachineScaleSetVMsClient
.
Update
(
ctx
,
nodeResourceGroup
,
ssName
,
instanceID
,
newVM
)
resp
,
err
:=
ss
.
VirtualMachineScaleSetVMsClient
.
Update
(
ctx
,
nodeResourceGroup
,
ssName
,
instanceID
,
newVM
,
"network_update"
)
if
ss
.
CloudProviderBackoff
&&
shouldRetryHTTPRequest
(
resp
,
err
)
{
klog
.
V
(
2
)
.
Infof
(
"ensureBackendPoolDeletedFromNode update backing off vmssVM(%s) with backendPoolID %s, err: %v"
,
nodeName
,
backendPoolID
,
err
)
retryErr
:=
ss
.
UpdateVmssVMWithRetry
(
nodeResourceGroup
,
ssName
,
instanceID
,
newVM
)
retryErr
:=
ss
.
UpdateVmssVMWithRetry
(
nodeResourceGroup
,
ssName
,
instanceID
,
newVM
,
"network_update"
)
if
retryErr
!=
nil
{
err
=
retryErr
klog
.
Errorf
(
"ensureBackendPoolDeletedFromNode update abort backoff vmssVM(%s) with backendPoolID %s, err: %v"
,
nodeName
,
backendPoolID
,
err
)
...
...
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