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
75b8d71e
Unverified
Commit
75b8d71e
authored
Jul 17, 2019
by
Erik Wilson
Committed by
GitHub
Jul 17, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #652 from erikwilson/update-tunnel-wait
Fix tunnel endpoint upgrade
parents
33a59542
23b07975
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
3 deletions
+18
-3
run.go
pkg/agent/run.go
+1
-1
tunnel.go
pkg/agent/tunnel/tunnel.go
+17
-2
No files found.
pkg/agent/run.go
View file @
75b8d71e
...
@@ -47,7 +47,7 @@ func run(ctx context.Context, cfg cmds.Agent) error {
...
@@ -47,7 +47,7 @@ func run(ctx context.Context, cfg cmds.Agent) error {
return
err
return
err
}
}
if
err
:=
tunnel
.
Setup
(
nodeConfig
);
err
!=
nil
{
if
err
:=
tunnel
.
Setup
(
ctx
,
nodeConfig
);
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/agent/tunnel/tunnel.go
View file @
75b8d71e
...
@@ -52,7 +52,7 @@ func getAddresses(endpoint *v1.Endpoints) []string {
...
@@ -52,7 +52,7 @@ func getAddresses(endpoint *v1.Endpoints) []string {
return
serverAddresses
return
serverAddresses
}
}
func
Setup
(
config
*
config
.
Node
)
error
{
func
Setup
(
c
tx
context
.
Context
,
c
onfig
*
config
.
Node
)
error
{
restConfig
,
err
:=
clientcmd
.
BuildConfigFromFlags
(
""
,
config
.
AgentConfig
.
KubeConfigNode
)
restConfig
,
err
:=
clientcmd
.
BuildConfigFromFlags
(
""
,
config
.
AgentConfig
.
KubeConfigNode
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
@@ -83,7 +83,6 @@ func Setup(config *config.Node) error {
...
@@ -83,7 +83,6 @@ func Setup(config *config.Node) error {
disconnect
[
address
]
=
connect
(
wg
,
address
,
config
,
transportConfig
)
disconnect
[
address
]
=
connect
(
wg
,
address
,
config
,
transportConfig
)
}
}
}
}
wg
.
Wait
()
go
func
()
{
go
func
()
{
connect
:
connect
:
...
@@ -134,6 +133,19 @@ func Setup(config *config.Node) error {
...
@@ -134,6 +133,19 @@ func Setup(config *config.Node) error {
}
}
}()
}()
wait
:=
make
(
chan
int
,
1
)
go
func
()
{
wg
.
Wait
()
wait
<-
0
}()
select
{
case
<-
ctx
.
Done
()
:
logrus
.
Error
(
"tunnel context canceled while waiting for connection"
)
return
ctx
.
Err
()
case
<-
wait
:
}
return
nil
return
nil
}
}
...
@@ -178,6 +190,9 @@ func connect(waitGroup *sync.WaitGroup, address string, config *config.Node, tra
...
@@ -178,6 +190,9 @@ func connect(waitGroup *sync.WaitGroup, address string, config *config.Node, tra
})
})
if
ctx
.
Err
()
!=
nil
{
if
ctx
.
Err
()
!=
nil
{
if
waitGroup
!=
nil
{
once
.
Do
(
waitGroup
.
Done
)
}
logrus
.
Infof
(
"Stopped tunnel to %s"
,
wsURL
)
logrus
.
Infof
(
"Stopped tunnel to %s"
,
wsURL
)
return
return
}
}
...
...
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