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
61efc293
Commit
61efc293
authored
Apr 13, 2018
by
Jan Chaloupka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Timeout on instances.NodeAddresses cloud provider request
parent
2bfe40a1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
1 deletion
+48
-1
kubelet.go
pkg/kubelet/kubelet.go
+15
-0
kubelet_node_status.go
pkg/kubelet/kubelet_node_status.go
+30
-1
kubelet_node_status_test.go
pkg/kubelet/kubelet_node_status_test.go
+3
-0
No files found.
pkg/kubelet/kubelet.go
View file @
61efc293
...
...
@@ -531,6 +531,13 @@ func NewMainKubelet(kubeCfg *kubeletconfiginternal.KubeletConfiguration,
keepTerminatedPodVolumes
:
keepTerminatedPodVolumes
,
}
if
klet
.
cloud
!=
nil
{
klet
.
cloudproviderRequestParallelism
=
make
(
chan
int
,
1
)
klet
.
cloudproviderRequestSync
=
make
(
chan
int
)
// TODO(jchaloup): Make it configurable via --cloud-provider-request-timeout
klet
.
cloudproviderRequestTimeout
=
10
*
time
.
Second
}
secretManager
:=
secret
.
NewCachingSecretManager
(
kubeDeps
.
KubeClient
,
secret
.
GetObjectTTLFromNodeFunc
(
klet
.
GetNode
))
klet
.
secretManager
=
secretManager
...
...
@@ -967,6 +974,14 @@ type Kubelet struct {
// Cloud provider interface.
cloud
cloudprovider
.
Interface
// To keep exclusive access to the cloudproviderRequestParallelism
cloudproviderRequestMux
sync
.
Mutex
// Keep the count of requests processed in parallel (expected to be 1 at most at a given time)
cloudproviderRequestParallelism
chan
int
// Sync with finished requests
cloudproviderRequestSync
chan
int
// Request timeout
cloudproviderRequestTimeout
time
.
Duration
// Indicates that the node initialization happens in an external cloud controller
externalCloudProvider
bool
...
...
pkg/kubelet/kubelet_node_status.go
View file @
61efc293
...
...
@@ -432,7 +432,36 @@ func (kl *Kubelet) setNodeAddress(node *v1.Node) error {
// to the cloud provider?
// TODO(justinsb): We can if CurrentNodeName() was actually CurrentNode() and returned an interface
// TODO: If IP addresses couldn't be fetched from the cloud provider, should kubelet fallback on the other methods for getting the IP below?
nodeAddresses
,
err
:=
instances
.
NodeAddresses
(
context
.
TODO
(),
kl
.
nodeName
)
var
nodeAddresses
[]
v1
.
NodeAddress
var
err
error
// Make sure the instances.NodeAddresses returns even if the cloud provider API hangs for a long time
func
()
{
kl
.
cloudproviderRequestMux
.
Lock
()
if
len
(
kl
.
cloudproviderRequestParallelism
)
>
0
{
kl
.
cloudproviderRequestMux
.
Unlock
()
return
}
kl
.
cloudproviderRequestParallelism
<-
0
kl
.
cloudproviderRequestMux
.
Unlock
()
go
func
()
{
nodeAddresses
,
err
=
instances
.
NodeAddresses
(
context
.
TODO
(),
kl
.
nodeName
)
kl
.
cloudproviderRequestMux
.
Lock
()
<-
kl
.
cloudproviderRequestParallelism
kl
.
cloudproviderRequestMux
.
Unlock
()
kl
.
cloudproviderRequestSync
<-
0
}()
}()
select
{
case
<-
kl
.
cloudproviderRequestSync
:
case
<-
time
.
After
(
kl
.
cloudproviderRequestTimeout
)
:
err
=
fmt
.
Errorf
(
"Timeout after %v"
,
kl
.
cloudproviderRequestTimeout
)
}
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to get node address from cloud provider: %v"
,
err
)
}
...
...
pkg/kubelet/kubelet_node_status_test.go
View file @
61efc293
...
...
@@ -192,6 +192,9 @@ func TestNodeStatusWithCloudProviderNodeIP(t *testing.T) {
Err
:
nil
,
}
kubelet
.
cloud
=
fakeCloud
kubelet
.
cloudproviderRequestParallelism
=
make
(
chan
int
,
1
)
kubelet
.
cloudproviderRequestSync
=
make
(
chan
int
)
kubelet
.
cloudproviderRequestTimeout
=
10
*
time
.
Second
kubelet
.
setNodeAddress
(
&
existingNode
)
...
...
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