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
6fa97306
Commit
6fa97306
authored
Oct 15, 2020
by
Brad Davidson
Committed by
Brad Davidson
Oct 15, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Kubernetes to v1.18.10-k3s1
Signed-off-by:
Brad Davidson
<
brad.davidson@rancher.com
>
parent
3661f566
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
39 changed files
with
524 additions
and
439 deletions
+524
-439
go.mod
go.mod
+26
-26
go.sum
go.sum
+0
-0
store.go
vendor/k8s.io/apiserver/pkg/storage/etcd3/store.go
+8
-0
base.go
vendor/k8s.io/client-go/pkg/version/base.go
+3
-3
base.go
vendor/k8s.io/component-base/version/base.go
+3
-3
sorter.go
vendor/k8s.io/kubectl/pkg/cmd/get/sorter.go
+7
-0
BUILD
vendor/k8s.io/kubernetes/pkg/api/endpoints/BUILD
+0
-42
OWNERS
vendor/k8s.io/kubernetes/pkg/api/endpoints/OWNERS
+0
-10
util.go
vendor/k8s.io/kubernetes/pkg/api/endpoints/util.go
+0
-235
config.go
...s.io/kubernetes/pkg/client/leaderelectionconfig/config.go
+2
-1
endpoints_controller.go
...ubernetes/pkg/controller/endpoint/endpoints_controller.go
+10
-1
config.go
vendor/k8s.io/kubernetes/pkg/credentialprovider/config.go
+9
-7
endpoints.go
vendor/k8s.io/kubernetes/pkg/proxy/endpoints.go
+10
-2
BUILD
vendor/k8s.io/kubernetes/pkg/registry/core/endpoint/BUILD
+0
-1
strategy.go
.../k8s.io/kubernetes/pkg/registry/core/endpoint/strategy.go
+0
-3
filtering.go
...scheduler/framework/plugins/interpodaffinity/filtering.go
+3
-3
cache.go
...r/k8s.io/kubernetes/pkg/scheduler/internal/cache/cache.go
+23
-4
interface.go
...s.io/kubernetes/pkg/scheduler/internal/cache/interface.go
+2
-0
snapshot.go
...8s.io/kubernetes/pkg/scheduler/internal/cache/snapshot.go
+14
-1
listers.go
vendor/k8s.io/kubernetes/pkg/scheduler/listers/listers.go
+2
-0
node_info.go
vendor/k8s.io/kubernetes/pkg/scheduler/nodeinfo/node_info.go
+51
-16
azure.go
vendor/k8s.io/legacy-cloud-providers/azure/azure.go
+3
-3
azure_backoff.go
vendor/k8s.io/legacy-cloud-providers/azure/azure_backoff.go
+2
-2
azure_controller_common.go
...o/legacy-cloud-providers/azure/azure_controller_common.go
+37
-22
azure_controller_standard.go
...legacy-cloud-providers/azure/azure_controller_standard.go
+5
-1
azure_controller_vmss.go
....io/legacy-cloud-providers/azure/azure_controller_vmss.go
+5
-1
azure_fakes.go
vendor/k8s.io/legacy-cloud-providers/azure/azure_fakes.go
+9
-1
azure_instances.go
...or/k8s.io/legacy-cloud-providers/azure/azure_instances.go
+13
-13
azure_loadbalancer.go
...k8s.io/legacy-cloud-providers/azure/azure_loadbalancer.go
+7
-6
azure_managedDiskController.go
...gacy-cloud-providers/azure/azure_managedDiskController.go
+6
-2
azure_standard.go
vendor/k8s.io/legacy-cloud-providers/azure/azure_standard.go
+3
-3
azure_vmss.go
vendor/k8s.io/legacy-cloud-providers/azure/azure_vmss.go
+9
-2
azure_zones.go
vendor/k8s.io/legacy-cloud-providers/azure/azure_zones.go
+3
-3
BUILD
....io/legacy-cloud-providers/azure/clients/diskclient/BUILD
+2
-0
azure_diskclient.go
...ud-providers/azure/clients/diskclient/azure_diskclient.go
+193
-0
interface.go
...acy-cloud-providers/azure/clients/diskclient/interface.go
+6
-0
azure_metrics.go
....io/legacy-cloud-providers/azure/metrics/azure_metrics.go
+1
-0
azure_error.go
.../k8s.io/legacy-cloud-providers/azure/retry/azure_error.go
+26
-0
modules.txt
vendor/modules.txt
+21
-22
No files found.
go.mod
View file @
6fa97306
...
@@ -33,31 +33,31 @@ replace (
...
@@ -33,31 +33,31 @@ replace (
github.com/prometheus/client_model => github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910
github.com/prometheus/client_model => github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910
github.com/prometheus/common => github.com/prometheus/common v0.0.0-20181126121408-4724e9255275
github.com/prometheus/common => github.com/prometheus/common v0.0.0-20181126121408-4724e9255275
github.com/prometheus/procfs => github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a
github.com/prometheus/procfs => github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a
k8s.io/api => github.com/rancher/kubernetes/staging/src/k8s.io/api v1.18.
9
-k3s1
k8s.io/api => github.com/rancher/kubernetes/staging/src/k8s.io/api v1.18.
10
-k3s1
k8s.io/apiextensions-apiserver => github.com/rancher/kubernetes/staging/src/k8s.io/apiextensions-apiserver v1.18.
9
-k3s1
k8s.io/apiextensions-apiserver => github.com/rancher/kubernetes/staging/src/k8s.io/apiextensions-apiserver v1.18.
10
-k3s1
k8s.io/apimachinery => github.com/rancher/kubernetes/staging/src/k8s.io/apimachinery v1.18.
9
-k3s1
k8s.io/apimachinery => github.com/rancher/kubernetes/staging/src/k8s.io/apimachinery v1.18.
10
-k3s1
k8s.io/apiserver => github.com/rancher/kubernetes/staging/src/k8s.io/apiserver v1.18.
9
-k3s1
k8s.io/apiserver => github.com/rancher/kubernetes/staging/src/k8s.io/apiserver v1.18.
10
-k3s1
k8s.io/cli-runtime => github.com/rancher/kubernetes/staging/src/k8s.io/cli-runtime v1.18.
9
-k3s1
k8s.io/cli-runtime => github.com/rancher/kubernetes/staging/src/k8s.io/cli-runtime v1.18.
10
-k3s1
k8s.io/client-go => github.com/rancher/kubernetes/staging/src/k8s.io/client-go v1.18.
9
-k3s1
k8s.io/client-go => github.com/rancher/kubernetes/staging/src/k8s.io/client-go v1.18.
10
-k3s1
k8s.io/cloud-provider => github.com/rancher/kubernetes/staging/src/k8s.io/cloud-provider v1.18.
9
-k3s1
k8s.io/cloud-provider => github.com/rancher/kubernetes/staging/src/k8s.io/cloud-provider v1.18.
10
-k3s1
k8s.io/cluster-bootstrap => github.com/rancher/kubernetes/staging/src/k8s.io/cluster-bootstrap v1.18.
9
-k3s1
k8s.io/cluster-bootstrap => github.com/rancher/kubernetes/staging/src/k8s.io/cluster-bootstrap v1.18.
10
-k3s1
k8s.io/code-generator => github.com/rancher/kubernetes/staging/src/k8s.io/code-generator v1.18.
9
-k3s1
k8s.io/code-generator => github.com/rancher/kubernetes/staging/src/k8s.io/code-generator v1.18.
10
-k3s1
k8s.io/component-base => github.com/rancher/kubernetes/staging/src/k8s.io/component-base v1.18.
9
-k3s1
k8s.io/component-base => github.com/rancher/kubernetes/staging/src/k8s.io/component-base v1.18.
10
-k3s1
k8s.io/cri-api => github.com/rancher/kubernetes/staging/src/k8s.io/cri-api v1.18.
9
-k3s1
k8s.io/cri-api => github.com/rancher/kubernetes/staging/src/k8s.io/cri-api v1.18.
10
-k3s1
k8s.io/csi-translation-lib => github.com/rancher/kubernetes/staging/src/k8s.io/csi-translation-lib v1.18.
9
-k3s1
k8s.io/csi-translation-lib => github.com/rancher/kubernetes/staging/src/k8s.io/csi-translation-lib v1.18.
10
-k3s1
k8s.io/kube-aggregator => github.com/rancher/kubernetes/staging/src/k8s.io/kube-aggregator v1.18.
9
-k3s1
k8s.io/kube-aggregator => github.com/rancher/kubernetes/staging/src/k8s.io/kube-aggregator v1.18.
10
-k3s1
k8s.io/kube-controller-manager => github.com/rancher/kubernetes/staging/src/k8s.io/kube-controller-manager v1.18.
9
-k3s1
k8s.io/kube-controller-manager => github.com/rancher/kubernetes/staging/src/k8s.io/kube-controller-manager v1.18.
10
-k3s1
k8s.io/kube-proxy => github.com/rancher/kubernetes/staging/src/k8s.io/kube-proxy v1.18.
9
-k3s1
k8s.io/kube-proxy => github.com/rancher/kubernetes/staging/src/k8s.io/kube-proxy v1.18.
10
-k3s1
k8s.io/kube-scheduler => github.com/rancher/kubernetes/staging/src/k8s.io/kube-scheduler v1.18.
9
-k3s1
k8s.io/kube-scheduler => github.com/rancher/kubernetes/staging/src/k8s.io/kube-scheduler v1.18.
10
-k3s1
k8s.io/kubectl => github.com/rancher/kubernetes/staging/src/k8s.io/kubectl v1.18.
9
-k3s1
k8s.io/kubectl => github.com/rancher/kubernetes/staging/src/k8s.io/kubectl v1.18.
10
-k3s1
k8s.io/kubelet => github.com/rancher/kubernetes/staging/src/k8s.io/kubelet v1.18.
9
-k3s1
k8s.io/kubelet => github.com/rancher/kubernetes/staging/src/k8s.io/kubelet v1.18.
10
-k3s1
k8s.io/kubernetes => github.com/rancher/kubernetes v1.18.
9
-k3s1
k8s.io/kubernetes => github.com/rancher/kubernetes v1.18.
10
-k3s1
k8s.io/legacy-cloud-providers => github.com/rancher/kubernetes/staging/src/k8s.io/legacy-cloud-providers v1.18.
9
-k3s1
k8s.io/legacy-cloud-providers => github.com/rancher/kubernetes/staging/src/k8s.io/legacy-cloud-providers v1.18.
10
-k3s1
k8s.io/metrics => github.com/rancher/kubernetes/staging/src/k8s.io/metrics v1.18.
9
-k3s1
k8s.io/metrics => github.com/rancher/kubernetes/staging/src/k8s.io/metrics v1.18.
10
-k3s1
k8s.io/node-api => github.com/rancher/kubernetes/staging/src/k8s.io/node-api v1.18.
9
-k3s1
k8s.io/node-api => github.com/rancher/kubernetes/staging/src/k8s.io/node-api v1.18.
10
-k3s1
k8s.io/sample-apiserver => github.com/rancher/kubernetes/staging/src/k8s.io/sample-apiserver v1.18.
9
-k3s1
k8s.io/sample-apiserver => github.com/rancher/kubernetes/staging/src/k8s.io/sample-apiserver v1.18.
10
-k3s1
k8s.io/sample-cli-plugin => github.com/rancher/kubernetes/staging/src/k8s.io/sample-cli-plugin v1.18.
9
-k3s1
k8s.io/sample-cli-plugin => github.com/rancher/kubernetes/staging/src/k8s.io/sample-cli-plugin v1.18.
10
-k3s1
k8s.io/sample-controller => github.com/rancher/kubernetes/staging/src/k8s.io/sample-controller v1.18.
9
-k3s1
k8s.io/sample-controller => github.com/rancher/kubernetes/staging/src/k8s.io/sample-controller v1.18.
10
-k3s1
mvdan.cc/unparam => mvdan.cc/unparam v0.0.0-20190209190245-fbb59629db34
mvdan.cc/unparam => mvdan.cc/unparam v0.0.0-20190209190245-fbb59629db34
)
)
...
@@ -123,5 +123,5 @@ require (
...
@@ -123,5 +123,5 @@ require (
k8s.io/component-base v0.0.0
k8s.io/component-base v0.0.0
k8s.io/cri-api v0.0.0
k8s.io/cri-api v0.0.0
k8s.io/klog v1.0.0
k8s.io/klog v1.0.0
k8s.io/kubernetes v1.18.0
k8s.io/kubernetes v1.18.
1
0
)
)
go.sum
View file @
6fa97306
This diff is collapsed.
Click to expand it.
vendor/k8s.io/apiserver/pkg/storage/etcd3/store.go
View file @
6fa97306
...
@@ -440,6 +440,14 @@ func getNewItemFunc(listObj runtime.Object, v reflect.Value) func() runtime.Obje
...
@@ -440,6 +440,14 @@ func getNewItemFunc(listObj runtime.Object, v reflect.Value) func() runtime.Obje
func
(
s
*
store
)
Count
(
key
string
)
(
int64
,
error
)
{
func
(
s
*
store
)
Count
(
key
string
)
(
int64
,
error
)
{
key
=
path
.
Join
(
s
.
pathPrefix
,
key
)
key
=
path
.
Join
(
s
.
pathPrefix
,
key
)
// We need to make sure the key ended with "/" so that we only get children "directories".
// e.g. if we have key "/a", "/a/b", "/ab", getting keys with prefix "/a" will return all three,
// while with prefix "/a/" will return only "/a/b" which is the correct answer.
if
!
strings
.
HasSuffix
(
key
,
"/"
)
{
key
+=
"/"
}
startTime
:=
time
.
Now
()
startTime
:=
time
.
Now
()
getResp
,
err
:=
s
.
client
.
KV
.
Get
(
context
.
Background
(),
key
,
clientv3
.
WithRange
(
clientv3
.
GetPrefixRangeEnd
(
key
)),
clientv3
.
WithCountOnly
())
getResp
,
err
:=
s
.
client
.
KV
.
Get
(
context
.
Background
(),
key
,
clientv3
.
WithRange
(
clientv3
.
GetPrefixRangeEnd
(
key
)),
clientv3
.
WithCountOnly
())
metrics
.
RecordEtcdRequestLatency
(
"listWithCount"
,
key
,
startTime
)
metrics
.
RecordEtcdRequestLatency
(
"listWithCount"
,
key
,
startTime
)
...
...
vendor/k8s.io/client-go/pkg/version/base.go
View file @
6fa97306
...
@@ -3,8 +3,8 @@ package version
...
@@ -3,8 +3,8 @@ package version
var
(
var
(
gitMajor
=
"1"
gitMajor
=
"1"
gitMinor
=
"18"
gitMinor
=
"18"
gitVersion
=
"v1.18.
9
-k3s1"
gitVersion
=
"v1.18.
10
-k3s1"
gitCommit
=
"
f1d9dca4e9681e74faee7359af3cc2df01a4b6d6
"
gitCommit
=
"
c8d808cfc3c2c00c8d542b84e368ca439987e352
"
gitTreeState
=
"clean"
gitTreeState
=
"clean"
buildDate
=
"2020-
09-16T22:20:24
Z"
buildDate
=
"2020-
10-15T18:25:57
Z"
)
)
vendor/k8s.io/component-base/version/base.go
View file @
6fa97306
...
@@ -3,8 +3,8 @@ package version
...
@@ -3,8 +3,8 @@ package version
var
(
var
(
gitMajor
=
"1"
gitMajor
=
"1"
gitMinor
=
"18"
gitMinor
=
"18"
gitVersion
=
"v1.18.
9
-k3s1"
gitVersion
=
"v1.18.
10
-k3s1"
gitCommit
=
"
f1d9dca4e9681e74faee7359af3cc2df01a4b6d6
"
gitCommit
=
"
c8d808cfc3c2c00c8d542b84e368ca439987e352
"
gitTreeState
=
"clean"
gitTreeState
=
"clean"
buildDate
=
"2020-
09-16T22:20:24
Z"
buildDate
=
"2020-
10-15T18:25:57
Z"
)
)
vendor/k8s.io/kubectl/pkg/cmd/get/sorter.go
View file @
6fa97306
...
@@ -206,6 +206,13 @@ func isLess(i, j reflect.Value) (bool, error) {
...
@@ -206,6 +206,13 @@ func isLess(i, j reflect.Value) (bool, error) {
return
true
,
nil
return
true
,
nil
case
reflect
.
Interface
:
case
reflect
.
Interface
:
if
i
.
IsNil
()
&&
j
.
IsNil
()
{
return
false
,
nil
}
else
if
i
.
IsNil
()
{
return
true
,
nil
}
else
if
j
.
IsNil
()
{
return
false
,
nil
}
switch
itype
:=
i
.
Interface
()
.
(
type
)
{
switch
itype
:=
i
.
Interface
()
.
(
type
)
{
case
uint8
:
case
uint8
:
if
jtype
,
ok
:=
j
.
Interface
()
.
(
uint8
);
ok
{
if
jtype
,
ok
:=
j
.
Interface
()
.
(
uint8
);
ok
{
...
...
vendor/k8s.io/kubernetes/pkg/api/endpoints/BUILD
deleted
100644 → 0
View file @
3661f566
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
"go_test",
)
go_library(
name = "go_default_library",
srcs = ["util.go"],
importpath = "k8s.io/kubernetes/pkg/api/endpoints",
deps = [
"//pkg/apis/core:go_default_library",
"//pkg/util/hash:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
],
)
go_test(
name = "go_default_test",
srcs = ["util_test.go"],
embed = [":go_default_library"],
deps = [
"//pkg/apis/core:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
"//vendor/github.com/davecgh/go-spew/spew:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
)
vendor/k8s.io/kubernetes/pkg/api/endpoints/OWNERS
deleted
100644 → 0
View file @
3661f566
# See the OWNERS docs at https://go.k8s.io/owners
reviewers:
- thockin
- smarterclayton
- mikedanese
- sttts
- eparis
- resouer
- david-mcmahon
vendor/k8s.io/kubernetes/pkg/api/endpoints/util.go
deleted
100644 → 0
View file @
3661f566
/*
Copyright 2015 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package
endpoints
import
(
"bytes"
"crypto/md5"
"encoding/hex"
"hash"
"sort"
"k8s.io/apimachinery/pkg/types"
api
"k8s.io/kubernetes/pkg/apis/core"
hashutil
"k8s.io/kubernetes/pkg/util/hash"
)
// RepackSubsets takes a slice of EndpointSubset objects, expands it to the full
// representation, and then repacks that into the canonical layout. This
// ensures that code which operates on these objects can rely on the common
// form for things like comparison. The result is a newly allocated slice.
func
RepackSubsets
(
subsets
[]
api
.
EndpointSubset
)
[]
api
.
EndpointSubset
{
// First map each unique port definition to the sets of hosts that
// offer it.
allAddrs
:=
map
[
addressKey
]
*
api
.
EndpointAddress
{}
portToAddrReadyMap
:=
map
[
api
.
EndpointPort
]
addressSet
{}
for
i
:=
range
subsets
{
if
len
(
subsets
[
i
]
.
Ports
)
==
0
{
// Don't discard endpoints with no ports defined, use a sentinel.
mapAddressesByPort
(
&
subsets
[
i
],
api
.
EndpointPort
{
Port
:
-
1
},
allAddrs
,
portToAddrReadyMap
)
}
else
{
for
_
,
port
:=
range
subsets
[
i
]
.
Ports
{
mapAddressesByPort
(
&
subsets
[
i
],
port
,
allAddrs
,
portToAddrReadyMap
)
}
}
}
// Next, map the sets of hosts to the sets of ports they offer.
// Go does not allow maps or slices as keys to maps, so we have
// to synthesize an artificial key and do a sort of 2-part
// associative entity.
type
keyString
string
keyToAddrReadyMap
:=
map
[
keyString
]
addressSet
{}
addrReadyMapKeyToPorts
:=
map
[
keyString
][]
api
.
EndpointPort
{}
for
port
,
addrs
:=
range
portToAddrReadyMap
{
key
:=
keyString
(
hashAddresses
(
addrs
))
keyToAddrReadyMap
[
key
]
=
addrs
if
port
.
Port
>
0
{
// avoid sentinels
addrReadyMapKeyToPorts
[
key
]
=
append
(
addrReadyMapKeyToPorts
[
key
],
port
)
}
else
{
if
_
,
found
:=
addrReadyMapKeyToPorts
[
key
];
!
found
{
// Force it to be present in the map
addrReadyMapKeyToPorts
[
key
]
=
nil
}
}
}
// Next, build the N-to-M association the API wants.
final
:=
[]
api
.
EndpointSubset
{}
for
key
,
ports
:=
range
addrReadyMapKeyToPorts
{
var
readyAddrs
,
notReadyAddrs
[]
api
.
EndpointAddress
for
addr
,
ready
:=
range
keyToAddrReadyMap
[
key
]
{
if
ready
{
readyAddrs
=
append
(
readyAddrs
,
*
addr
)
}
else
{
notReadyAddrs
=
append
(
notReadyAddrs
,
*
addr
)
}
}
final
=
append
(
final
,
api
.
EndpointSubset
{
Addresses
:
readyAddrs
,
NotReadyAddresses
:
notReadyAddrs
,
Ports
:
ports
})
}
// Finally, sort it.
return
SortSubsets
(
final
)
}
// The sets of hosts must be de-duped, using IP+UID as the key.
type
addressKey
struct
{
ip
string
uid
types
.
UID
}
// mapAddressesByPort adds all ready and not-ready addresses into a map by a single port.
func
mapAddressesByPort
(
subset
*
api
.
EndpointSubset
,
port
api
.
EndpointPort
,
allAddrs
map
[
addressKey
]
*
api
.
EndpointAddress
,
portToAddrReadyMap
map
[
api
.
EndpointPort
]
addressSet
)
{
for
k
:=
range
subset
.
Addresses
{
mapAddressByPort
(
&
subset
.
Addresses
[
k
],
port
,
true
,
allAddrs
,
portToAddrReadyMap
)
}
for
k
:=
range
subset
.
NotReadyAddresses
{
mapAddressByPort
(
&
subset
.
NotReadyAddresses
[
k
],
port
,
false
,
allAddrs
,
portToAddrReadyMap
)
}
}
// mapAddressByPort adds one address into a map by port, registering the address with a unique pointer, and preserving
// any existing ready state.
func
mapAddressByPort
(
addr
*
api
.
EndpointAddress
,
port
api
.
EndpointPort
,
ready
bool
,
allAddrs
map
[
addressKey
]
*
api
.
EndpointAddress
,
portToAddrReadyMap
map
[
api
.
EndpointPort
]
addressSet
)
*
api
.
EndpointAddress
{
// use addressKey to distinguish between two endpoints that are identical addresses
// but may have come from different hosts, for attribution.
key
:=
addressKey
{
ip
:
addr
.
IP
}
if
addr
.
TargetRef
!=
nil
{
key
.
uid
=
addr
.
TargetRef
.
UID
}
// Accumulate the address. The full EndpointAddress structure is preserved for use when
// we rebuild the subsets so that the final TargetRef has all of the necessary data.
existingAddress
:=
allAddrs
[
key
]
if
existingAddress
==
nil
{
// Make a copy so we don't write to the
// input args of this function.
existingAddress
=
&
api
.
EndpointAddress
{}
*
existingAddress
=
*
addr
allAddrs
[
key
]
=
existingAddress
}
// Remember that this port maps to this address.
if
_
,
found
:=
portToAddrReadyMap
[
port
];
!
found
{
portToAddrReadyMap
[
port
]
=
addressSet
{}
}
// if we have not yet recorded this port for this address, or if the previous
// state was ready, write the current ready state. not ready always trumps
// ready.
if
wasReady
,
found
:=
portToAddrReadyMap
[
port
][
existingAddress
];
!
found
||
wasReady
{
portToAddrReadyMap
[
port
][
existingAddress
]
=
ready
}
return
existingAddress
}
type
addressSet
map
[
*
api
.
EndpointAddress
]
bool
type
addrReady
struct
{
addr
*
api
.
EndpointAddress
ready
bool
}
func
hashAddresses
(
addrs
addressSet
)
string
{
// Flatten the list of addresses into a string so it can be used as a
// map key. Unfortunately, DeepHashObject is implemented in terms of
// spew, and spew does not handle non-primitive map keys well. So
// first we collapse it into a slice, sort the slice, then hash that.
slice
:=
make
([]
addrReady
,
0
,
len
(
addrs
))
for
k
,
ready
:=
range
addrs
{
slice
=
append
(
slice
,
addrReady
{
k
,
ready
})
}
sort
.
Sort
(
addrsReady
(
slice
))
hasher
:=
md5
.
New
()
hashutil
.
DeepHashObject
(
hasher
,
slice
)
return
hex
.
EncodeToString
(
hasher
.
Sum
(
nil
)[
0
:
])
}
func
lessAddrReady
(
a
,
b
addrReady
)
bool
{
// ready is not significant to hashing since we can't have duplicate addresses
return
LessEndpointAddress
(
a
.
addr
,
b
.
addr
)
}
type
addrsReady
[]
addrReady
func
(
sl
addrsReady
)
Len
()
int
{
return
len
(
sl
)
}
func
(
sl
addrsReady
)
Swap
(
i
,
j
int
)
{
sl
[
i
],
sl
[
j
]
=
sl
[
j
],
sl
[
i
]
}
func
(
sl
addrsReady
)
Less
(
i
,
j
int
)
bool
{
return
lessAddrReady
(
sl
[
i
],
sl
[
j
])
}
// LessEndpointAddress compares IP addresses lexicographically and returns true if first argument is lesser than second
func
LessEndpointAddress
(
a
,
b
*
api
.
EndpointAddress
)
bool
{
ipComparison
:=
bytes
.
Compare
([]
byte
(
a
.
IP
),
[]
byte
(
b
.
IP
))
if
ipComparison
!=
0
{
return
ipComparison
<
0
}
if
b
.
TargetRef
==
nil
{
return
false
}
if
a
.
TargetRef
==
nil
{
return
true
}
return
a
.
TargetRef
.
UID
<
b
.
TargetRef
.
UID
}
// SortSubsets sorts an array of EndpointSubset objects in place. For ease of
// use it returns the input slice.
func
SortSubsets
(
subsets
[]
api
.
EndpointSubset
)
[]
api
.
EndpointSubset
{
for
i
:=
range
subsets
{
ss
:=
&
subsets
[
i
]
sort
.
Sort
(
addrsByIPAndUID
(
ss
.
Addresses
))
sort
.
Sort
(
addrsByIPAndUID
(
ss
.
NotReadyAddresses
))
sort
.
Sort
(
portsByHash
(
ss
.
Ports
))
}
sort
.
Sort
(
subsetsByHash
(
subsets
))
return
subsets
}
func
hashObject
(
hasher
hash
.
Hash
,
obj
interface
{})
[]
byte
{
hashutil
.
DeepHashObject
(
hasher
,
obj
)
return
hasher
.
Sum
(
nil
)
}
type
subsetsByHash
[]
api
.
EndpointSubset
func
(
sl
subsetsByHash
)
Len
()
int
{
return
len
(
sl
)
}
func
(
sl
subsetsByHash
)
Swap
(
i
,
j
int
)
{
sl
[
i
],
sl
[
j
]
=
sl
[
j
],
sl
[
i
]
}
func
(
sl
subsetsByHash
)
Less
(
i
,
j
int
)
bool
{
hasher
:=
md5
.
New
()
h1
:=
hashObject
(
hasher
,
sl
[
i
])
h2
:=
hashObject
(
hasher
,
sl
[
j
])
return
bytes
.
Compare
(
h1
,
h2
)
<
0
}
type
addrsByIPAndUID
[]
api
.
EndpointAddress
func
(
sl
addrsByIPAndUID
)
Len
()
int
{
return
len
(
sl
)
}
func
(
sl
addrsByIPAndUID
)
Swap
(
i
,
j
int
)
{
sl
[
i
],
sl
[
j
]
=
sl
[
j
],
sl
[
i
]
}
func
(
sl
addrsByIPAndUID
)
Less
(
i
,
j
int
)
bool
{
return
LessEndpointAddress
(
&
sl
[
i
],
&
sl
[
j
])
}
type
portsByHash
[]
api
.
EndpointPort
func
(
sl
portsByHash
)
Len
()
int
{
return
len
(
sl
)
}
func
(
sl
portsByHash
)
Swap
(
i
,
j
int
)
{
sl
[
i
],
sl
[
j
]
=
sl
[
j
],
sl
[
i
]
}
func
(
sl
portsByHash
)
Less
(
i
,
j
int
)
bool
{
hasher
:=
md5
.
New
()
h1
:=
hashObject
(
hasher
,
sl
[
i
])
h2
:=
hashObject
(
hasher
,
sl
[
j
])
return
bytes
.
Compare
(
h1
,
h2
)
<
0
}
vendor/k8s.io/kubernetes/pkg/client/leaderelectionconfig/config.go
View file @
6fa97306
...
@@ -42,7 +42,8 @@ func BindFlags(l *componentbaseconfig.LeaderElectionConfiguration, fs *pflag.Fla
...
@@ -42,7 +42,8 @@ func BindFlags(l *componentbaseconfig.LeaderElectionConfiguration, fs *pflag.Fla
"of a leadership. This is only applicable if leader election is enabled."
)
"of a leadership. This is only applicable if leader election is enabled."
)
fs
.
StringVar
(
&
l
.
ResourceLock
,
"leader-elect-resource-lock"
,
l
.
ResourceLock
,
""
+
fs
.
StringVar
(
&
l
.
ResourceLock
,
"leader-elect-resource-lock"
,
l
.
ResourceLock
,
""
+
"The type of resource object that is used for locking during "
+
"The type of resource object that is used for locking during "
+
"leader election. Supported options are `endpoints` (default) and `configmaps`."
)
"leader election. Supported options are 'endpoints', 'configmaps', "
+
"'leases', 'endpointsleases' and 'configmapsleases'."
)
fs
.
StringVar
(
&
l
.
ResourceName
,
"leader-elect-resource-name"
,
l
.
ResourceName
,
""
+
fs
.
StringVar
(
&
l
.
ResourceName
,
"leader-elect-resource-name"
,
l
.
ResourceName
,
""
+
"The name of resource object that is used for locking during "
+
"The name of resource object that is used for locking during "
+
"leader election."
)
"leader election."
)
...
...
vendor/k8s.io/kubernetes/pkg/controller/endpoint/endpoints_controller.go
View file @
6fa97306
...
@@ -455,9 +455,18 @@ func (e *EndpointController) syncService(key string) error {
...
@@ -455,9 +455,18 @@ func (e *EndpointController) syncService(key string) error {
createEndpoints
:=
len
(
currentEndpoints
.
ResourceVersion
)
==
0
createEndpoints
:=
len
(
currentEndpoints
.
ResourceVersion
)
==
0
// Compare the sorted subsets and labels
// Remove the HeadlessService label from the endpoints if it exists,
// as this won't be set on the service itself
// and will cause a false negative in this diff check.
// But first check if it has that label to avoid expensive copies.
compareLabels
:=
currentEndpoints
.
Labels
if
_
,
ok
:=
currentEndpoints
.
Labels
[
v1
.
IsHeadlessService
];
ok
{
compareLabels
=
utillabels
.
CloneAndRemoveLabel
(
currentEndpoints
.
Labels
,
v1
.
IsHeadlessService
)
}
if
!
createEndpoints
&&
if
!
createEndpoints
&&
apiequality
.
Semantic
.
DeepEqual
(
currentEndpoints
.
Subsets
,
subsets
)
&&
apiequality
.
Semantic
.
DeepEqual
(
currentEndpoints
.
Subsets
,
subsets
)
&&
apiequality
.
Semantic
.
DeepEqual
(
c
urrentEndpoints
.
Labels
,
service
.
Labels
)
{
apiequality
.
Semantic
.
DeepEqual
(
c
ompare
Labels
,
service
.
Labels
)
{
klog
.
V
(
5
)
.
Infof
(
"endpoints are equal for %s/%s, skipping update"
,
service
.
Namespace
,
service
.
Name
)
klog
.
V
(
5
)
.
Infof
(
"endpoints are equal for %s/%s, skipping update"
,
service
.
Namespace
,
service
.
Name
)
return
nil
return
nil
}
}
...
...
vendor/k8s.io/kubernetes/pkg/credentialprovider/config.go
View file @
6fa97306
...
@@ -114,10 +114,14 @@ func ReadDockercfgFile(searchPaths []string) (cfg DockerConfig, err error) {
...
@@ -114,10 +114,14 @@ func ReadDockercfgFile(searchPaths []string) (cfg DockerConfig, err error) {
continue
continue
}
}
cfg
,
err
:=
readDockerConfigFileFromBytes
(
contents
)
cfg
,
err
:=
readDockerConfigFileFromBytes
(
contents
)
if
err
=
=
nil
{
if
err
!
=
nil
{
klog
.
V
(
4
)
.
Infof
(
"
found .dockercfg at %s"
,
absDockerConfigFileLocation
)
klog
.
V
(
4
)
.
Infof
(
"
couldn't get the config from %q contents: %v"
,
absDockerConfigFileLocation
,
err
)
return
cfg
,
nil
continue
}
}
klog
.
V
(
4
)
.
Infof
(
"found .dockercfg at %s"
,
absDockerConfigFileLocation
)
return
cfg
,
nil
}
}
return
nil
,
fmt
.
Errorf
(
"couldn't find valid .dockercfg after checking in %v"
,
searchPaths
)
return
nil
,
fmt
.
Errorf
(
"couldn't find valid .dockercfg after checking in %v"
,
searchPaths
)
}
}
...
@@ -224,8 +228,7 @@ func ReadDockerConfigFileFromUrl(url string, client *http.Client, header *http.H
...
@@ -224,8 +228,7 @@ func ReadDockerConfigFileFromUrl(url string, client *http.Client, header *http.H
func
readDockerConfigFileFromBytes
(
contents
[]
byte
)
(
cfg
DockerConfig
,
err
error
)
{
func
readDockerConfigFileFromBytes
(
contents
[]
byte
)
(
cfg
DockerConfig
,
err
error
)
{
if
err
=
json
.
Unmarshal
(
contents
,
&
cfg
);
err
!=
nil
{
if
err
=
json
.
Unmarshal
(
contents
,
&
cfg
);
err
!=
nil
{
klog
.
Errorf
(
"while trying to parse blob %q: %v"
,
contents
,
err
)
return
nil
,
errors
.
New
(
"error occurred while trying to unmarshal json"
)
return
nil
,
err
}
}
return
return
}
}
...
@@ -233,8 +236,7 @@ func readDockerConfigFileFromBytes(contents []byte) (cfg DockerConfig, err error
...
@@ -233,8 +236,7 @@ func readDockerConfigFileFromBytes(contents []byte) (cfg DockerConfig, err error
func
readDockerConfigJsonFileFromBytes
(
contents
[]
byte
)
(
cfg
DockerConfig
,
err
error
)
{
func
readDockerConfigJsonFileFromBytes
(
contents
[]
byte
)
(
cfg
DockerConfig
,
err
error
)
{
var
cfgJson
DockerConfigJson
var
cfgJson
DockerConfigJson
if
err
=
json
.
Unmarshal
(
contents
,
&
cfgJson
);
err
!=
nil
{
if
err
=
json
.
Unmarshal
(
contents
,
&
cfgJson
);
err
!=
nil
{
klog
.
Errorf
(
"while trying to parse blob %q: %v"
,
contents
,
err
)
return
nil
,
errors
.
New
(
"error occurred while trying to unmarshal json"
)
return
nil
,
err
}
}
cfg
=
cfgJson
.
Auths
cfg
=
cfgJson
.
Auths
return
return
...
...
vendor/k8s.io/kubernetes/pkg/proxy/endpoints.go
View file @
6fa97306
...
@@ -161,7 +161,10 @@ func (ect *EndpointChangeTracker) Update(previous, current *v1.Endpoints) bool {
...
@@ -161,7 +161,10 @@ func (ect *EndpointChangeTracker) Update(previous, current *v1.Endpoints) bool {
ect
.
items
[
namespacedName
]
=
change
ect
.
items
[
namespacedName
]
=
change
}
}
if
t
:=
getLastChangeTriggerTime
(
endpoints
.
Annotations
);
!
t
.
IsZero
()
{
// In case of Endpoints deletion, the LastChangeTriggerTime annotation is
// by-definition coming from the time of last update, which is not what
// we want to measure. So we simply ignore it in this cases.
if
t
:=
getLastChangeTriggerTime
(
endpoints
.
Annotations
);
!
t
.
IsZero
()
&&
current
!=
nil
{
ect
.
lastChangeTriggerTimes
[
namespacedName
]
=
append
(
ect
.
lastChangeTriggerTimes
[
namespacedName
],
t
)
ect
.
lastChangeTriggerTimes
[
namespacedName
]
=
append
(
ect
.
lastChangeTriggerTimes
[
namespacedName
],
t
)
}
}
...
@@ -212,7 +215,12 @@ func (ect *EndpointChangeTracker) EndpointSliceUpdate(endpointSlice *discovery.E
...
@@ -212,7 +215,12 @@ func (ect *EndpointChangeTracker) EndpointSliceUpdate(endpointSlice *discovery.E
if
changeNeeded
{
if
changeNeeded
{
metrics
.
EndpointChangesPending
.
Inc
()
metrics
.
EndpointChangesPending
.
Inc
()
if
t
:=
getLastChangeTriggerTime
(
endpointSlice
.
Annotations
);
!
t
.
IsZero
()
{
// In case of Endpoints deletion, the LastChangeTriggerTime annotation is
// by-definition coming from the time of last update, which is not what
// we want to measure. So we simply ignore it in this cases.
// TODO(wojtek-t, robscott): Address the problem for EndpointSlice deletion
// when other EndpointSlice for that service still exist.
if
t
:=
getLastChangeTriggerTime
(
endpointSlice
.
Annotations
);
!
t
.
IsZero
()
&&
!
removeSlice
{
ect
.
lastChangeTriggerTimes
[
namespacedName
]
=
ect
.
lastChangeTriggerTimes
[
namespacedName
]
=
append
(
ect
.
lastChangeTriggerTimes
[
namespacedName
],
t
)
append
(
ect
.
lastChangeTriggerTimes
[
namespacedName
],
t
)
}
}
...
...
vendor/k8s.io/kubernetes/pkg/registry/core/endpoint/BUILD
View file @
6fa97306
...
@@ -13,7 +13,6 @@ go_library(
...
@@ -13,7 +13,6 @@ go_library(
],
],
importpath = "k8s.io/kubernetes/pkg/registry/core/endpoint",
importpath = "k8s.io/kubernetes/pkg/registry/core/endpoint",
deps = [
deps = [
"//pkg/api/endpoints:go_default_library",
"//pkg/api/legacyscheme:go_default_library",
"//pkg/api/legacyscheme:go_default_library",
"//pkg/apis/core:go_default_library",
"//pkg/apis/core:go_default_library",
"//pkg/apis/core/validation:go_default_library",
"//pkg/apis/core/validation:go_default_library",
...
...
vendor/k8s.io/kubernetes/pkg/registry/core/endpoint/strategy.go
View file @
6fa97306
...
@@ -22,7 +22,6 @@ import (
...
@@ -22,7 +22,6 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field"
"k8s.io/apimachinery/pkg/util/validation/field"
"k8s.io/apiserver/pkg/storage/names"
"k8s.io/apiserver/pkg/storage/names"
endptspkg
"k8s.io/kubernetes/pkg/api/endpoints"
"k8s.io/kubernetes/pkg/api/legacyscheme"
"k8s.io/kubernetes/pkg/api/legacyscheme"
api
"k8s.io/kubernetes/pkg/apis/core"
api
"k8s.io/kubernetes/pkg/apis/core"
"k8s.io/kubernetes/pkg/apis/core/validation"
"k8s.io/kubernetes/pkg/apis/core/validation"
...
@@ -60,8 +59,6 @@ func (endpointsStrategy) Validate(ctx context.Context, obj runtime.Object) field
...
@@ -60,8 +59,6 @@ func (endpointsStrategy) Validate(ctx context.Context, obj runtime.Object) field
// Canonicalize normalizes the object after validation.
// Canonicalize normalizes the object after validation.
func
(
endpointsStrategy
)
Canonicalize
(
obj
runtime
.
Object
)
{
func
(
endpointsStrategy
)
Canonicalize
(
obj
runtime
.
Object
)
{
endpoints
:=
obj
.
(
*
api
.
Endpoints
)
endpoints
.
Subsets
=
endptspkg
.
RepackSubsets
(
endpoints
.
Subsets
)
}
}
// AllowCreateOnUpdate is true for endpoints.
// AllowCreateOnUpdate is true for endpoints.
...
...
vendor/k8s.io/kubernetes/pkg/scheduler/framework/plugins/interpodaffinity/filtering.go
View file @
6fa97306
...
@@ -229,13 +229,13 @@ func getTPMapMatchingExistingAntiAffinity(pod *v1.Pod, allNodes []*nodeinfo.Node
...
@@ -229,13 +229,13 @@ func getTPMapMatchingExistingAntiAffinity(pod *v1.Pod, allNodes []*nodeinfo.Node
klog
.
Error
(
"node not found"
)
klog
.
Error
(
"node not found"
)
return
return
}
}
for
_
,
existingPod
:=
range
nodeInfo
.
PodsWithAffinity
()
{
for
_
,
existingPod
:=
range
nodeInfo
.
PodsWith
RequiredAnti
Affinity
()
{
existingPodTopologyMaps
,
err
:=
getMatchingAntiAffinityTopologyPairsOfPod
(
pod
,
existingPod
,
node
)
existingPodTopologyMaps
,
err
:=
getMatchingAntiAffinityTopologyPairsOfPod
(
pod
,
existingPod
,
node
)
if
err
!=
nil
{
if
err
!=
nil
{
errCh
.
SendErrorWithCancel
(
err
,
cancel
)
errCh
.
SendErrorWithCancel
(
err
,
cancel
)
return
return
}
}
if
existingPodTopologyMaps
!=
nil
{
if
len
(
existingPodTopologyMaps
)
!=
0
{
appendResult
(
existingPodTopologyMaps
)
appendResult
(
existingPodTopologyMaps
)
}
}
}
}
...
@@ -334,7 +334,7 @@ func (pl *InterPodAffinity) PreFilter(ctx context.Context, cycleState *framework
...
@@ -334,7 +334,7 @@ func (pl *InterPodAffinity) PreFilter(ctx context.Context, cycleState *framework
if
allNodes
,
err
=
pl
.
sharedLister
.
NodeInfos
()
.
List
();
err
!=
nil
{
if
allNodes
,
err
=
pl
.
sharedLister
.
NodeInfos
()
.
List
();
err
!=
nil
{
return
framework
.
NewStatus
(
framework
.
Error
,
fmt
.
Sprintf
(
"failed to list NodeInfos: %v"
,
err
))
return
framework
.
NewStatus
(
framework
.
Error
,
fmt
.
Sprintf
(
"failed to list NodeInfos: %v"
,
err
))
}
}
if
havePodsWithAffinityNodes
,
err
=
pl
.
sharedLister
.
NodeInfos
()
.
HavePodsWithAffinityList
();
err
!=
nil
{
if
havePodsWithAffinityNodes
,
err
=
pl
.
sharedLister
.
NodeInfos
()
.
HavePodsWith
RequiredAnti
AffinityList
();
err
!=
nil
{
return
framework
.
NewStatus
(
framework
.
Error
,
fmt
.
Sprintf
(
"failed to list NodeInfos with pods with affinity: %v"
,
err
))
return
framework
.
NewStatus
(
framework
.
Error
,
fmt
.
Sprintf
(
"failed to list NodeInfos with pods with affinity: %v"
,
err
))
}
}
...
...
vendor/k8s.io/kubernetes/pkg/scheduler/internal/cache/cache.go
View file @
6fa97306
...
@@ -196,6 +196,8 @@ func (cache *schedulerCache) Dump() *Dump {
...
@@ -196,6 +196,8 @@ func (cache *schedulerCache) Dump() *Dump {
// UpdateSnapshot takes a snapshot of cached NodeInfo map. This is called at
// UpdateSnapshot takes a snapshot of cached NodeInfo map. This is called at
// beginning of every scheduling cycle.
// beginning of every scheduling cycle.
// The snapshot only includes Nodes that are not deleted at the time this function is called.
// nodeinfo.Node() is guaranteed to be not nil for all the nodes in the snapshot.
// This function tracks generation number of NodeInfo and updates only the
// This function tracks generation number of NodeInfo and updates only the
// entries of an existing snapshot that have changed after the snapshot was taken.
// entries of an existing snapshot that have changed after the snapshot was taken.
func
(
cache
*
schedulerCache
)
UpdateSnapshot
(
nodeSnapshot
*
Snapshot
)
error
{
func
(
cache
*
schedulerCache
)
UpdateSnapshot
(
nodeSnapshot
*
Snapshot
)
error
{
...
@@ -213,6 +215,10 @@ func (cache *schedulerCache) UpdateSnapshot(nodeSnapshot *Snapshot) error {
...
@@ -213,6 +215,10 @@ func (cache *schedulerCache) UpdateSnapshot(nodeSnapshot *Snapshot) error {
// status from having pods with affinity to NOT having pods with affinity or the other
// status from having pods with affinity to NOT having pods with affinity or the other
// way around.
// way around.
updateNodesHavePodsWithAffinity
:=
false
updateNodesHavePodsWithAffinity
:=
false
// HavePodsWithRequiredAntiAffinityNodeInfoList must be re-created if a node changed its
// status from having pods with required anti-affinity to NOT having pods with required
// anti-affinity or the other way around.
updateNodesHavePodsWithRequiredAntiAffinity
:=
false
// Start from the head of the NodeInfo doubly linked list and update snapshot
// Start from the head of the NodeInfo doubly linked list and update snapshot
// of NodeInfos updated after the last snapshot.
// of NodeInfos updated after the last snapshot.
...
@@ -239,6 +245,9 @@ func (cache *schedulerCache) UpdateSnapshot(nodeSnapshot *Snapshot) error {
...
@@ -239,6 +245,9 @@ func (cache *schedulerCache) UpdateSnapshot(nodeSnapshot *Snapshot) error {
if
(
len
(
existing
.
PodsWithAffinity
())
>
0
)
!=
(
len
(
clone
.
PodsWithAffinity
())
>
0
)
{
if
(
len
(
existing
.
PodsWithAffinity
())
>
0
)
!=
(
len
(
clone
.
PodsWithAffinity
())
>
0
)
{
updateNodesHavePodsWithAffinity
=
true
updateNodesHavePodsWithAffinity
=
true
}
}
if
(
len
(
existing
.
PodsWithRequiredAntiAffinity
())
>
0
)
!=
(
len
(
clone
.
PodsWithRequiredAntiAffinity
())
>
0
)
{
updateNodesHavePodsWithRequiredAntiAffinity
=
true
}
// We need to preserve the original pointer of the NodeInfo struct since it
// We need to preserve the original pointer of the NodeInfo struct since it
// is used in the NodeInfoList, which we may not update.
// is used in the NodeInfoList, which we may not update.
*
existing
=
*
clone
*
existing
=
*
clone
...
@@ -249,12 +258,15 @@ func (cache *schedulerCache) UpdateSnapshot(nodeSnapshot *Snapshot) error {
...
@@ -249,12 +258,15 @@ func (cache *schedulerCache) UpdateSnapshot(nodeSnapshot *Snapshot) error {
nodeSnapshot
.
generation
=
cache
.
headNode
.
info
.
GetGeneration
()
nodeSnapshot
.
generation
=
cache
.
headNode
.
info
.
GetGeneration
()
}
}
if
len
(
nodeSnapshot
.
nodeInfoMap
)
>
len
(
cache
.
nodes
)
{
// Comparing to pods in nodeTree.
// Deleted nodes get removed from the tree, but they might remain in the nodes map
// if they still have non-deleted Pods.
if
len
(
nodeSnapshot
.
nodeInfoMap
)
>
cache
.
nodeTree
.
numNodes
{
cache
.
removeDeletedNodesFromSnapshot
(
nodeSnapshot
)
cache
.
removeDeletedNodesFromSnapshot
(
nodeSnapshot
)
updateAllLists
=
true
updateAllLists
=
true
}
}
if
updateAllLists
||
updateNodesHavePodsWithAffinity
{
if
updateAllLists
||
updateNodesHavePodsWithAffinity
||
updateNodesHavePodsWithRequiredAntiAffinity
{
cache
.
updateNodeInfoSnapshotList
(
nodeSnapshot
,
updateAllLists
)
cache
.
updateNodeInfoSnapshotList
(
nodeSnapshot
,
updateAllLists
)
}
}
...
@@ -276,6 +288,7 @@ func (cache *schedulerCache) UpdateSnapshot(nodeSnapshot *Snapshot) error {
...
@@ -276,6 +288,7 @@ func (cache *schedulerCache) UpdateSnapshot(nodeSnapshot *Snapshot) error {
func
(
cache
*
schedulerCache
)
updateNodeInfoSnapshotList
(
snapshot
*
Snapshot
,
updateAll
bool
)
{
func
(
cache
*
schedulerCache
)
updateNodeInfoSnapshotList
(
snapshot
*
Snapshot
,
updateAll
bool
)
{
snapshot
.
havePodsWithAffinityNodeInfoList
=
make
([]
*
schedulernodeinfo
.
NodeInfo
,
0
,
cache
.
nodeTree
.
numNodes
)
snapshot
.
havePodsWithAffinityNodeInfoList
=
make
([]
*
schedulernodeinfo
.
NodeInfo
,
0
,
cache
.
nodeTree
.
numNodes
)
snapshot
.
havePodsWithRequiredAntiAffinityNodeInfoList
=
make
([]
*
schedulernodeinfo
.
NodeInfo
,
0
,
cache
.
nodeTree
.
numNodes
)
if
updateAll
{
if
updateAll
{
// Take a snapshot of the nodes order in the tree
// Take a snapshot of the nodes order in the tree
snapshot
.
nodeInfoList
=
make
([]
*
schedulernodeinfo
.
NodeInfo
,
0
,
cache
.
nodeTree
.
numNodes
)
snapshot
.
nodeInfoList
=
make
([]
*
schedulernodeinfo
.
NodeInfo
,
0
,
cache
.
nodeTree
.
numNodes
)
...
@@ -287,6 +300,9 @@ func (cache *schedulerCache) updateNodeInfoSnapshotList(snapshot *Snapshot, upda
...
@@ -287,6 +300,9 @@ func (cache *schedulerCache) updateNodeInfoSnapshotList(snapshot *Snapshot, upda
if
len
(
n
.
PodsWithAffinity
())
>
0
{
if
len
(
n
.
PodsWithAffinity
())
>
0
{
snapshot
.
havePodsWithAffinityNodeInfoList
=
append
(
snapshot
.
havePodsWithAffinityNodeInfoList
,
n
)
snapshot
.
havePodsWithAffinityNodeInfoList
=
append
(
snapshot
.
havePodsWithAffinityNodeInfoList
,
n
)
}
}
if
len
(
n
.
PodsWithRequiredAntiAffinity
())
>
0
{
snapshot
.
havePodsWithRequiredAntiAffinityNodeInfoList
=
append
(
snapshot
.
havePodsWithRequiredAntiAffinityNodeInfoList
,
n
)
}
}
else
{
}
else
{
klog
.
Errorf
(
"node %q exist in nodeTree but not in NodeInfoMap, this should not happen."
,
nodeName
)
klog
.
Errorf
(
"node %q exist in nodeTree but not in NodeInfoMap, this should not happen."
,
nodeName
)
}
}
...
@@ -296,18 +312,21 @@ func (cache *schedulerCache) updateNodeInfoSnapshotList(snapshot *Snapshot, upda
...
@@ -296,18 +312,21 @@ func (cache *schedulerCache) updateNodeInfoSnapshotList(snapshot *Snapshot, upda
if
len
(
n
.
PodsWithAffinity
())
>
0
{
if
len
(
n
.
PodsWithAffinity
())
>
0
{
snapshot
.
havePodsWithAffinityNodeInfoList
=
append
(
snapshot
.
havePodsWithAffinityNodeInfoList
,
n
)
snapshot
.
havePodsWithAffinityNodeInfoList
=
append
(
snapshot
.
havePodsWithAffinityNodeInfoList
,
n
)
}
}
if
len
(
n
.
PodsWithRequiredAntiAffinity
())
>
0
{
snapshot
.
havePodsWithRequiredAntiAffinityNodeInfoList
=
append
(
snapshot
.
havePodsWithRequiredAntiAffinityNodeInfoList
,
n
)
}
}
}
}
}
}
}
// If certain nodes were deleted after the last snapshot was taken, we should remove them from the snapshot.
// If certain nodes were deleted after the last snapshot was taken, we should remove them from the snapshot.
func
(
cache
*
schedulerCache
)
removeDeletedNodesFromSnapshot
(
snapshot
*
Snapshot
)
{
func
(
cache
*
schedulerCache
)
removeDeletedNodesFromSnapshot
(
snapshot
*
Snapshot
)
{
toDelete
:=
len
(
snapshot
.
nodeInfoMap
)
-
len
(
cache
.
nodes
)
toDelete
:=
len
(
snapshot
.
nodeInfoMap
)
-
cache
.
nodeTree
.
numNodes
for
name
:=
range
snapshot
.
nodeInfoMap
{
for
name
:=
range
snapshot
.
nodeInfoMap
{
if
toDelete
<=
0
{
if
toDelete
<=
0
{
break
break
}
}
if
_
,
ok
:=
cache
.
nodes
[
name
];
!
ok
{
if
n
,
ok
:=
cache
.
nodes
[
name
];
!
ok
||
n
.
info
.
Node
()
==
nil
{
delete
(
snapshot
.
nodeInfoMap
,
name
)
delete
(
snapshot
.
nodeInfoMap
,
name
)
toDelete
--
toDelete
--
}
}
...
...
vendor/k8s.io/kubernetes/pkg/scheduler/internal/cache/interface.go
View file @
6fa97306
...
@@ -99,6 +99,8 @@ type Cache interface {
...
@@ -99,6 +99,8 @@ type Cache interface {
// UpdateSnapshot updates the passed infoSnapshot to the current contents of Cache.
// UpdateSnapshot updates the passed infoSnapshot to the current contents of Cache.
// The node info contains aggregated information of pods scheduled (including assumed to be)
// The node info contains aggregated information of pods scheduled (including assumed to be)
// on this node.
// on this node.
// The snapshot only includes Nodes that are not deleted at the time this function is called.
// nodeinfo.Node() is guaranteed to be not nil for all the nodes in the snapshot.
UpdateSnapshot
(
nodeSnapshot
*
Snapshot
)
error
UpdateSnapshot
(
nodeSnapshot
*
Snapshot
)
error
// Dump produces a dump of the current cache.
// Dump produces a dump of the current cache.
...
...
vendor/k8s.io/kubernetes/pkg/scheduler/internal/cache/snapshot.go
View file @
6fa97306
...
@@ -35,7 +35,10 @@ type Snapshot struct {
...
@@ -35,7 +35,10 @@ type Snapshot struct {
nodeInfoList
[]
*
schedulernodeinfo
.
NodeInfo
nodeInfoList
[]
*
schedulernodeinfo
.
NodeInfo
// havePodsWithAffinityNodeInfoList is the list of nodes with at least one pod declaring affinity terms.
// havePodsWithAffinityNodeInfoList is the list of nodes with at least one pod declaring affinity terms.
havePodsWithAffinityNodeInfoList
[]
*
schedulernodeinfo
.
NodeInfo
havePodsWithAffinityNodeInfoList
[]
*
schedulernodeinfo
.
NodeInfo
generation
int64
// havePodsWithRequiredAntiAffinityNodeInfoList is the list of nodes with at least one
// pod declaring required anti-affinity terms.
havePodsWithRequiredAntiAffinityNodeInfoList
[]
*
schedulernodeinfo
.
NodeInfo
generation
int64
}
}
var
_
schedulerlisters
.
SharedLister
=
&
Snapshot
{}
var
_
schedulerlisters
.
SharedLister
=
&
Snapshot
{}
...
@@ -52,17 +55,22 @@ func NewSnapshot(pods []*v1.Pod, nodes []*v1.Node) *Snapshot {
...
@@ -52,17 +55,22 @@ func NewSnapshot(pods []*v1.Pod, nodes []*v1.Node) *Snapshot {
nodeInfoMap
:=
createNodeInfoMap
(
pods
,
nodes
)
nodeInfoMap
:=
createNodeInfoMap
(
pods
,
nodes
)
nodeInfoList
:=
make
([]
*
schedulernodeinfo
.
NodeInfo
,
0
,
len
(
nodeInfoMap
))
nodeInfoList
:=
make
([]
*
schedulernodeinfo
.
NodeInfo
,
0
,
len
(
nodeInfoMap
))
havePodsWithAffinityNodeInfoList
:=
make
([]
*
schedulernodeinfo
.
NodeInfo
,
0
,
len
(
nodeInfoMap
))
havePodsWithAffinityNodeInfoList
:=
make
([]
*
schedulernodeinfo
.
NodeInfo
,
0
,
len
(
nodeInfoMap
))
havePodsWithRequiredAntiAffinityNodeInfoList
:=
make
([]
*
schedulernodeinfo
.
NodeInfo
,
0
,
len
(
nodeInfoMap
))
for
_
,
v
:=
range
nodeInfoMap
{
for
_
,
v
:=
range
nodeInfoMap
{
nodeInfoList
=
append
(
nodeInfoList
,
v
)
nodeInfoList
=
append
(
nodeInfoList
,
v
)
if
len
(
v
.
PodsWithAffinity
())
>
0
{
if
len
(
v
.
PodsWithAffinity
())
>
0
{
havePodsWithAffinityNodeInfoList
=
append
(
havePodsWithAffinityNodeInfoList
,
v
)
havePodsWithAffinityNodeInfoList
=
append
(
havePodsWithAffinityNodeInfoList
,
v
)
}
}
if
len
(
v
.
PodsWithRequiredAntiAffinity
())
>
0
{
havePodsWithRequiredAntiAffinityNodeInfoList
=
append
(
havePodsWithRequiredAntiAffinityNodeInfoList
,
v
)
}
}
}
s
:=
NewEmptySnapshot
()
s
:=
NewEmptySnapshot
()
s
.
nodeInfoMap
=
nodeInfoMap
s
.
nodeInfoMap
=
nodeInfoMap
s
.
nodeInfoList
=
nodeInfoList
s
.
nodeInfoList
=
nodeInfoList
s
.
havePodsWithAffinityNodeInfoList
=
havePodsWithAffinityNodeInfoList
s
.
havePodsWithAffinityNodeInfoList
=
havePodsWithAffinityNodeInfoList
s
.
havePodsWithRequiredAntiAffinityNodeInfoList
=
havePodsWithRequiredAntiAffinityNodeInfoList
return
s
return
s
}
}
...
@@ -177,6 +185,11 @@ func (s *Snapshot) HavePodsWithAffinityList() ([]*schedulernodeinfo.NodeInfo, er
...
@@ -177,6 +185,11 @@ func (s *Snapshot) HavePodsWithAffinityList() ([]*schedulernodeinfo.NodeInfo, er
return
s
.
havePodsWithAffinityNodeInfoList
,
nil
return
s
.
havePodsWithAffinityNodeInfoList
,
nil
}
}
// HavePodsWithRequiredAntiAffinityList returns the list of nodes with at least one pods with inter-pod affinity
func
(
s
*
Snapshot
)
HavePodsWithRequiredAntiAffinityList
()
([]
*
schedulernodeinfo
.
NodeInfo
,
error
)
{
return
s
.
havePodsWithRequiredAntiAffinityNodeInfoList
,
nil
}
// Get returns the NodeInfo of the given node name.
// Get returns the NodeInfo of the given node name.
func
(
s
*
Snapshot
)
Get
(
nodeName
string
)
(
*
schedulernodeinfo
.
NodeInfo
,
error
)
{
func
(
s
*
Snapshot
)
Get
(
nodeName
string
)
(
*
schedulernodeinfo
.
NodeInfo
,
error
)
{
if
v
,
ok
:=
s
.
nodeInfoMap
[
nodeName
];
ok
&&
v
.
Node
()
!=
nil
{
if
v
,
ok
:=
s
.
nodeInfoMap
[
nodeName
];
ok
&&
v
.
Node
()
!=
nil
{
...
...
vendor/k8s.io/kubernetes/pkg/scheduler/listers/listers.go
View file @
6fa97306
...
@@ -41,6 +41,8 @@ type NodeInfoLister interface {
...
@@ -41,6 +41,8 @@ type NodeInfoLister interface {
List
()
([]
*
schedulernodeinfo
.
NodeInfo
,
error
)
List
()
([]
*
schedulernodeinfo
.
NodeInfo
,
error
)
// Returns the list of NodeInfos of nodes with pods with affinity terms.
// Returns the list of NodeInfos of nodes with pods with affinity terms.
HavePodsWithAffinityList
()
([]
*
schedulernodeinfo
.
NodeInfo
,
error
)
HavePodsWithAffinityList
()
([]
*
schedulernodeinfo
.
NodeInfo
,
error
)
// Returns the list of NodeInfos of nodes with pods with required anti-affinity terms.
HavePodsWithRequiredAntiAffinityList
()
([]
*
schedulernodeinfo
.
NodeInfo
,
error
)
// Returns the NodeInfo of the given node name.
// Returns the NodeInfo of the given node name.
Get
(
nodeName
string
)
(
*
schedulernodeinfo
.
NodeInfo
,
error
)
Get
(
nodeName
string
)
(
*
schedulernodeinfo
.
NodeInfo
,
error
)
}
}
...
...
vendor/k8s.io/kubernetes/pkg/scheduler/nodeinfo/node_info.go
View file @
6fa97306
...
@@ -49,9 +49,10 @@ type NodeInfo struct {
...
@@ -49,9 +49,10 @@ type NodeInfo struct {
// Overall node information.
// Overall node information.
node
*
v1
.
Node
node
*
v1
.
Node
pods
[]
*
v1
.
Pod
pods
[]
*
v1
.
Pod
podsWithAffinity
[]
*
v1
.
Pod
podsWithAffinity
[]
*
v1
.
Pod
usedPorts
HostPortInfo
podsWithRequiredAntiAffinity
[]
*
v1
.
Pod
usedPorts
HostPortInfo
// Total requested resources of all pods on this node. This includes assumed
// Total requested resources of all pods on this node. This includes assumed
// pods, which scheduler has sent for binding, but may not be scheduled yet.
// pods, which scheduler has sent for binding, but may not be scheduled yet.
...
@@ -339,6 +340,14 @@ func (n *NodeInfo) PodsWithAffinity() []*v1.Pod {
...
@@ -339,6 +340,14 @@ func (n *NodeInfo) PodsWithAffinity() []*v1.Pod {
return
n
.
podsWithAffinity
return
n
.
podsWithAffinity
}
}
// PodsWithRequiredAntiAffinity return all pods with required anti-affinity constraints on this node.
func
(
n
*
NodeInfo
)
PodsWithRequiredAntiAffinity
()
[]
*
v1
.
Pod
{
if
n
==
nil
{
return
nil
}
return
n
.
podsWithRequiredAntiAffinity
}
// AllowedPodNumber returns the number of the allowed pods on this node.
// AllowedPodNumber returns the number of the allowed pods on this node.
func
(
n
*
NodeInfo
)
AllowedPodNumber
()
int
{
func
(
n
*
NodeInfo
)
AllowedPodNumber
()
int
{
if
n
==
nil
||
n
.
allocatableResource
==
nil
{
if
n
==
nil
||
n
.
allocatableResource
==
nil
{
...
@@ -445,6 +454,9 @@ func (n *NodeInfo) Clone() *NodeInfo {
...
@@ -445,6 +454,9 @@ func (n *NodeInfo) Clone() *NodeInfo {
if
len
(
n
.
podsWithAffinity
)
>
0
{
if
len
(
n
.
podsWithAffinity
)
>
0
{
clone
.
podsWithAffinity
=
append
([]
*
v1
.
Pod
(
nil
),
n
.
podsWithAffinity
...
)
clone
.
podsWithAffinity
=
append
([]
*
v1
.
Pod
(
nil
),
n
.
podsWithAffinity
...
)
}
}
if
len
(
n
.
podsWithRequiredAntiAffinity
)
>
0
{
clone
.
podsWithRequiredAntiAffinity
=
append
([]
*
v1
.
Pod
(
nil
),
n
.
podsWithRequiredAntiAffinity
...
)
}
if
len
(
n
.
taints
)
>
0
{
if
len
(
n
.
taints
)
>
0
{
clone
.
taints
=
append
([]
v1
.
Taint
(
nil
),
n
.
taints
...
)
clone
.
taints
=
append
([]
v1
.
Taint
(
nil
),
n
.
taints
...
)
}
}
...
@@ -477,6 +489,11 @@ func hasPodAffinityConstraints(pod *v1.Pod) bool {
...
@@ -477,6 +489,11 @@ func hasPodAffinityConstraints(pod *v1.Pod) bool {
return
affinity
!=
nil
&&
(
affinity
.
PodAffinity
!=
nil
||
affinity
.
PodAntiAffinity
!=
nil
)
return
affinity
!=
nil
&&
(
affinity
.
PodAffinity
!=
nil
||
affinity
.
PodAntiAffinity
!=
nil
)
}
}
func
hasRequiredPodAntiAffinityConstraints
(
pod
*
v1
.
Pod
)
bool
{
affinity
:=
pod
.
Spec
.
Affinity
return
affinity
!=
nil
&&
affinity
.
PodAntiAffinity
!=
nil
&&
len
(
affinity
.
PodAntiAffinity
.
RequiredDuringSchedulingIgnoredDuringExecution
)
!=
0
}
// AddPod adds pod information to this NodeInfo.
// AddPod adds pod information to this NodeInfo.
func
(
n
*
NodeInfo
)
AddPod
(
pod
*
v1
.
Pod
)
{
func
(
n
*
NodeInfo
)
AddPod
(
pod
*
v1
.
Pod
)
{
res
,
non0CPU
,
non0Mem
:=
calculateResource
(
pod
)
res
,
non0CPU
,
non0Mem
:=
calculateResource
(
pod
)
...
@@ -495,6 +512,9 @@ func (n *NodeInfo) AddPod(pod *v1.Pod) {
...
@@ -495,6 +512,9 @@ func (n *NodeInfo) AddPod(pod *v1.Pod) {
if
hasPodAffinityConstraints
(
pod
)
{
if
hasPodAffinityConstraints
(
pod
)
{
n
.
podsWithAffinity
=
append
(
n
.
podsWithAffinity
,
pod
)
n
.
podsWithAffinity
=
append
(
n
.
podsWithAffinity
,
pod
)
}
}
if
hasRequiredPodAntiAffinityConstraints
(
pod
)
{
n
.
podsWithRequiredAntiAffinity
=
append
(
n
.
podsWithRequiredAntiAffinity
,
pod
)
}
// Consume ports when pods added.
// Consume ports when pods added.
n
.
UpdateUsedPorts
(
pod
,
true
)
n
.
UpdateUsedPorts
(
pod
,
true
)
...
@@ -502,33 +522,45 @@ func (n *NodeInfo) AddPod(pod *v1.Pod) {
...
@@ -502,33 +522,45 @@ func (n *NodeInfo) AddPod(pod *v1.Pod) {
n
.
generation
=
nextGeneration
()
n
.
generation
=
nextGeneration
()
}
}
// RemovePod subtracts pod information from this NodeInfo.
func
removeFromSlice
(
s
[]
*
v1
.
Pod
,
k
string
)
[]
*
v1
.
Pod
{
func
(
n
*
NodeInfo
)
RemovePod
(
pod
*
v1
.
Pod
)
error
{
for
i
:=
range
s
{
k1
,
err
:=
GetPodKey
(
pod
)
k2
,
err
:=
GetPodKey
(
s
[
i
])
if
err
!=
nil
{
return
err
}
for
i
:=
range
n
.
podsWithAffinity
{
k2
,
err
:=
GetPodKey
(
n
.
podsWithAffinity
[
i
])
if
err
!=
nil
{
if
err
!=
nil
{
klog
.
Errorf
(
"Cannot get pod key, err: %v"
,
err
)
klog
.
Errorf
(
"Cannot get pod key, err: %v"
,
err
)
continue
continue
}
}
if
k
1
==
k2
{
if
k
==
k2
{
// delete the element
// delete the element
n
.
podsWithAffinity
[
i
]
=
n
.
podsWithAffinity
[
len
(
n
.
podsWithAffinity
)
-
1
]
s
[
i
]
=
s
[
len
(
s
)
-
1
]
n
.
podsWithAffinity
=
n
.
podsWithAffinity
[
:
len
(
n
.
podsWithAffinity
)
-
1
]
s
=
s
[
:
len
(
s
)
-
1
]
break
break
}
}
}
}
return
s
}
// RemovePod subtracts pod information from this NodeInfo.
func
(
n
*
NodeInfo
)
RemovePod
(
pod
*
v1
.
Pod
)
error
{
k
,
err
:=
GetPodKey
(
pod
)
if
err
!=
nil
{
return
err
}
if
hasPodAffinityConstraints
(
pod
)
{
n
.
podsWithAffinity
=
removeFromSlice
(
n
.
podsWithAffinity
,
k
)
}
if
hasRequiredPodAntiAffinityConstraints
(
pod
)
{
n
.
podsWithRequiredAntiAffinity
=
removeFromSlice
(
n
.
podsWithRequiredAntiAffinity
,
k
)
}
for
i
:=
range
n
.
pods
{
for
i
:=
range
n
.
pods
{
k2
,
err
:=
GetPodKey
(
n
.
pods
[
i
])
k2
,
err
:=
GetPodKey
(
n
.
pods
[
i
])
if
err
!=
nil
{
if
err
!=
nil
{
klog
.
Errorf
(
"Cannot get pod key, err: %v"
,
err
)
klog
.
Errorf
(
"Cannot get pod key, err: %v"
,
err
)
continue
continue
}
}
if
k
1
==
k2
{
if
k
==
k2
{
// delete the element
// delete the element
n
.
pods
[
i
]
=
n
.
pods
[
len
(
n
.
pods
)
-
1
]
n
.
pods
[
i
]
=
n
.
pods
[
len
(
n
.
pods
)
-
1
]
n
.
pods
=
n
.
pods
[
:
len
(
n
.
pods
)
-
1
]
n
.
pods
=
n
.
pods
[
:
len
(
n
.
pods
)
-
1
]
...
@@ -563,6 +595,9 @@ func (n *NodeInfo) resetSlicesIfEmpty() {
...
@@ -563,6 +595,9 @@ func (n *NodeInfo) resetSlicesIfEmpty() {
if
len
(
n
.
podsWithAffinity
)
==
0
{
if
len
(
n
.
podsWithAffinity
)
==
0
{
n
.
podsWithAffinity
=
nil
n
.
podsWithAffinity
=
nil
}
}
if
len
(
n
.
podsWithRequiredAntiAffinity
)
==
0
{
n
.
podsWithRequiredAntiAffinity
=
nil
}
if
len
(
n
.
pods
)
==
0
{
if
len
(
n
.
pods
)
==
0
{
n
.
pods
=
nil
n
.
pods
=
nil
}
}
...
...
vendor/k8s.io/legacy-cloud-providers/azure/azure.go
View file @
6fa97306
...
@@ -241,7 +241,7 @@ type Cloud struct {
...
@@ -241,7 +241,7 @@ type Cloud struct {
ResourceRequestBackoff
wait
.
Backoff
ResourceRequestBackoff
wait
.
Backoff
metadata
*
InstanceMetadataService
metadata
*
InstanceMetadataService
vm
Set
VMSet
VM
Set
VMSet
// ipv6DualStack allows overriding for unit testing. It's normally initialized from featuregates
// ipv6DualStack allows overriding for unit testing. It's normally initialized from featuregates
ipv6DualStackEnabled
bool
ipv6DualStackEnabled
bool
...
@@ -484,12 +484,12 @@ func (az *Cloud) InitializeCloudFromConfig(config *Config, fromSecret bool) erro
...
@@ -484,12 +484,12 @@ func (az *Cloud) InitializeCloudFromConfig(config *Config, fromSecret bool) erro
}
}
if
strings
.
EqualFold
(
vmTypeVMSS
,
az
.
Config
.
VMType
)
{
if
strings
.
EqualFold
(
vmTypeVMSS
,
az
.
Config
.
VMType
)
{
az
.
vm
Set
,
err
=
newScaleSet
(
az
)
az
.
VM
Set
,
err
=
newScaleSet
(
az
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
}
else
{
}
else
{
az
.
vm
Set
=
newAvailabilitySet
(
az
)
az
.
VM
Set
=
newAvailabilitySet
(
az
)
}
}
az
.
vmCache
,
err
=
az
.
newVMCache
()
az
.
vmCache
,
err
=
az
.
newVMCache
()
...
...
vendor/k8s.io/legacy-cloud-providers/azure/azure_backoff.go
View file @
6fa97306
...
@@ -111,7 +111,7 @@ func (az *Cloud) getPrivateIPsForMachineWithRetry(nodeName types.NodeName) ([]st
...
@@ -111,7 +111,7 @@ func (az *Cloud) getPrivateIPsForMachineWithRetry(nodeName types.NodeName) ([]st
var
privateIPs
[]
string
var
privateIPs
[]
string
err
:=
wait
.
ExponentialBackoff
(
az
.
RequestBackoff
(),
func
()
(
bool
,
error
)
{
err
:=
wait
.
ExponentialBackoff
(
az
.
RequestBackoff
(),
func
()
(
bool
,
error
)
{
var
retryErr
error
var
retryErr
error
privateIPs
,
retryErr
=
az
.
vm
Set
.
GetPrivateIPsByNodeName
(
string
(
nodeName
))
privateIPs
,
retryErr
=
az
.
VM
Set
.
GetPrivateIPsByNodeName
(
string
(
nodeName
))
if
retryErr
!=
nil
{
if
retryErr
!=
nil
{
// won't retry since the instance doesn't exist on Azure.
// won't retry since the instance doesn't exist on Azure.
if
retryErr
==
cloudprovider
.
InstanceNotFound
{
if
retryErr
==
cloudprovider
.
InstanceNotFound
{
...
@@ -135,7 +135,7 @@ func (az *Cloud) GetIPForMachineWithRetry(name types.NodeName) (string, string,
...
@@ -135,7 +135,7 @@ func (az *Cloud) GetIPForMachineWithRetry(name types.NodeName) (string, string,
var
ip
,
publicIP
string
var
ip
,
publicIP
string
err
:=
wait
.
ExponentialBackoff
(
az
.
RequestBackoff
(),
func
()
(
bool
,
error
)
{
err
:=
wait
.
ExponentialBackoff
(
az
.
RequestBackoff
(),
func
()
(
bool
,
error
)
{
var
retryErr
error
var
retryErr
error
ip
,
publicIP
,
retryErr
=
az
.
vm
Set
.
GetIPByNodeName
(
string
(
name
))
ip
,
publicIP
,
retryErr
=
az
.
VM
Set
.
GetIPByNodeName
(
string
(
name
))
if
retryErr
!=
nil
{
if
retryErr
!=
nil
{
klog
.
Errorf
(
"GetIPForMachineWithRetry(%s): backoff failure, will retry,err=%v"
,
name
,
retryErr
)
klog
.
Errorf
(
"GetIPForMachineWithRetry(%s): backoff failure, will retry,err=%v"
,
name
,
retryErr
)
return
false
,
nil
return
false
,
nil
...
...
vendor/k8s.io/legacy-cloud-providers/azure/azure_controller_common.go
View file @
6fa97306
...
@@ -49,7 +49,9 @@ const (
...
@@ -49,7 +49,9 @@ const (
errLeaseFailed
=
"AcquireDiskLeaseFailed"
errLeaseFailed
=
"AcquireDiskLeaseFailed"
errLeaseIDMissing
=
"LeaseIdMissing"
errLeaseIDMissing
=
"LeaseIdMissing"
errContainerNotFound
=
"ContainerNotFound"
errContainerNotFound
=
"ContainerNotFound"
errDiskBlobNotFound
=
"DiskBlobNotFound"
errStatusCode400
=
"statuscode=400"
errInvalidParameter
=
`code="invalidparameter"`
errTargetInstanceIds
=
`target="instanceids"`
sourceSnapshot
=
"snapshot"
sourceSnapshot
=
"snapshot"
sourceVolume
=
"volume"
sourceVolume
=
"volume"
...
@@ -90,15 +92,15 @@ type controllerCommon struct {
...
@@ -90,15 +92,15 @@ type controllerCommon struct {
// getNodeVMSet gets the VMSet interface based on config.VMType and the real virtual machine type.
// getNodeVMSet gets the VMSet interface based on config.VMType and the real virtual machine type.
func
(
c
*
controllerCommon
)
getNodeVMSet
(
nodeName
types
.
NodeName
,
crt
azcache
.
AzureCacheReadType
)
(
VMSet
,
error
)
{
func
(
c
*
controllerCommon
)
getNodeVMSet
(
nodeName
types
.
NodeName
,
crt
azcache
.
AzureCacheReadType
)
(
VMSet
,
error
)
{
// 1. vmType is standard, return cloud.
vm
Set directly.
// 1. vmType is standard, return cloud.
VM
Set directly.
if
c
.
cloud
.
VMType
==
vmTypeStandard
{
if
c
.
cloud
.
VMType
==
vmTypeStandard
{
return
c
.
cloud
.
vm
Set
,
nil
return
c
.
cloud
.
VM
Set
,
nil
}
}
// 2. vmType is Virtual Machine Scale Set (vmss), convert vmSet to scaleSet.
// 2. vmType is Virtual Machine Scale Set (vmss), convert vmSet to scaleSet.
ss
,
ok
:=
c
.
cloud
.
vm
Set
.
(
*
scaleSet
)
ss
,
ok
:=
c
.
cloud
.
VM
Set
.
(
*
scaleSet
)
if
!
ok
{
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"error of converting vmSet (%q) to scaleSet with vmType %q"
,
c
.
cloud
.
vm
Set
,
c
.
cloud
.
VMType
)
return
nil
,
fmt
.
Errorf
(
"error of converting vmSet (%q) to scaleSet with vmType %q"
,
c
.
cloud
.
VM
Set
,
c
.
cloud
.
VMType
)
}
}
// 3. If the node is managed by availability set, then return ss.availabilitySet.
// 3. If the node is managed by availability set, then return ss.availabilitySet.
...
@@ -214,24 +216,32 @@ func (c *controllerCommon) DetachDisk(diskName, diskURI string, nodeName types.N
...
@@ -214,24 +216,32 @@ func (c *controllerCommon) DetachDisk(diskName, diskURI string, nodeName types.N
c
.
diskAttachDetachMap
.
Delete
(
strings
.
ToLower
(
diskURI
))
c
.
diskAttachDetachMap
.
Delete
(
strings
.
ToLower
(
diskURI
))
c
.
vmLockMap
.
UnlockEntry
(
strings
.
ToLower
(
string
(
nodeName
)))
c
.
vmLockMap
.
UnlockEntry
(
strings
.
ToLower
(
string
(
nodeName
)))
if
err
!=
nil
&&
retry
.
IsErrorRetriable
(
err
)
&&
c
.
cloud
.
CloudProviderBackoff
{
if
err
!=
nil
{
klog
.
V
(
2
)
.
Infof
(
"azureDisk - update backing off: detach disk(%s, %s), err: %v"
,
diskName
,
diskURI
,
err
)
if
isInstanceNotFoundError
(
err
)
{
retryErr
:=
kwait
.
ExponentialBackoff
(
c
.
cloud
.
RequestBackoff
(),
func
()
(
bool
,
error
)
{
// if host doesn't exist, no need to detach
c
.
vmLockMap
.
LockEntry
(
strings
.
ToLower
(
string
(
nodeName
)))
klog
.
Warningf
(
"azureDisk - got InstanceNotFoundError(%v), DetachDisk(%s) will assume disk is already detached"
,
c
.
diskAttachDetachMap
.
Store
(
strings
.
ToLower
(
diskURI
),
"detaching"
)
err
,
diskURI
)
err
:=
vmset
.
DetachDisk
(
diskName
,
diskURI
,
nodeName
)
return
nil
c
.
diskAttachDetachMap
.
Delete
(
strings
.
ToLower
(
diskURI
))
}
c
.
vmLockMap
.
UnlockEntry
(
strings
.
ToLower
(
string
(
nodeName
)))
if
retry
.
IsErrorRetriable
(
err
)
&&
c
.
cloud
.
CloudProviderBackoff
{
klog
.
Warningf
(
"azureDisk - update backing off: detach disk(%s, %s), err: %v"
,
diskName
,
diskURI
,
err
)
retriable
:=
false
retryErr
:=
kwait
.
ExponentialBackoff
(
c
.
cloud
.
RequestBackoff
(),
func
()
(
bool
,
error
)
{
if
err
!=
nil
&&
retry
.
IsErrorRetriable
(
err
)
{
c
.
vmLockMap
.
LockEntry
(
strings
.
ToLower
(
string
(
nodeName
)))
retriable
=
true
c
.
diskAttachDetachMap
.
Store
(
strings
.
ToLower
(
diskURI
),
"detaching"
)
err
:=
vmset
.
DetachDisk
(
diskName
,
diskURI
,
nodeName
)
c
.
diskAttachDetachMap
.
Delete
(
strings
.
ToLower
(
diskURI
))
c
.
vmLockMap
.
UnlockEntry
(
strings
.
ToLower
(
string
(
nodeName
)))
retriable
:=
false
if
err
!=
nil
&&
retry
.
IsErrorRetriable
(
err
)
{
retriable
=
true
}
return
!
retriable
,
err
})
if
retryErr
!=
nil
{
err
=
retryErr
klog
.
V
(
2
)
.
Infof
(
"azureDisk - update abort backoff: detach disk(%s, %s), err: %v"
,
diskName
,
diskURI
,
err
)
}
}
return
!
retriable
,
err
})
if
retryErr
!=
nil
{
err
=
retryErr
klog
.
V
(
2
)
.
Infof
(
"azureDisk - update abort backoff: detach disk(%s, %s), err: %v"
,
diskName
,
diskURI
,
err
)
}
}
}
}
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -426,3 +436,8 @@ func getValidCreationData(subscriptionID, resourceGroup, sourceResourceID, sourc
...
@@ -426,3 +436,8 @@ func getValidCreationData(subscriptionID, resourceGroup, sourceResourceID, sourc
SourceResourceID
:
&
sourceResourceID
,
SourceResourceID
:
&
sourceResourceID
,
},
nil
},
nil
}
}
func
isInstanceNotFoundError
(
err
error
)
bool
{
errMsg
:=
strings
.
ToLower
(
err
.
Error
())
return
strings
.
Contains
(
errMsg
,
errStatusCode400
)
&&
strings
.
Contains
(
errMsg
,
errInvalidParameter
)
&&
strings
.
Contains
(
errMsg
,
errTargetInstanceIds
)
}
vendor/k8s.io/legacy-cloud-providers/azure/azure_controller_standard.go
View file @
6fa97306
...
@@ -142,7 +142,11 @@ func (as *availabilitySet) DetachDisk(diskName, diskURI string, nodeName types.N
...
@@ -142,7 +142,11 @@ func (as *availabilitySet) DetachDisk(diskName, diskURI string, nodeName types.N
(
disk
.
ManagedDisk
!=
nil
&&
diskURI
!=
""
&&
strings
.
EqualFold
(
*
disk
.
ManagedDisk
.
ID
,
diskURI
))
{
(
disk
.
ManagedDisk
!=
nil
&&
diskURI
!=
""
&&
strings
.
EqualFold
(
*
disk
.
ManagedDisk
.
ID
,
diskURI
))
{
// found the disk
// found the disk
klog
.
V
(
2
)
.
Infof
(
"azureDisk - detach disk: name %q uri %q"
,
diskName
,
diskURI
)
klog
.
V
(
2
)
.
Infof
(
"azureDisk - detach disk: name %q uri %q"
,
diskName
,
diskURI
)
disks
[
i
]
.
ToBeDetached
=
to
.
BoolPtr
(
true
)
if
strings
.
EqualFold
(
as
.
cloud
.
Environment
.
Name
,
"AZURESTACKCLOUD"
)
{
disks
=
append
(
disks
[
:
i
],
disks
[
i
+
1
:
]
...
)
}
else
{
disks
[
i
]
.
ToBeDetached
=
to
.
BoolPtr
(
true
)
}
bFoundDisk
=
true
bFoundDisk
=
true
break
break
}
}
...
...
vendor/k8s.io/legacy-cloud-providers/azure/azure_controller_vmss.go
View file @
6fa97306
...
@@ -147,7 +147,11 @@ func (ss *scaleSet) DetachDisk(diskName, diskURI string, nodeName types.NodeName
...
@@ -147,7 +147,11 @@ func (ss *scaleSet) DetachDisk(diskName, diskURI string, nodeName types.NodeName
(
disk
.
ManagedDisk
!=
nil
&&
diskURI
!=
""
&&
strings
.
EqualFold
(
*
disk
.
ManagedDisk
.
ID
,
diskURI
))
{
(
disk
.
ManagedDisk
!=
nil
&&
diskURI
!=
""
&&
strings
.
EqualFold
(
*
disk
.
ManagedDisk
.
ID
,
diskURI
))
{
// found the disk
// found the disk
klog
.
V
(
2
)
.
Infof
(
"azureDisk - detach disk: name %q uri %q"
,
diskName
,
diskURI
)
klog
.
V
(
2
)
.
Infof
(
"azureDisk - detach disk: name %q uri %q"
,
diskName
,
diskURI
)
disks
[
i
]
.
ToBeDetached
=
to
.
BoolPtr
(
true
)
if
strings
.
EqualFold
(
ss
.
cloud
.
Environment
.
Name
,
"AZURESTACKCLOUD"
)
{
disks
=
append
(
disks
[
:
i
],
disks
[
i
+
1
:
]
...
)
}
else
{
disks
[
i
]
.
ToBeDetached
=
to
.
BoolPtr
(
true
)
}
bFoundDisk
=
true
bFoundDisk
=
true
break
break
}
}
...
...
vendor/k8s.io/legacy-cloud-providers/azure/azure_fakes.go
View file @
6fa97306
...
@@ -761,6 +761,14 @@ func (fDC *fakeDisksClient) Get(ctx context.Context, resourceGroupName string, d
...
@@ -761,6 +761,14 @@ func (fDC *fakeDisksClient) Get(ctx context.Context, resourceGroupName string, d
errors
.
New
(
"Not such Disk"
))
errors
.
New
(
"Not such Disk"
))
}
}
func
(
fDC
*
fakeDisksClient
)
ListByResourceGroup
(
ctx
context
.
Context
,
resourceGroupName
string
)
([]
compute
.
Disk
,
*
retry
.
Error
)
{
return
[]
compute
.
Disk
{},
nil
}
func
(
fDC
*
fakeDisksClient
)
Update
(
ctx
context
.
Context
,
resourceGroupName
string
,
diskName
string
,
diskParameter
compute
.
DiskUpdate
)
*
retry
.
Error
{
return
nil
}
// GetTestCloud returns a fake azure cloud for unit tests in Azure related CSI drivers
// GetTestCloud returns a fake azure cloud for unit tests in Azure related CSI drivers
func
GetTestCloud
(
ctrl
*
gomock
.
Controller
)
(
az
*
Cloud
)
{
func
GetTestCloud
(
ctrl
*
gomock
.
Controller
)
(
az
*
Cloud
)
{
az
=
&
Cloud
{
az
=
&
Cloud
{
...
@@ -800,7 +808,7 @@ func GetTestCloud(ctrl *gomock.Controller) (az *Cloud) {
...
@@ -800,7 +808,7 @@ func GetTestCloud(ctrl *gomock.Controller) (az *Cloud) {
az
.
VirtualMachineScaleSetsClient
=
newFakeVirtualMachineScaleSetsClient
()
az
.
VirtualMachineScaleSetsClient
=
newFakeVirtualMachineScaleSetsClient
()
az
.
VirtualMachineScaleSetVMsClient
=
newFakeVirtualMachineScaleSetVMsClient
()
az
.
VirtualMachineScaleSetVMsClient
=
newFakeVirtualMachineScaleSetVMsClient
()
az
.
VirtualMachinesClient
=
newFakeAzureVirtualMachinesClient
()
az
.
VirtualMachinesClient
=
newFakeAzureVirtualMachinesClient
()
az
.
vm
Set
=
newAvailabilitySet
(
az
)
az
.
VM
Set
=
newAvailabilitySet
(
az
)
az
.
vmCache
,
_
=
az
.
newVMCache
()
az
.
vmCache
,
_
=
az
.
newVMCache
()
az
.
lbCache
,
_
=
az
.
newLBCache
()
az
.
lbCache
,
_
=
az
.
newLBCache
()
az
.
nsgCache
,
_
=
az
.
newNSGCache
()
az
.
nsgCache
,
_
=
az
.
newNSGCache
()
...
...
vendor/k8s.io/legacy-cloud-providers/azure/azure_instances.go
View file @
6fa97306
...
@@ -94,11 +94,11 @@ func (az *Cloud) NodeAddresses(ctx context.Context, name types.NodeName) ([]v1.N
...
@@ -94,11 +94,11 @@ func (az *Cloud) NodeAddresses(ctx context.Context, name types.NodeName) ([]v1.N
// Not local instance, get addresses from Azure ARM API.
// Not local instance, get addresses from Azure ARM API.
if
!
isLocalInstance
{
if
!
isLocalInstance
{
if
az
.
vm
Set
!=
nil
{
if
az
.
VM
Set
!=
nil
{
return
addressGetter
(
name
)
return
addressGetter
(
name
)
}
}
//
vm
Set == nil indicates credentials are not provided.
//
VM
Set == nil indicates credentials are not provided.
return
nil
,
fmt
.
Errorf
(
"no credentials provided for Azure cloud provider"
)
return
nil
,
fmt
.
Errorf
(
"no credentials provided for Azure cloud provider"
)
}
}
...
@@ -164,7 +164,7 @@ func (az *Cloud) NodeAddressesByProviderID(ctx context.Context, providerID strin
...
@@ -164,7 +164,7 @@ func (az *Cloud) NodeAddressesByProviderID(ctx context.Context, providerID strin
return
nil
,
nil
return
nil
,
nil
}
}
name
,
err
:=
az
.
vm
Set
.
GetNodeNameByProviderID
(
providerID
)
name
,
err
:=
az
.
VM
Set
.
GetNodeNameByProviderID
(
providerID
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -185,7 +185,7 @@ func (az *Cloud) InstanceExistsByProviderID(ctx context.Context, providerID stri
...
@@ -185,7 +185,7 @@ func (az *Cloud) InstanceExistsByProviderID(ctx context.Context, providerID stri
return
true
,
nil
return
true
,
nil
}
}
name
,
err
:=
az
.
vm
Set
.
GetNodeNameByProviderID
(
providerID
)
name
,
err
:=
az
.
VM
Set
.
GetNodeNameByProviderID
(
providerID
)
if
err
!=
nil
{
if
err
!=
nil
{
if
err
==
cloudprovider
.
InstanceNotFound
{
if
err
==
cloudprovider
.
InstanceNotFound
{
return
false
,
nil
return
false
,
nil
...
@@ -210,7 +210,7 @@ func (az *Cloud) InstanceShutdownByProviderID(ctx context.Context, providerID st
...
@@ -210,7 +210,7 @@ func (az *Cloud) InstanceShutdownByProviderID(ctx context.Context, providerID st
return
false
,
nil
return
false
,
nil
}
}
nodeName
,
err
:=
az
.
vm
Set
.
GetNodeNameByProviderID
(
providerID
)
nodeName
,
err
:=
az
.
VM
Set
.
GetNodeNameByProviderID
(
providerID
)
if
err
!=
nil
{
if
err
!=
nil
{
// Returns false, so the controller manager will continue to check InstanceExistsByProviderID().
// Returns false, so the controller manager will continue to check InstanceExistsByProviderID().
if
err
==
cloudprovider
.
InstanceNotFound
{
if
err
==
cloudprovider
.
InstanceNotFound
{
...
@@ -220,7 +220,7 @@ func (az *Cloud) InstanceShutdownByProviderID(ctx context.Context, providerID st
...
@@ -220,7 +220,7 @@ func (az *Cloud) InstanceShutdownByProviderID(ctx context.Context, providerID st
return
false
,
err
return
false
,
err
}
}
powerStatus
,
err
:=
az
.
vm
Set
.
GetPowerStatusByNodeName
(
string
(
nodeName
))
powerStatus
,
err
:=
az
.
VM
Set
.
GetPowerStatusByNodeName
(
string
(
nodeName
))
if
err
!=
nil
{
if
err
!=
nil
{
// Returns false, so the controller manager will continue to check InstanceExistsByProviderID().
// Returns false, so the controller manager will continue to check InstanceExistsByProviderID().
if
err
==
cloudprovider
.
InstanceNotFound
{
if
err
==
cloudprovider
.
InstanceNotFound
{
...
@@ -287,8 +287,8 @@ func (az *Cloud) InstanceID(ctx context.Context, name types.NodeName) (string, e
...
@@ -287,8 +287,8 @@ func (az *Cloud) InstanceID(ctx context.Context, name types.NodeName) (string, e
// Not local instance, get instanceID from Azure ARM API.
// Not local instance, get instanceID from Azure ARM API.
if
!
isLocalInstance
{
if
!
isLocalInstance
{
if
az
.
vm
Set
!=
nil
{
if
az
.
VM
Set
!=
nil
{
return
az
.
vm
Set
.
GetInstanceIDByNodeName
(
nodeName
)
return
az
.
VM
Set
.
GetInstanceIDByNodeName
(
nodeName
)
}
}
// vmSet == nil indicates credentials are not provided.
// vmSet == nil indicates credentials are not provided.
...
@@ -317,7 +317,7 @@ func (az *Cloud) InstanceID(ctx context.Context, name types.NodeName) (string, e
...
@@ -317,7 +317,7 @@ func (az *Cloud) InstanceID(ctx context.Context, name types.NodeName) (string, e
return
az
.
getVmssMachineID
(
subscriptionID
,
resourceGroup
,
ssName
,
instanceID
),
nil
return
az
.
getVmssMachineID
(
subscriptionID
,
resourceGroup
,
ssName
,
instanceID
),
nil
}
}
return
az
.
vm
Set
.
GetInstanceIDByNodeName
(
nodeName
)
return
az
.
VM
Set
.
GetInstanceIDByNodeName
(
nodeName
)
}
}
// InstanceTypeByProviderID returns the cloudprovider instance type of the node with the specified unique providerID
// InstanceTypeByProviderID returns the cloudprovider instance type of the node with the specified unique providerID
...
@@ -334,7 +334,7 @@ func (az *Cloud) InstanceTypeByProviderID(ctx context.Context, providerID string
...
@@ -334,7 +334,7 @@ func (az *Cloud) InstanceTypeByProviderID(ctx context.Context, providerID string
return
""
,
nil
return
""
,
nil
}
}
name
,
err
:=
az
.
vm
Set
.
GetNodeNameByProviderID
(
providerID
)
name
,
err
:=
az
.
VM
Set
.
GetNodeNameByProviderID
(
providerID
)
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
err
return
""
,
err
}
}
...
@@ -372,8 +372,8 @@ func (az *Cloud) InstanceType(ctx context.Context, name types.NodeName) (string,
...
@@ -372,8 +372,8 @@ func (az *Cloud) InstanceType(ctx context.Context, name types.NodeName) (string,
return
""
,
err
return
""
,
err
}
}
if
!
isLocalInstance
{
if
!
isLocalInstance
{
if
az
.
vm
Set
!=
nil
{
if
az
.
VM
Set
!=
nil
{
return
az
.
vm
Set
.
GetInstanceTypeByNodeName
(
string
(
name
))
return
az
.
VM
Set
.
GetInstanceTypeByNodeName
(
string
(
name
))
}
}
// vmSet == nil indicates credentials are not provided.
// vmSet == nil indicates credentials are not provided.
...
@@ -385,7 +385,7 @@ func (az *Cloud) InstanceType(ctx context.Context, name types.NodeName) (string,
...
@@ -385,7 +385,7 @@ func (az *Cloud) InstanceType(ctx context.Context, name types.NodeName) (string,
}
}
}
}
return
az
.
vm
Set
.
GetInstanceTypeByNodeName
(
string
(
name
))
return
az
.
VM
Set
.
GetInstanceTypeByNodeName
(
string
(
name
))
}
}
// AddSSHKeyToAllInstances adds an SSH public key as a legal identity for all instances
// AddSSHKeyToAllInstances adds an SSH public key as a legal identity for all instances
...
...
vendor/k8s.io/legacy-cloud-providers/azure/azure_loadbalancer.go
View file @
6fa97306
...
@@ -36,6 +36,7 @@ import (
...
@@ -36,6 +36,7 @@ import (
servicehelpers
"k8s.io/cloud-provider/service/helpers"
servicehelpers
"k8s.io/cloud-provider/service/helpers"
"k8s.io/klog"
"k8s.io/klog"
azcache
"k8s.io/legacy-cloud-providers/azure/cache"
azcache
"k8s.io/legacy-cloud-providers/azure/cache"
"k8s.io/legacy-cloud-providers/azure/retry"
utilnet
"k8s.io/utils/net"
utilnet
"k8s.io/utils/net"
)
)
...
@@ -216,7 +217,7 @@ func (az *Cloud) EnsureLoadBalancerDeleted(ctx context.Context, clusterName stri
...
@@ -216,7 +217,7 @@ func (az *Cloud) EnsureLoadBalancerDeleted(ctx context.Context, clusterName stri
klog
.
V
(
5
)
.
Infof
(
"Delete service (%s): START clusterName=%q"
,
serviceName
,
clusterName
)
klog
.
V
(
5
)
.
Infof
(
"Delete service (%s): START clusterName=%q"
,
serviceName
,
clusterName
)
serviceIPToCleanup
,
err
:=
az
.
findServiceIPAddress
(
ctx
,
clusterName
,
service
,
isInternal
)
serviceIPToCleanup
,
err
:=
az
.
findServiceIPAddress
(
ctx
,
clusterName
,
service
,
isInternal
)
if
err
!=
nil
{
if
err
!=
nil
&&
!
retry
.
HasStatusForbiddenOrIgnoredError
(
err
)
{
return
err
return
err
}
}
...
@@ -225,7 +226,7 @@ func (az *Cloud) EnsureLoadBalancerDeleted(ctx context.Context, clusterName stri
...
@@ -225,7 +226,7 @@ func (az *Cloud) EnsureLoadBalancerDeleted(ctx context.Context, clusterName stri
return
err
return
err
}
}
if
_
,
err
:=
az
.
reconcileLoadBalancer
(
clusterName
,
service
,
nil
,
false
/* wantLb */
);
err
!=
nil
{
if
_
,
err
:=
az
.
reconcileLoadBalancer
(
clusterName
,
service
,
nil
,
false
/* wantLb */
);
err
!=
nil
&&
!
retry
.
HasStatusForbiddenOrIgnoredError
(
err
)
{
return
err
return
err
}
}
...
@@ -258,7 +259,7 @@ func (az *Cloud) getLoadBalancerResourceGroup() string {
...
@@ -258,7 +259,7 @@ func (az *Cloud) getLoadBalancerResourceGroup() string {
func
(
az
*
Cloud
)
getServiceLoadBalancer
(
service
*
v1
.
Service
,
clusterName
string
,
nodes
[]
*
v1
.
Node
,
wantLb
bool
)
(
lb
*
network
.
LoadBalancer
,
status
*
v1
.
LoadBalancerStatus
,
exists
bool
,
err
error
)
{
func
(
az
*
Cloud
)
getServiceLoadBalancer
(
service
*
v1
.
Service
,
clusterName
string
,
nodes
[]
*
v1
.
Node
,
wantLb
bool
)
(
lb
*
network
.
LoadBalancer
,
status
*
v1
.
LoadBalancerStatus
,
exists
bool
,
err
error
)
{
isInternal
:=
requiresInternalLoadBalancer
(
service
)
isInternal
:=
requiresInternalLoadBalancer
(
service
)
var
defaultLB
*
network
.
LoadBalancer
var
defaultLB
*
network
.
LoadBalancer
primaryVMSetName
:=
az
.
vm
Set
.
GetPrimaryVMSetName
()
primaryVMSetName
:=
az
.
VM
Set
.
GetPrimaryVMSetName
()
defaultLBName
:=
az
.
getAzureLoadBalancerName
(
clusterName
,
primaryVMSetName
,
isInternal
)
defaultLBName
:=
az
.
getAzureLoadBalancerName
(
clusterName
,
primaryVMSetName
,
isInternal
)
existingLBs
,
err
:=
az
.
ListLB
(
service
)
existingLBs
,
err
:=
az
.
ListLB
(
service
)
...
@@ -331,7 +332,7 @@ func (az *Cloud) selectLoadBalancer(clusterName string, service *v1.Service, exi
...
@@ -331,7 +332,7 @@ func (az *Cloud) selectLoadBalancer(clusterName string, service *v1.Service, exi
isInternal
:=
requiresInternalLoadBalancer
(
service
)
isInternal
:=
requiresInternalLoadBalancer
(
service
)
serviceName
:=
getServiceName
(
service
)
serviceName
:=
getServiceName
(
service
)
klog
.
V
(
2
)
.
Infof
(
"selectLoadBalancer for service (%s): isInternal(%v) - start"
,
serviceName
,
isInternal
)
klog
.
V
(
2
)
.
Infof
(
"selectLoadBalancer for service (%s): isInternal(%v) - start"
,
serviceName
,
isInternal
)
vmSetNames
,
err
:=
az
.
vm
Set
.
GetVMSetNames
(
service
,
nodes
)
vmSetNames
,
err
:=
az
.
VM
Set
.
GetVMSetNames
(
service
,
nodes
)
if
err
!=
nil
{
if
err
!=
nil
{
klog
.
Errorf
(
"az.selectLoadBalancer: cluster(%s) service(%s) isInternal(%t) - az.GetVMSetNames failed, err=(%v)"
,
clusterName
,
serviceName
,
isInternal
,
err
)
klog
.
Errorf
(
"az.selectLoadBalancer: cluster(%s) service(%s) isInternal(%t) - az.GetVMSetNames failed, err=(%v)"
,
clusterName
,
serviceName
,
isInternal
,
err
)
return
nil
,
false
,
err
return
nil
,
false
,
err
...
@@ -937,7 +938,7 @@ func (az *Cloud) reconcileLoadBalancer(clusterName string, service *v1.Service,
...
@@ -937,7 +938,7 @@ func (az *Cloud) reconcileLoadBalancer(clusterName string, service *v1.Service,
// Remove backend pools from vmSets. This is required for virtual machine scale sets before removing the LB.
// Remove backend pools from vmSets. This is required for virtual machine scale sets before removing the LB.
vmSetName
:=
az
.
mapLoadBalancerNameToVMSet
(
lbName
,
clusterName
)
vmSetName
:=
az
.
mapLoadBalancerNameToVMSet
(
lbName
,
clusterName
)
klog
.
V
(
10
)
.
Infof
(
"EnsureBackendPoolDeleted(%s,%s) for service %s: start"
,
lbBackendPoolID
,
vmSetName
,
serviceName
)
klog
.
V
(
10
)
.
Infof
(
"EnsureBackendPoolDeleted(%s,%s) for service %s: start"
,
lbBackendPoolID
,
vmSetName
,
serviceName
)
err
:=
az
.
vm
Set
.
EnsureBackendPoolDeleted
(
service
,
lbBackendPoolID
,
vmSetName
,
lb
.
BackendAddressPools
)
err
:=
az
.
VM
Set
.
EnsureBackendPoolDeleted
(
service
,
lbBackendPoolID
,
vmSetName
,
lb
.
BackendAddressPools
)
if
err
!=
nil
{
if
err
!=
nil
{
klog
.
Errorf
(
"EnsureBackendPoolDeleted(%s) for service %s failed: %v"
,
lbBackendPoolID
,
serviceName
,
err
)
klog
.
Errorf
(
"EnsureBackendPoolDeleted(%s) for service %s failed: %v"
,
lbBackendPoolID
,
serviceName
,
err
)
return
nil
,
err
return
nil
,
err
...
@@ -981,7 +982,7 @@ func (az *Cloud) reconcileLoadBalancer(clusterName string, service *v1.Service,
...
@@ -981,7 +982,7 @@ func (az *Cloud) reconcileLoadBalancer(clusterName string, service *v1.Service,
vmSetName
:=
az
.
mapLoadBalancerNameToVMSet
(
lbName
,
clusterName
)
vmSetName
:=
az
.
mapLoadBalancerNameToVMSet
(
lbName
,
clusterName
)
// Etag would be changed when updating backend pools, so invalidate lbCache after it.
// Etag would be changed when updating backend pools, so invalidate lbCache after it.
defer
az
.
lbCache
.
Delete
(
lbName
)
defer
az
.
lbCache
.
Delete
(
lbName
)
err
:=
az
.
vm
Set
.
EnsureHostsInPool
(
service
,
nodes
,
lbBackendPoolID
,
vmSetName
,
isInternal
)
err
:=
az
.
VM
Set
.
EnsureHostsInPool
(
service
,
nodes
,
lbBackendPoolID
,
vmSetName
,
isInternal
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
vendor/k8s.io/legacy-cloud-providers/azure/azure_managedDiskController.go
View file @
6fa97306
...
@@ -287,11 +287,15 @@ func (c *ManagedDiskController) ResizeDisk(diskURI string, oldSize resource.Quan
...
@@ -287,11 +287,15 @@ func (c *ManagedDiskController) ResizeDisk(diskURI string, oldSize resource.Quan
return
newSizeQuant
,
nil
return
newSizeQuant
,
nil
}
}
result
.
DiskProperties
.
DiskSizeGB
=
&
requestGiB
diskParameter
:=
compute
.
DiskUpdate
{
DiskUpdateProperties
:
&
compute
.
DiskUpdateProperties
{
DiskSizeGB
:
&
requestGiB
,
},
}
ctx
,
cancel
=
getContextWithCancel
()
ctx
,
cancel
=
getContextWithCancel
()
defer
cancel
()
defer
cancel
()
if
rerr
:=
c
.
common
.
cloud
.
DisksClient
.
CreateOrUpdate
(
ctx
,
resourceGroup
,
diskName
,
result
);
rerr
!=
nil
{
if
rerr
:=
c
.
common
.
cloud
.
DisksClient
.
Update
(
ctx
,
resourceGroup
,
diskName
,
diskParameter
);
rerr
!=
nil
{
return
oldSize
,
rerr
.
Error
()
return
oldSize
,
rerr
.
Error
()
}
}
...
...
vendor/k8s.io/legacy-cloud-providers/azure/azure_standard.go
View file @
6fa97306
...
@@ -135,7 +135,7 @@ func (az *Cloud) getNetworkResourceSubscriptionID() string {
...
@@ -135,7 +135,7 @@ func (az *Cloud) getNetworkResourceSubscriptionID() string {
func
(
az
*
Cloud
)
mapLoadBalancerNameToVMSet
(
lbName
string
,
clusterName
string
)
(
vmSetName
string
)
{
func
(
az
*
Cloud
)
mapLoadBalancerNameToVMSet
(
lbName
string
,
clusterName
string
)
(
vmSetName
string
)
{
vmSetName
=
strings
.
TrimSuffix
(
lbName
,
InternalLoadBalancerNameSuffix
)
vmSetName
=
strings
.
TrimSuffix
(
lbName
,
InternalLoadBalancerNameSuffix
)
if
strings
.
EqualFold
(
clusterName
,
vmSetName
)
{
if
strings
.
EqualFold
(
clusterName
,
vmSetName
)
{
vmSetName
=
az
.
vm
Set
.
GetPrimaryVMSetName
()
vmSetName
=
az
.
VM
Set
.
GetPrimaryVMSetName
()
}
}
return
vmSetName
return
vmSetName
...
@@ -150,7 +150,7 @@ func (az *Cloud) getAzureLoadBalancerName(clusterName string, vmSetName string,
...
@@ -150,7 +150,7 @@ func (az *Cloud) getAzureLoadBalancerName(clusterName string, vmSetName string,
clusterName
=
az
.
LoadBalancerName
clusterName
=
az
.
LoadBalancerName
}
}
lbNamePrefix
:=
vmSetName
lbNamePrefix
:=
vmSetName
if
strings
.
EqualFold
(
vmSetName
,
az
.
vm
Set
.
GetPrimaryVMSetName
())
||
az
.
useStandardLoadBalancer
()
{
if
strings
.
EqualFold
(
vmSetName
,
az
.
VM
Set
.
GetPrimaryVMSetName
())
||
az
.
useStandardLoadBalancer
()
{
lbNamePrefix
=
clusterName
lbNamePrefix
=
clusterName
}
}
if
isInternal
{
if
isInternal
{
...
@@ -732,7 +732,7 @@ func (as *availabilitySet) EnsureHostInPool(service *v1.Service, nodeName types.
...
@@ -732,7 +732,7 @@ func (as *availabilitySet) EnsureHostInPool(service *v1.Service, nodeName types.
return
""
,
""
,
""
,
nil
,
nil
return
""
,
""
,
""
,
nil
,
nil
}
}
klog
.
Errorf
(
"error: az.EnsureHostInPool(%s), az.
vm
Set.GetPrimaryInterface.Get(%s, %s), err=%v"
,
nodeName
,
vmName
,
vmSetName
,
err
)
klog
.
Errorf
(
"error: az.EnsureHostInPool(%s), az.
VM
Set.GetPrimaryInterface.Get(%s, %s), err=%v"
,
nodeName
,
vmName
,
vmSetName
,
err
)
return
""
,
""
,
""
,
nil
,
err
return
""
,
""
,
""
,
nil
,
err
}
}
...
...
vendor/k8s.io/legacy-cloud-providers/azure/azure_vmss.go
View file @
6fa97306
...
@@ -531,17 +531,21 @@ func (ss *scaleSet) GetPrivateIPsByNodeName(nodeName string) ([]string, error) {
...
@@ -531,17 +531,21 @@ func (ss *scaleSet) GetPrivateIPsByNodeName(nodeName string) ([]string, error) {
// This returns the full identifier of the primary NIC for the given VM.
// This returns the full identifier of the primary NIC for the given VM.
func
(
ss
*
scaleSet
)
getPrimaryInterfaceID
(
machine
compute
.
VirtualMachineScaleSetVM
)
(
string
,
error
)
{
func
(
ss
*
scaleSet
)
getPrimaryInterfaceID
(
machine
compute
.
VirtualMachineScaleSetVM
)
(
string
,
error
)
{
if
machine
.
NetworkProfile
==
nil
||
machine
.
NetworkProfile
.
NetworkInterfaces
==
nil
{
return
""
,
fmt
.
Errorf
(
"failed to find the network interfaces for vm %s"
,
to
.
String
(
machine
.
Name
))
}
if
len
(
*
machine
.
NetworkProfile
.
NetworkInterfaces
)
==
1
{
if
len
(
*
machine
.
NetworkProfile
.
NetworkInterfaces
)
==
1
{
return
*
(
*
machine
.
NetworkProfile
.
NetworkInterfaces
)[
0
]
.
ID
,
nil
return
*
(
*
machine
.
NetworkProfile
.
NetworkInterfaces
)[
0
]
.
ID
,
nil
}
}
for
_
,
ref
:=
range
*
machine
.
NetworkProfile
.
NetworkInterfaces
{
for
_
,
ref
:=
range
*
machine
.
NetworkProfile
.
NetworkInterfaces
{
if
*
ref
.
Primary
{
if
to
.
Bool
(
ref
.
Primary
)
{
return
*
ref
.
ID
,
nil
return
*
ref
.
ID
,
nil
}
}
}
}
return
""
,
fmt
.
Errorf
(
"failed to find a primary nic for the vm. vmname=%q"
,
*
machine
.
Name
)
return
""
,
fmt
.
Errorf
(
"failed to find a primary nic for the vm. vmname=%q"
,
to
.
String
(
machine
.
Name
)
)
}
}
// getVmssMachineID returns the full identifier of a vmss virtual machine.
// getVmssMachineID returns the full identifier of a vmss virtual machine.
...
@@ -659,6 +663,9 @@ func (ss *scaleSet) listScaleSetVMs(scaleSetName, resourceGroup string) ([]compu
...
@@ -659,6 +663,9 @@ func (ss *scaleSet) listScaleSetVMs(scaleSetName, resourceGroup string) ([]compu
allVMs
,
rerr
:=
ss
.
VirtualMachineScaleSetVMsClient
.
List
(
ctx
,
resourceGroup
,
scaleSetName
,
string
(
compute
.
InstanceView
))
allVMs
,
rerr
:=
ss
.
VirtualMachineScaleSetVMsClient
.
List
(
ctx
,
resourceGroup
,
scaleSetName
,
string
(
compute
.
InstanceView
))
if
rerr
!=
nil
{
if
rerr
!=
nil
{
klog
.
Errorf
(
"VirtualMachineScaleSetVMsClient.List failed: %v"
,
rerr
)
klog
.
Errorf
(
"VirtualMachineScaleSetVMsClient.List failed: %v"
,
rerr
)
if
rerr
.
IsNotFound
()
{
return
nil
,
cloudprovider
.
InstanceNotFound
}
return
nil
,
rerr
.
Error
()
return
nil
,
rerr
.
Error
()
}
}
...
...
vendor/k8s.io/legacy-cloud-providers/azure/azure_zones.go
View file @
6fa97306
...
@@ -87,7 +87,7 @@ func (az *Cloud) GetZone(ctx context.Context) (cloudprovider.Zone, error) {
...
@@ -87,7 +87,7 @@ func (az *Cloud) GetZone(ctx context.Context) (cloudprovider.Zone, error) {
if
err
!=
nil
{
if
err
!=
nil
{
return
cloudprovider
.
Zone
{},
fmt
.
Errorf
(
"failure getting hostname from kernel"
)
return
cloudprovider
.
Zone
{},
fmt
.
Errorf
(
"failure getting hostname from kernel"
)
}
}
return
az
.
vm
Set
.
GetZoneByNodeName
(
strings
.
ToLower
(
hostname
))
return
az
.
VM
Set
.
GetZoneByNodeName
(
strings
.
ToLower
(
hostname
))
}
}
// GetZoneByProviderID implements Zones.GetZoneByProviderID
// GetZoneByProviderID implements Zones.GetZoneByProviderID
...
@@ -104,7 +104,7 @@ func (az *Cloud) GetZoneByProviderID(ctx context.Context, providerID string) (cl
...
@@ -104,7 +104,7 @@ func (az *Cloud) GetZoneByProviderID(ctx context.Context, providerID string) (cl
return
cloudprovider
.
Zone
{},
nil
return
cloudprovider
.
Zone
{},
nil
}
}
nodeName
,
err
:=
az
.
vm
Set
.
GetNodeNameByProviderID
(
providerID
)
nodeName
,
err
:=
az
.
VM
Set
.
GetNodeNameByProviderID
(
providerID
)
if
err
!=
nil
{
if
err
!=
nil
{
return
cloudprovider
.
Zone
{},
err
return
cloudprovider
.
Zone
{},
err
}
}
...
@@ -126,5 +126,5 @@ func (az *Cloud) GetZoneByNodeName(ctx context.Context, nodeName types.NodeName)
...
@@ -126,5 +126,5 @@ func (az *Cloud) GetZoneByNodeName(ctx context.Context, nodeName types.NodeName)
return
cloudprovider
.
Zone
{},
nil
return
cloudprovider
.
Zone
{},
nil
}
}
return
az
.
vm
Set
.
GetZoneByNodeName
(
string
(
nodeName
))
return
az
.
VM
Set
.
GetZoneByNodeName
(
string
(
nodeName
))
}
}
vendor/k8s.io/legacy-cloud-providers/azure/clients/diskclient/BUILD
View file @
6fa97306
...
@@ -19,6 +19,7 @@ go_library(
...
@@ -19,6 +19,7 @@ go_library(
"//vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-07-01/compute:go_default_library",
"//vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-07-01/compute:go_default_library",
"//vendor/github.com/Azure/go-autorest/autorest:go_default_library",
"//vendor/github.com/Azure/go-autorest/autorest:go_default_library",
"//vendor/github.com/Azure/go-autorest/autorest/azure:go_default_library",
"//vendor/github.com/Azure/go-autorest/autorest/azure:go_default_library",
"//vendor/github.com/Azure/go-autorest/autorest/to:go_default_library",
"//vendor/k8s.io/klog:go_default_library",
"//vendor/k8s.io/klog:go_default_library",
],
],
)
)
...
@@ -31,6 +32,7 @@ go_test(
...
@@ -31,6 +32,7 @@ go_test(
"//staging/src/k8s.io/legacy-cloud-providers/azure/clients:go_default_library",
"//staging/src/k8s.io/legacy-cloud-providers/azure/clients:go_default_library",
"//staging/src/k8s.io/legacy-cloud-providers/azure/clients/armclient:go_default_library",
"//staging/src/k8s.io/legacy-cloud-providers/azure/clients/armclient:go_default_library",
"//staging/src/k8s.io/legacy-cloud-providers/azure/clients/armclient/mockarmclient:go_default_library",
"//staging/src/k8s.io/legacy-cloud-providers/azure/clients/armclient/mockarmclient:go_default_library",
"//staging/src/k8s.io/legacy-cloud-providers/azure/retry:go_default_library",
"//vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-07-01/compute:go_default_library",
"//vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-07-01/compute:go_default_library",
"//vendor/github.com/Azure/go-autorest/autorest:go_default_library",
"//vendor/github.com/Azure/go-autorest/autorest:go_default_library",
"//vendor/github.com/Azure/go-autorest/autorest/to:go_default_library",
"//vendor/github.com/Azure/go-autorest/autorest/to:go_default_library",
...
...
vendor/k8s.io/legacy-cloud-providers/azure/clients/diskclient/azure_diskclient.go
View file @
6fa97306
...
@@ -20,12 +20,14 @@ package diskclient
...
@@ -20,12 +20,14 @@ package diskclient
import
(
import
(
"context"
"context"
"fmt"
"net/http"
"net/http"
"time"
"time"
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-07-01/compute"
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-07-01/compute"
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/to"
"k8s.io/client-go/util/flowcontrol"
"k8s.io/client-go/util/flowcontrol"
"k8s.io/klog"
"k8s.io/klog"
...
@@ -204,6 +206,74 @@ func (c *Client) createOrUpdateResponder(resp *http.Response) (*compute.Disk, *r
...
@@ -204,6 +206,74 @@ func (c *Client) createOrUpdateResponder(resp *http.Response) (*compute.Disk, *r
return
result
,
retry
.
GetError
(
resp
,
err
)
return
result
,
retry
.
GetError
(
resp
,
err
)
}
}
// Update creates or updates a Disk.
func
(
c
*
Client
)
Update
(
ctx
context
.
Context
,
resourceGroupName
string
,
diskName
string
,
diskParameter
compute
.
DiskUpdate
)
*
retry
.
Error
{
mc
:=
metrics
.
NewMetricContext
(
"disks"
,
"update"
,
resourceGroupName
,
c
.
subscriptionID
,
""
)
// Report errors if the client is rate limited.
if
!
c
.
rateLimiterWriter
.
TryAccept
()
{
mc
.
RateLimitedCount
()
return
retry
.
GetRateLimitError
(
true
,
"DiskUpdate"
)
}
// Report errors if the client is throttled.
if
c
.
RetryAfterWriter
.
After
(
time
.
Now
())
{
mc
.
ThrottledCount
()
rerr
:=
retry
.
GetThrottlingError
(
"DiskUpdate"
,
"client throttled"
,
c
.
RetryAfterWriter
)
return
rerr
}
rerr
:=
c
.
updateDisk
(
ctx
,
resourceGroupName
,
diskName
,
diskParameter
)
mc
.
Observe
(
rerr
.
Error
())
if
rerr
!=
nil
{
if
rerr
.
IsThrottled
()
{
// Update RetryAfterReader so that no more requests would be sent until RetryAfter expires.
c
.
RetryAfterWriter
=
rerr
.
RetryAfter
}
return
rerr
}
return
nil
}
// updateDisk updates a Disk.
func
(
c
*
Client
)
updateDisk
(
ctx
context
.
Context
,
resourceGroupName
string
,
diskName
string
,
diskParameter
compute
.
DiskUpdate
)
*
retry
.
Error
{
resourceID
:=
armclient
.
GetResourceID
(
c
.
subscriptionID
,
resourceGroupName
,
"Microsoft.Compute/disks"
,
diskName
,
)
response
,
rerr
:=
c
.
armClient
.
PatchResource
(
ctx
,
resourceID
,
diskParameter
)
defer
c
.
armClient
.
CloseResponse
(
ctx
,
response
)
if
rerr
!=
nil
{
klog
.
V
(
5
)
.
Infof
(
"Received error in %s: resourceID: %s, error: %s"
,
"disk.put.request"
,
resourceID
,
rerr
.
Error
())
return
rerr
}
if
response
!=
nil
&&
response
.
StatusCode
!=
http
.
StatusNoContent
{
_
,
rerr
=
c
.
updateResponder
(
response
)
if
rerr
!=
nil
{
klog
.
V
(
5
)
.
Infof
(
"Received error in %s: resourceID: %s, error: %s"
,
"disk.put.respond"
,
resourceID
,
rerr
.
Error
())
return
rerr
}
}
return
nil
}
func
(
c
*
Client
)
updateResponder
(
resp
*
http
.
Response
)
(
*
compute
.
Disk
,
*
retry
.
Error
)
{
result
:=
&
compute
.
Disk
{}
err
:=
autorest
.
Respond
(
resp
,
azure
.
WithErrorUnlessStatusCode
(
http
.
StatusOK
,
http
.
StatusCreated
),
autorest
.
ByUnmarshallingJSON
(
&
result
))
result
.
Response
=
autorest
.
Response
{
Response
:
resp
}
return
result
,
retry
.
GetError
(
resp
,
err
)
}
// Delete deletes a Disk by name.
// Delete deletes a Disk by name.
func
(
c
*
Client
)
Delete
(
ctx
context
.
Context
,
resourceGroupName
string
,
diskName
string
)
*
retry
.
Error
{
func
(
c
*
Client
)
Delete
(
ctx
context
.
Context
,
resourceGroupName
string
,
diskName
string
)
*
retry
.
Error
{
mc
:=
metrics
.
NewMetricContext
(
"disks"
,
"delete"
,
resourceGroupName
,
c
.
subscriptionID
,
""
)
mc
:=
metrics
.
NewMetricContext
(
"disks"
,
"delete"
,
resourceGroupName
,
c
.
subscriptionID
,
""
)
...
@@ -246,3 +316,126 @@ func (c *Client) deleteDisk(ctx context.Context, resourceGroupName string, diskN
...
@@ -246,3 +316,126 @@ func (c *Client) deleteDisk(ctx context.Context, resourceGroupName string, diskN
return
c
.
armClient
.
DeleteResource
(
ctx
,
resourceID
,
""
)
return
c
.
armClient
.
DeleteResource
(
ctx
,
resourceID
,
""
)
}
}
// ListByResourceGroup lists all the disks under a resource group.
func
(
c
*
Client
)
ListByResourceGroup
(
ctx
context
.
Context
,
resourceGroupName
string
)
([]
compute
.
Disk
,
*
retry
.
Error
)
{
resourceID
:=
fmt
.
Sprintf
(
"/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Compute/disks"
,
autorest
.
Encode
(
"path"
,
c
.
subscriptionID
),
autorest
.
Encode
(
"path"
,
resourceGroupName
))
result
:=
make
([]
compute
.
Disk
,
0
)
page
:=
&
DiskListPage
{}
page
.
fn
=
c
.
listNextResults
resp
,
rerr
:=
c
.
armClient
.
GetResource
(
ctx
,
resourceID
,
""
)
defer
c
.
armClient
.
CloseResponse
(
ctx
,
resp
)
if
rerr
!=
nil
{
klog
.
V
(
5
)
.
Infof
(
"Received error in %s: resourceID: %s, error: %s"
,
"disk.list.request"
,
resourceID
,
rerr
.
Error
())
return
result
,
rerr
}
var
err
error
page
.
dl
,
err
=
c
.
listResponder
(
resp
)
if
err
!=
nil
{
klog
.
V
(
5
)
.
Infof
(
"Received error in %s: resourceID: %s, error: %s"
,
"disk.list.respond"
,
resourceID
,
err
)
return
result
,
retry
.
GetError
(
resp
,
err
)
}
for
page
.
NotDone
()
{
result
=
append
(
result
,
*
page
.
Response
()
.
Value
...
)
if
err
=
page
.
NextWithContext
(
ctx
);
err
!=
nil
{
klog
.
V
(
5
)
.
Infof
(
"Received error in %s: resourceID: %s, error: %s"
,
"disk.list.next"
,
resourceID
,
err
)
return
result
,
retry
.
GetError
(
page
.
Response
()
.
Response
.
Response
,
err
)
}
}
return
result
,
nil
}
// listNextResults retrieves the next set of results, if any.
func
(
c
*
Client
)
listNextResults
(
ctx
context
.
Context
,
lastResults
compute
.
DiskList
)
(
result
compute
.
DiskList
,
err
error
)
{
req
,
err
:=
c
.
diskListPreparer
(
ctx
,
lastResults
)
if
err
!=
nil
{
return
result
,
autorest
.
NewErrorWithError
(
err
,
"diskclient"
,
"listNextResults"
,
nil
,
"Failure preparing next results request"
)
}
if
req
==
nil
{
return
}
resp
,
rerr
:=
c
.
armClient
.
Send
(
ctx
,
req
)
defer
c
.
armClient
.
CloseResponse
(
ctx
,
resp
)
if
rerr
!=
nil
{
result
.
Response
=
autorest
.
Response
{
Response
:
resp
}
return
result
,
autorest
.
NewErrorWithError
(
rerr
.
Error
(),
"diskclient"
,
"listNextResults"
,
resp
,
"Failure sending next results request"
)
}
result
,
err
=
c
.
listResponder
(
resp
)
if
err
!=
nil
{
err
=
autorest
.
NewErrorWithError
(
err
,
"diskclient"
,
"listNextResults"
,
resp
,
"Failure responding to next results request"
)
}
return
}
// listResponder handles the response to the List request. The method always
// closes the http.Response Body.
func
(
c
*
Client
)
listResponder
(
resp
*
http
.
Response
)
(
result
compute
.
DiskList
,
err
error
)
{
err
=
autorest
.
Respond
(
resp
,
azure
.
WithErrorUnlessStatusCode
(
http
.
StatusOK
),
autorest
.
ByUnmarshallingJSON
(
&
result
),
autorest
.
ByClosing
())
result
.
Response
=
autorest
.
Response
{
Response
:
resp
}
return
}
func
(
c
*
Client
)
diskListPreparer
(
ctx
context
.
Context
,
lr
compute
.
DiskList
)
(
*
http
.
Request
,
error
)
{
if
lr
.
NextLink
==
nil
||
len
(
to
.
String
(
lr
.
NextLink
))
<
1
{
return
nil
,
nil
}
return
autorest
.
Prepare
((
&
http
.
Request
{})
.
WithContext
(
ctx
),
autorest
.
AsJSON
(),
autorest
.
AsGet
(),
autorest
.
WithBaseURL
(
to
.
String
(
lr
.
NextLink
)))
}
// DiskListPage contains a page of Disk values.
type
DiskListPage
struct
{
fn
func
(
context
.
Context
,
compute
.
DiskList
)
(
compute
.
DiskList
,
error
)
dl
compute
.
DiskList
}
// NextWithContext advances to the next page of values. If there was an error making
// the request the page does not advance and the error is returned.
func
(
page
*
DiskListPage
)
NextWithContext
(
ctx
context
.
Context
)
(
err
error
)
{
next
,
err
:=
page
.
fn
(
ctx
,
page
.
dl
)
if
err
!=
nil
{
return
err
}
page
.
dl
=
next
return
nil
}
// Next advances to the next page of values. If there was an error making
// the request the page does not advance and the error is returned.
// Deprecated: Use NextWithContext() instead.
func
(
page
*
DiskListPage
)
Next
()
error
{
return
page
.
NextWithContext
(
context
.
Background
())
}
// NotDone returns true if the page enumeration should be started or is not yet complete.
func
(
page
DiskListPage
)
NotDone
()
bool
{
return
!
page
.
dl
.
IsEmpty
()
}
// Response returns the raw server response from the last page request.
func
(
page
DiskListPage
)
Response
()
compute
.
DiskList
{
return
page
.
dl
}
// Values returns the slice of values for the current page or nil if there are no values.
func
(
page
DiskListPage
)
Values
()
[]
compute
.
Disk
{
if
page
.
dl
.
IsEmpty
()
{
return
nil
}
return
*
page
.
dl
.
Value
}
vendor/k8s.io/legacy-cloud-providers/azure/clients/diskclient/interface.go
View file @
6fa97306
...
@@ -40,6 +40,12 @@ type Interface interface {
...
@@ -40,6 +40,12 @@ type Interface interface {
// CreateOrUpdate creates or updates a Disk.
// CreateOrUpdate creates or updates a Disk.
CreateOrUpdate
(
ctx
context
.
Context
,
resourceGroupName
string
,
diskName
string
,
diskParameter
compute
.
Disk
)
*
retry
.
Error
CreateOrUpdate
(
ctx
context
.
Context
,
resourceGroupName
string
,
diskName
string
,
diskParameter
compute
.
Disk
)
*
retry
.
Error
// Update updates a Disk.
Update
(
ctx
context
.
Context
,
resourceGroupName
string
,
diskName
string
,
diskParameter
compute
.
DiskUpdate
)
*
retry
.
Error
// Delete deletes a Disk by name.
// Delete deletes a Disk by name.
Delete
(
ctx
context
.
Context
,
resourceGroupName
string
,
diskName
string
)
*
retry
.
Error
Delete
(
ctx
context
.
Context
,
resourceGroupName
string
,
diskName
string
)
*
retry
.
Error
// ListByResourceGroup lists all the disks under a resource group.
ListByResourceGroup
(
ctx
context
.
Context
,
resourceGroupName
string
)
([]
compute
.
Disk
,
*
retry
.
Error
)
}
}
vendor/k8s.io/legacy-cloud-providers/azure/metrics/azure_metrics.go
View file @
6fa97306
...
@@ -86,6 +86,7 @@ func registerAPIMetrics(attributes ...string) *apiCallMetrics {
...
@@ -86,6 +86,7 @@ func registerAPIMetrics(attributes ...string) *apiCallMetrics {
&
metrics
.
HistogramOpts
{
&
metrics
.
HistogramOpts
{
Name
:
"cloudprovider_azure_api_request_duration_seconds"
,
Name
:
"cloudprovider_azure_api_request_duration_seconds"
,
Help
:
"Latency of an Azure API call"
,
Help
:
"Latency of an Azure API call"
,
Buckets
:
[]
float64
{
.1
,
.25
,
.5
,
1
,
2.5
,
5
,
10
,
15
,
25
,
50
,
120
,
300
,
600
,
1200
},
StabilityLevel
:
metrics
.
ALPHA
,
StabilityLevel
:
metrics
.
ALPHA
,
},
},
attributes
,
attributes
,
...
...
vendor/k8s.io/legacy-cloud-providers/azure/retry/azure_error.go
View file @
6fa97306
...
@@ -89,6 +89,15 @@ func (err *Error) IsThrottled() bool {
...
@@ -89,6 +89,15 @@ func (err *Error) IsThrottled() bool {
return
err
.
HTTPStatusCode
==
http
.
StatusTooManyRequests
||
err
.
RetryAfter
.
After
(
now
())
return
err
.
HTTPStatusCode
==
http
.
StatusTooManyRequests
||
err
.
RetryAfter
.
After
(
now
())
}
}
// IsNotFound returns true the if the requested object wasn't found
func
(
err
*
Error
)
IsNotFound
()
bool
{
if
err
==
nil
{
return
false
}
return
err
.
HTTPStatusCode
==
http
.
StatusNotFound
}
// NewError creates a new Error.
// NewError creates a new Error.
func
NewError
(
retriable
bool
,
err
error
)
*
Error
{
func
NewError
(
retriable
bool
,
err
error
)
*
Error
{
return
&
Error
{
return
&
Error
{
...
@@ -286,3 +295,20 @@ func IsErrorRetriable(err error) bool {
...
@@ -286,3 +295,20 @@ func IsErrorRetriable(err error) bool {
return
strings
.
Contains
(
err
.
Error
(),
"Retriable: true"
)
return
strings
.
Contains
(
err
.
Error
(),
"Retriable: true"
)
}
}
// HasStatusForbiddenOrIgnoredError return true if the given error code is part of the error message
// This should only be used when trying to delete resources
func
HasStatusForbiddenOrIgnoredError
(
err
error
)
bool
{
if
err
==
nil
{
return
false
}
if
strings
.
Contains
(
err
.
Error
(),
fmt
.
Sprintf
(
"HTTPStatusCode: %d"
,
http
.
StatusNotFound
))
{
return
true
}
if
strings
.
Contains
(
err
.
Error
(),
fmt
.
Sprintf
(
"HTTPStatusCode: %d"
,
http
.
StatusForbidden
))
{
return
true
}
return
false
}
vendor/modules.txt
View file @
6fa97306
This diff is collapsed.
Click to expand it.
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