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
9ff0943d
Commit
9ff0943d
authored
Nov 16, 2022
by
Brad Davidson
Committed by
Brad Davidson
Nov 21, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Address nits from self-review
Signed-off-by:
Brad Davidson
<
brad.davidson@rancher.com
>
parent
56bf7d6a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
13 deletions
+15
-13
portdriver.go
pkg/rootless/portdriver.go
+13
-1
rootless.go
pkg/rootless/rootless.go
+2
-12
No files found.
pkg/rootless/portdriver.go
View file @
9ff0943d
...
@@ -6,6 +6,7 @@ package rootless
...
@@ -6,6 +6,7 @@ package rootless
import
(
import
(
"io"
"io"
"path"
"path"
"strings"
"github.com/rootless-containers/rootlesskit/pkg/port"
"github.com/rootless-containers/rootlesskit/pkg/port"
portbuiltin
"github.com/rootless-containers/rootlesskit/pkg/port/builtin"
portbuiltin
"github.com/rootless-containers/rootlesskit/pkg/port/builtin"
...
@@ -13,6 +14,15 @@ import (
...
@@ -13,6 +14,15 @@ import (
"github.com/sirupsen/logrus"
"github.com/sirupsen/logrus"
)
)
type
logrusDebugWriter
struct
{
}
func
(
w
*
logrusDebugWriter
)
Write
(
p
[]
byte
)
(
int
,
error
)
{
s
:=
strings
.
TrimSuffix
(
string
(
p
),
"
\n
"
)
logrus
.
Debug
(
s
)
return
len
(
p
),
nil
}
type
portDriver
interface
{
type
portDriver
interface
{
NewParentDriver
()
(
port
.
ParentDriver
,
error
)
NewParentDriver
()
(
port
.
ParentDriver
,
error
)
NewChildDriver
()
port
.
ChildDriver
NewChildDriver
()
port
.
ChildDriver
...
@@ -74,7 +84,9 @@ func (s *slirp4netnsDriver) APISocketPath() string {
...
@@ -74,7 +84,9 @@ func (s *slirp4netnsDriver) APISocketPath() string {
return
""
return
""
}
}
func
getDriver
(
driverName
string
,
logWriter
io
.
Writer
)
portDriver
{
func
getDriver
(
driverName
string
)
portDriver
{
logWriter
:=
&
logrusDebugWriter
{}
if
driverName
==
"slirp4netns"
{
if
driverName
==
"slirp4netns"
{
return
&
slirp4netnsDriver
{
logWriter
:
logWriter
}
return
&
slirp4netnsDriver
{
logWriter
:
logWriter
}
}
}
...
...
pkg/rootless/rootless.go
View file @
9ff0943d
...
@@ -42,9 +42,8 @@ func Rootless(stateDir string, enableIPv6 bool) error {
...
@@ -42,9 +42,8 @@ func Rootless(stateDir string, enableIPv6 bool) error {
hasFD
:=
os
.
Getenv
(
pipeFD
)
!=
""
hasFD
:=
os
.
Getenv
(
pipeFD
)
!=
""
hasChildEnv
:=
os
.
Getenv
(
childEnv
)
!=
""
hasChildEnv
:=
os
.
Getenv
(
childEnv
)
!=
""
driverName
:=
strings
.
ToLower
(
os
.
Getenv
(
portDriverEnv
))
rootlessDir
:=
filepath
.
Join
(
stateDir
,
"rootless"
)
rootlessDir
:=
filepath
.
Join
(
stateDir
,
"rootless"
)
driver
:=
getDriver
(
driverName
,
&
logrusDebugWriter
{}
)
driver
:=
getDriver
(
strings
.
ToLower
(
os
.
Getenv
(
portDriverEnv
))
)
if
hasFD
{
if
hasFD
{
logrus
.
Debug
(
"Running rootless child"
)
logrus
.
Debug
(
"Running rootless child"
)
...
@@ -166,7 +165,7 @@ func createParentOpt(driver portDriver, stateDir string, enableIPv6 bool) (*pare
...
@@ -166,7 +165,7 @@ func createParentOpt(driver portDriver, stateDir string, enableIPv6 bool) (*pare
mtu
:=
0
mtu
:=
0
if
val
:=
os
.
Getenv
(
mtuEnv
);
val
!=
""
{
if
val
:=
os
.
Getenv
(
mtuEnv
);
val
!=
""
{
if
v
,
err
:=
strconv
.
ParseInt
(
val
,
10
,
0
);
err
!=
nil
{
if
v
,
err
:=
strconv
.
ParseInt
(
val
,
10
,
0
);
err
!=
nil
{
logrus
.
Warn
(
"Failed to parse rootless mtu; using default"
)
logrus
.
Warn
(
"Failed to parse rootless mtu
value
; using default"
)
}
else
{
}
else
{
mtu
=
int
(
v
)
mtu
=
int
(
v
)
}
}
...
@@ -217,15 +216,6 @@ func createParentOpt(driver portDriver, stateDir string, enableIPv6 bool) (*pare
...
@@ -217,15 +216,6 @@ func createParentOpt(driver portDriver, stateDir string, enableIPv6 bool) (*pare
return
opt
,
nil
return
opt
,
nil
}
}
type
logrusDebugWriter
struct
{
}
func
(
w
*
logrusDebugWriter
)
Write
(
p
[]
byte
)
(
int
,
error
)
{
s
:=
strings
.
TrimSuffix
(
string
(
p
),
"
\n
"
)
logrus
.
Debug
(
s
)
return
len
(
p
),
nil
}
func
createChildOpt
(
driver
portDriver
)
(
*
child
.
Opt
,
error
)
{
func
createChildOpt
(
driver
portDriver
)
(
*
child
.
Opt
,
error
)
{
opt
:=
&
child
.
Opt
{}
opt
:=
&
child
.
Opt
{}
opt
.
TargetCmd
=
os
.
Args
opt
.
TargetCmd
=
os
.
Args
...
...
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