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
afee83dd
Commit
afee83dd
authored
Jun 29, 2022
by
Brad Davidson
Committed by
Brad Davidson
Jul 07, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bump remotedialer
Includes fix for recently identified memory leak. Signed-off-by:
Brad Davidson
<
brad.davidson@rancher.com
>
parent
a2372602
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
12 deletions
+26
-12
go.mod
go.mod
+1
-1
go.sum
go.sum
+2
-2
tunnel.go
pkg/agent/tunnel/tunnel.go
+1
-1
tunnel.go
pkg/daemons/control/tunnel.go
+22
-8
No files found.
go.mod
View file @
afee83dd
...
...
@@ -99,7 +99,7 @@ require (
github.com/pkg/errors v0.9.1
github.com/rancher/dynamiclistener v0.3.3
github.com/rancher/lasso v0.0.0-20210616224652-fc3ebd901c08
github.com/rancher/remotedialer v0.2.
0
github.com/rancher/remotedialer v0.2.
6-0.20220624190122-ea57207bf2b8
github.com/rancher/wharfie v0.5.1
github.com/rancher/wrangler v1.0.0
github.com/robfig/cron/v3 v3.0.1
...
...
go.sum
View file @
afee83dd
...
...
@@ -1092,8 +1092,8 @@ github.com/rancher/dynamiclistener v0.3.3 h1:pNwVc3vzuEHsbqAh1e76asq4aeDzHFV/5Ha
github.com/rancher/dynamiclistener v0.3.3/go.mod h1:QwTpy+drx4gvPMefrrUUKpVaWiy74O7vNvkwBXJ+s3E=
github.com/rancher/lasso v0.0.0-20210616224652-fc3ebd901c08 h1:NxR8Fh0eE7/5/5Zvlog9B5NVjWKqBSb1WYMUF7/IE5c=
github.com/rancher/lasso v0.0.0-20210616224652-fc3ebd901c08/go.mod h1:9qZd/S8DqWzfKtjKGgSoHqGEByYmUE3qRaBaaAHwfEM=
github.com/rancher/remotedialer v0.2.
0 h1:xD7t3K6JYwTdAsxmGtTHQMkEkFgKouQ1foLxVW424Dc
=
github.com/rancher/remotedialer v0.2.
0/go.mod h1:tkU8ZvrR5lRgaKWaX71nAy6daeqvPFx/lJEnbW7tXSI
=
github.com/rancher/remotedialer v0.2.
6-0.20220624190122-ea57207bf2b8 h1:leqh0chjBsXhKWebxxFd5QPcoQLu51EpaHo04ce0o+8
=
github.com/rancher/remotedialer v0.2.
6-0.20220624190122-ea57207bf2b8/go.mod h1:BwwztuvViX2JrLLUwDlsYt5DiyUwHLlzynRwkZLAY0Q
=
github.com/rancher/wharfie v0.5.1 h1:TUqZyNj6BaGe2+tqhwAGwZouuwx02mvAMMjNuyejc5I=
github.com/rancher/wharfie v0.5.1/go.mod h1:5AHZRFBAOWYPDNCwj/y5Dpj+MMwXLoitPwxjYAIbcxQ=
github.com/rancher/wrangler v0.8.3/go.mod h1:dKEaHNB4izxmPUtpq1Hvr3z3Oh+9k5pCZyFO9sUhlaY=
...
...
pkg/agent/tunnel/tunnel.go
View file @
afee83dd
...
...
@@ -341,7 +341,7 @@ func (a *agentTunnel) connect(rootCtx context.Context, waitGroup *sync.WaitGroup
for
{
remotedialer
.
ClientConnect
(
ctx
,
wsURL
,
nil
,
ws
,
func
(
proto
,
address
string
)
bool
{
return
a
.
authorized
(
rootCtx
,
proto
,
address
)
},
func
(
_
context
.
Context
)
error
{
},
func
(
_
context
.
Context
,
_
*
remotedialer
.
Session
)
error
{
if
waitGroup
!=
nil
{
once
.
Do
(
waitGroup
.
Done
)
}
...
...
pkg/daemons/control/tunnel.go
View file @
afee83dd
...
...
@@ -27,6 +27,8 @@ import (
"k8s.io/client-go/kubernetes"
)
var
defaultDialer
=
net
.
Dialer
{}
func
loggingErrorWriter
(
rw
http
.
ResponseWriter
,
req
*
http
.
Request
,
code
int
,
err
error
)
{
logrus
.
Debugf
(
"Tunnel server error: %d %v"
,
code
,
err
)
rw
.
WriteHeader
(
code
)
...
...
@@ -167,10 +169,10 @@ func (t *TunnelServer) onChangePod(podName string, pod *v1.Pod) (*v1.Pod, error)
// serveConnect attempts to handle the HTTP CONNECT request by dialing
// a connection, either locally or via the remotedialer tunnel.
func
(
t
*
TunnelServer
)
serveConnect
(
resp
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
bconn
,
err
:=
t
.
dialBackend
(
req
.
Host
)
bconn
,
err
:=
t
.
dialBackend
(
req
.
Context
(),
req
.
Host
)
if
err
!=
nil
{
responsewriters
.
ErrorNegotiated
(
apierrors
.
New
InternalError
(
errors
.
Wrap
(
err
,
"no tunnels available"
)),
apierrors
.
New
ServiceUnavailable
(
err
.
Error
(
)),
scheme
.
Codecs
.
WithoutConversion
(),
schema
.
GroupVersion
{},
resp
,
req
,
)
return
...
...
@@ -203,7 +205,7 @@ func (t *TunnelServer) serveConnect(resp http.ResponseWriter, req *http.Request)
// tunnel connection, the agent may return an error if the agent's authorizer
// denies the connection, or if there is some other error in actually dialing
// the requested endpoint.
func
(
t
*
TunnelServer
)
dialBackend
(
addr
string
)
(
net
.
Conn
,
error
)
{
func
(
t
*
TunnelServer
)
dialBackend
(
ctx
context
.
Context
,
addr
string
)
(
net
.
Conn
,
error
)
{
host
,
port
,
err
:=
net
.
SplitHostPort
(
addr
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -245,14 +247,26 @@ func (t *TunnelServer) dialBackend(addr string) (net.Conn, error) {
useTunnel
=
false
}
if
useTunnel
&&
t
.
server
.
HasSession
(
nodeName
)
{
// Have a session and it is safe to use for this destination, do so.
logrus
.
Debugf
(
"Tunnel server egress proxy dialing %s via session to %s"
,
addr
,
nodeName
)
return
t
.
server
.
Dial
(
nodeName
,
15
*
time
.
Second
,
"tcp"
,
addr
)
if
useTunnel
{
// Dialer(nodeName) returns a dial function that calls getDialer internally, which does the same locked session search
// as HasSession(nodeName). Rather than checking twice, just attempt the dial and handle the error if no session is found.
dialContext
:=
t
.
server
.
Dialer
(
nodeName
)
if
conn
,
err
:=
dialContext
(
ctx
,
"tcp"
,
addr
);
err
!=
nil
{
logrus
.
Debugf
(
"Tunnel server egress proxy dial error: %v"
,
err
)
if
toKubelet
&&
strings
.
HasPrefix
(
err
.
Error
(),
"failed to find Session for client"
)
{
// Don't have a session and we're trying to remote dial the kubelet via loopback, reject the connection.
return
conn
,
err
}
// any other error is ignored; fall back to to dialing directly.
}
else
{
// Have a session and it is safe to use for this destination, do so.
logrus
.
Debugf
(
"Tunnel server egress proxy dialing %s via Session to %s"
,
addr
,
nodeName
)
return
conn
,
err
}
}
// Don't have a session, the agent doesn't support tunneling to this destination, or
// the destination is local; fall back to direct connection.
logrus
.
Debugf
(
"Tunnel server egress proxy dialing %s directly"
,
addr
)
return
net
.
Dial
(
"tcp"
,
addr
)
return
defaultDialer
.
DialContext
(
ctx
,
"tcp"
,
addr
)
}
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