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
8c197bdc
Commit
8c197bdc
authored
Sep 13, 2023
by
Manuel Buil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Include the interface name in the error message
Signed-off-by:
Manuel Buil
<
mbuil@suse.com
>
parent
56abe705
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
8 deletions
+15
-8
config.go
pkg/agent/config/config.go
+1
-1
agent.go
pkg/cli/agent/agent.go
+5
-1
server.go
pkg/cli/server/server.go
+5
-1
net.go
pkg/util/net.go
+4
-5
No files found.
pkg/agent/config/config.go
View file @
8c197bdc
...
@@ -363,7 +363,7 @@ func get(ctx context.Context, envInfo *cmds.Agent, proxy proxy.Proxy) (*config.N
...
@@ -363,7 +363,7 @@ func get(ctx context.Context, envInfo *cmds.Agent, proxy proxy.Proxy) (*config.N
if
controlConfig
.
FlannelBackend
!=
config
.
FlannelBackendNone
&&
len
(
envInfo
.
FlannelIface
)
>
0
{
if
controlConfig
.
FlannelBackend
!=
config
.
FlannelBackendNone
&&
len
(
envInfo
.
FlannelIface
)
>
0
{
flannelIface
,
err
=
net
.
InterfaceByName
(
envInfo
.
FlannelIface
)
flannelIface
,
err
=
net
.
InterfaceByName
(
envInfo
.
FlannelIface
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
errors
.
Wrapf
(
err
,
"unable to find interface
"
)
return
nil
,
errors
.
Wrapf
(
err
,
"unable to find interface
%s"
,
envInfo
.
FlannelIface
)
}
}
}
}
...
...
pkg/cli/agent/agent.go
View file @
8c197bdc
...
@@ -60,7 +60,11 @@ func Run(ctx *cli.Context) error {
...
@@ -60,7 +60,11 @@ func Run(ctx *cli.Context) error {
}
}
if
cmds
.
AgentConfig
.
FlannelIface
!=
""
&&
len
(
cmds
.
AgentConfig
.
NodeIP
)
==
0
{
if
cmds
.
AgentConfig
.
FlannelIface
!=
""
&&
len
(
cmds
.
AgentConfig
.
NodeIP
)
==
0
{
cmds
.
AgentConfig
.
NodeIP
.
Set
(
util
.
GetIPFromInterface
(
cmds
.
AgentConfig
.
FlannelIface
))
ip
,
err
:=
util
.
GetIPFromInterface
(
cmds
.
AgentConfig
.
FlannelIface
)
if
err
!=
nil
{
return
err
}
cmds
.
AgentConfig
.
NodeIP
.
Set
(
ip
)
}
}
logrus
.
Info
(
"Starting "
+
version
.
Program
+
" agent "
+
ctx
.
App
.
Version
)
logrus
.
Info
(
"Starting "
+
version
.
Program
+
" agent "
+
ctx
.
App
.
Version
)
...
...
pkg/cli/server/server.go
View file @
8c197bdc
...
@@ -217,7 +217,11 @@ func run(app *cli.Context, cfg *cmds.Server, leaderControllers server.CustomCont
...
@@ -217,7 +217,11 @@ func run(app *cli.Context, cfg *cmds.Server, leaderControllers server.CustomCont
}
}
if
cmds
.
AgentConfig
.
FlannelIface
!=
""
&&
len
(
cmds
.
AgentConfig
.
NodeIP
)
==
0
{
if
cmds
.
AgentConfig
.
FlannelIface
!=
""
&&
len
(
cmds
.
AgentConfig
.
NodeIP
)
==
0
{
cmds
.
AgentConfig
.
NodeIP
.
Set
(
util
.
GetIPFromInterface
(
cmds
.
AgentConfig
.
FlannelIface
))
ip
,
err
:=
util
.
GetIPFromInterface
(
cmds
.
AgentConfig
.
FlannelIface
)
if
err
!=
nil
{
return
err
}
cmds
.
AgentConfig
.
NodeIP
.
Set
(
ip
)
}
}
if
serverConfig
.
ControlConfig
.
PrivateIP
==
""
&&
len
(
cmds
.
AgentConfig
.
NodeIP
)
!=
0
{
if
serverConfig
.
ControlConfig
.
PrivateIP
==
""
&&
len
(
cmds
.
AgentConfig
.
NodeIP
)
!=
0
{
...
...
pkg/util/net.go
View file @
8c197bdc
...
@@ -301,14 +301,13 @@ func IPStringToIPNet(address string) (*net.IPNet, error) {
...
@@ -301,14 +301,13 @@ func IPStringToIPNet(address string) (*net.IPNet, error) {
}
}
// GetIPFromInterface is the public function that returns the IP of an interface
// GetIPFromInterface is the public function that returns the IP of an interface
func
GetIPFromInterface
(
ifaceName
string
)
string
{
func
GetIPFromInterface
(
ifaceName
string
)
(
string
,
error
)
{
ip
,
err
:=
getIPFromInterface
(
ifaceName
)
ip
,
err
:=
getIPFromInterface
(
ifaceName
)
if
err
!=
nil
{
if
err
!=
nil
{
logrus
.
Warn
(
fmt
.
Errorf
(
"unable to get global unicast ip from interface name: %w"
,
err
))
return
""
,
fmt
.
Errorf
(
"interface %s does not have a correct global unicast ip: %w"
,
ifaceName
,
err
)
}
else
{
logrus
.
Infof
(
"Found ip %s from iface %s"
,
ip
,
ifaceName
)
}
}
return
ip
logrus
.
Infof
(
"Found ip %s from iface %s"
,
ip
,
ifaceName
)
return
ip
,
nil
}
}
// getIPFromInterface is the private function that returns de IP of an interface
// getIPFromInterface is the private function that returns de IP of an interface
...
...
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