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
b5dc2985
Unverified
Commit
b5dc2985
authored
Sep 25, 2023
by
Manuel Buil
Committed by
GitHub
Sep 25, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8421 from manuelbuil/flannelErrors125
[Release 1.25] Add context to flannel errors
parents
131f5c4e
51969e6e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
11 deletions
+12
-11
flannel.go
pkg/agent/flannel/flannel.go
+12
-11
No files found.
pkg/agent/flannel/flannel.go
View file @
b5dc2985
...
@@ -25,6 +25,7 @@ import (
...
@@ -25,6 +25,7 @@ import (
"github.com/flannel-io/flannel/pkg/ip"
"github.com/flannel-io/flannel/pkg/ip"
"github.com/flannel-io/flannel/pkg/iptables"
"github.com/flannel-io/flannel/pkg/iptables"
"github.com/flannel-io/flannel/pkg/subnet/kube"
"github.com/flannel-io/flannel/pkg/subnet/kube"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/sirupsen/logrus"
"golang.org/x/net/context"
"golang.org/x/net/context"
...
@@ -49,7 +50,7 @@ var (
...
@@ -49,7 +50,7 @@ var (
func
flannel
(
ctx
context
.
Context
,
flannelIface
*
net
.
Interface
,
flannelConf
,
kubeConfigFile
string
,
flannelIPv6Masq
bool
,
netMode
int
)
error
{
func
flannel
(
ctx
context
.
Context
,
flannelIface
*
net
.
Interface
,
flannelConf
,
kubeConfigFile
string
,
flannelIPv6Masq
bool
,
netMode
int
)
error
{
extIface
,
err
:=
LookupExtInterface
(
flannelIface
,
netMode
)
extIface
,
err
:=
LookupExtInterface
(
flannelIface
,
netMode
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
ors
.
Wrap
(
err
,
"failed to find the interface"
)
}
}
sm
,
err
:=
kube
.
NewSubnetManager
(
ctx
,
sm
,
err
:=
kube
.
NewSubnetManager
(
ctx
,
...
@@ -60,12 +61,12 @@ func flannel(ctx context.Context, flannelIface *net.Interface, flannelConf, kube
...
@@ -60,12 +61,12 @@ func flannel(ctx context.Context, flannelIface *net.Interface, flannelConf, kube
false
,
false
,
false
)
false
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
ors
.
Wrap
(
err
,
"failed to create the SubnetManager"
)
}
}
config
,
err
:=
sm
.
GetNetworkConfig
(
ctx
)
config
,
err
:=
sm
.
GetNetworkConfig
(
ctx
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
ors
.
Wrap
(
err
,
"failed to get the network config"
)
}
}
// Create a backend manager then use it to create the backend and register the network with it.
// Create a backend manager then use it to create the backend and register the network with it.
...
@@ -73,18 +74,18 @@ func flannel(ctx context.Context, flannelIface *net.Interface, flannelConf, kube
...
@@ -73,18 +74,18 @@ func flannel(ctx context.Context, flannelIface *net.Interface, flannelConf, kube
be
,
err
:=
bm
.
GetBackend
(
config
.
BackendType
)
be
,
err
:=
bm
.
GetBackend
(
config
.
BackendType
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
ors
.
Wrap
(
err
,
"failed to create the flannel backend"
)
}
}
bn
,
err
:=
be
.
RegisterNetwork
(
ctx
,
&
sync
.
WaitGroup
{},
config
)
bn
,
err
:=
be
.
RegisterNetwork
(
ctx
,
&
sync
.
WaitGroup
{},
config
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
ors
.
Wrap
(
err
,
"failed to register flannel network"
)
}
}
if
netMode
==
(
ipv4
+
ipv6
)
||
netMode
==
ipv4
{
if
netMode
==
(
ipv4
+
ipv6
)
||
netMode
==
ipv4
{
net
,
err
:=
config
.
GetFlannelNetwork
(
&
bn
.
Lease
()
.
Subnet
)
net
,
err
:=
config
.
GetFlannelNetwork
(
&
bn
.
Lease
()
.
Subnet
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
ors
.
Wrap
(
err
,
"failed to get flannel network details"
)
}
}
iptables
.
CreateIP4Chain
(
"nat"
,
"FLANNEL-POSTRTG"
)
iptables
.
CreateIP4Chain
(
"nat"
,
"FLANNEL-POSTRTG"
)
iptables
.
CreateIP4Chain
(
"filter"
,
"FLANNEL-FWD"
)
iptables
.
CreateIP4Chain
(
"filter"
,
"FLANNEL-FWD"
)
...
@@ -104,7 +105,7 @@ func flannel(ctx context.Context, flannelIface *net.Interface, flannelConf, kube
...
@@ -104,7 +105,7 @@ func flannel(ctx context.Context, flannelIface *net.Interface, flannelConf, kube
if
config
.
IPv6Network
.
String
()
!=
emptyIPv6Network
{
if
config
.
IPv6Network
.
String
()
!=
emptyIPv6Network
{
ip6net
,
err
:=
config
.
GetFlannelIPv6Network
(
&
bn
.
Lease
()
.
IPv6Subnet
)
ip6net
,
err
:=
config
.
GetFlannelIPv6Network
(
&
bn
.
Lease
()
.
IPv6Subnet
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
ors
.
Wrap
(
err
,
"failed to get ipv6 flannel network details"
)
}
}
if
flannelIPv6Masq
{
if
flannelIPv6Masq
{
logrus
.
Debugf
(
"Creating IPv6 masquerading iptables rules for %s network"
,
config
.
IPv6Network
.
String
())
logrus
.
Debugf
(
"Creating IPv6 masquerading iptables rules for %s network"
,
config
.
IPv6Network
.
String
())
...
@@ -146,11 +147,11 @@ func LookupExtInterface(iface *net.Interface, netMode int) (*backend.ExternalInt
...
@@ -146,11 +147,11 @@ func LookupExtInterface(iface *net.Interface, netMode int) (*backend.ExternalInt
logrus
.
Debug
(
"No interface defined for flannel in the config. Fetching the default gateway interface"
)
logrus
.
Debug
(
"No interface defined for flannel in the config. Fetching the default gateway interface"
)
if
netMode
==
ipv4
||
netMode
==
(
ipv4
+
ipv6
)
{
if
netMode
==
ipv4
||
netMode
==
(
ipv4
+
ipv6
)
{
if
iface
,
err
=
ip
.
GetDefaultGatewayInterface
();
err
!=
nil
{
if
iface
,
err
=
ip
.
GetDefaultGatewayInterface
();
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to get default interface: %s"
,
err
)
return
nil
,
errors
.
Wrap
(
err
,
"failed to get default interface"
)
}
}
}
else
{
}
else
{
if
iface
,
err
=
ip
.
GetDefaultV6GatewayInterface
();
err
!=
nil
{
if
iface
,
err
=
ip
.
GetDefaultV6GatewayInterface
();
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to get default interface: %s"
,
err
)
return
nil
,
errors
.
Wrap
(
err
,
"failed to get default interface"
)
}
}
}
}
}
}
...
@@ -160,14 +161,14 @@ func LookupExtInterface(iface *net.Interface, netMode int) (*backend.ExternalInt
...
@@ -160,14 +161,14 @@ func LookupExtInterface(iface *net.Interface, netMode int) (*backend.ExternalInt
case
ipv4
:
case
ipv4
:
ifaceAddr
,
err
=
ip
.
GetInterfaceIP4Addrs
(
iface
)
ifaceAddr
,
err
=
ip
.
GetInterfaceIP4Addrs
(
iface
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to find IPv4 address for interface %s"
,
iface
.
Name
)
return
nil
,
errors
.
Wrap
(
err
,
"failed to find IPv4 address for interface"
)
}
}
logrus
.
Infof
(
"The interface %s with ipv4 address %s will be used by flannel"
,
iface
.
Name
,
ifaceAddr
[
0
])
logrus
.
Infof
(
"The interface %s with ipv4 address %s will be used by flannel"
,
iface
.
Name
,
ifaceAddr
[
0
])
ifacev6Addr
=
append
(
ifacev6Addr
,
nil
)
ifacev6Addr
=
append
(
ifacev6Addr
,
nil
)
case
ipv6
:
case
ipv6
:
ifacev6Addr
,
err
=
ip
.
GetInterfaceIP6Addrs
(
iface
)
ifacev6Addr
,
err
=
ip
.
GetInterfaceIP6Addrs
(
iface
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to find IPv6 address for interface %s"
,
iface
.
Name
)
return
nil
,
errors
.
Wrap
(
err
,
"failed to find IPv6 address for interface"
)
}
}
logrus
.
Infof
(
"The interface %s with ipv6 address %s will be used by flannel"
,
iface
.
Name
,
ifacev6Addr
[
0
])
logrus
.
Infof
(
"The interface %s with ipv6 address %s will be used by flannel"
,
iface
.
Name
,
ifacev6Addr
[
0
])
ifaceAddr
=
append
(
ifaceAddr
,
nil
)
ifaceAddr
=
append
(
ifaceAddr
,
nil
)
...
...
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