Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Hepto
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
reminec
Hepto
Commits
96c26afb
Commit
96c26afb
authored
2 years ago
by
kaiyou
Browse files
Options
Downloads
Patches
Plain Diff
Add some useful logging
parent
3bc8f9f7
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
cmd/hepto/config.go
+5
-1
5 additions, 1 deletion
cmd/hepto/config.go
cmd/hepto/root.go
+1
-1
1 addition, 1 deletion
cmd/hepto/root.go
pkg/selfcontain/net.go
+11
-12
11 additions, 12 deletions
pkg/selfcontain/net.go
with
17 additions
and
14 deletions
cmd/hepto/config.go
+
5
−
1
View file @
96c26afb
...
...
@@ -50,6 +50,10 @@ func (c *Config) Complete() error {
for
_
,
mount
:=
range
cluster
.
RequiredMounts
(
&
c
.
Cluster
,
&
c
.
Node
)
{
c
.
Container
.
Mounts
[
mount
]
=
path
.
Join
(
c
.
Container
.
Data
,
mount
)
}
// Set the container IP mask if required
if
len
(
c
.
Container
.
IP
.
Mask
)
==
0
{
c
.
Container
.
IP
.
Mask
=
c
.
Container
.
IP
.
IP
.
DefaultMask
()
}
// Additional container settings
c
.
Container
.
Name
=
c
.
Node
.
Name
c
.
Container
.
Capabilities
=
additionalCapabilities
...
...
@@ -71,7 +75,7 @@ func init() {
// Container settings
Hepto
.
Flags
()
.
StringVar
(
&
config
.
Container
.
Master
,
"iface"
,
"eth0"
,
"Master network interface"
)
Hepto
.
Flags
()
.
IP
Net
Var
(
&
config
.
Container
.
IP
,
"ip"
,
net
.
IP
Net
{},
"IP address for the public interface"
)
Hepto
.
Flags
()
.
IPVar
(
&
config
.
Container
.
IP
.
IP
,
"ip"
,
net
.
IP
{},
"IP address for the public interface"
)
Hepto
.
Flags
()
.
IPVar
(
&
config
.
Container
.
GW
,
"gw"
,
net
.
IP
{},
"IP address of the network gateway"
)
Hepto
.
Flags
()
.
IPSliceVar
(
&
config
.
Container
.
DNS
,
"dns"
,
defaultDNS
,
"DNS server IP addresses"
)
Hepto
.
Flags
()
.
StringToStringVar
(
&
config
.
Container
.
Mounts
,
"bind"
,
map
[
string
]
string
{},
"Additional bind mounts"
)
...
...
This diff is collapsed.
Click to expand it.
cmd/hepto/root.go
+
1
−
1
View file @
96c26afb
...
...
@@ -47,7 +47,7 @@ func waitForIP() net.IP {
time
.
Sleep
(
time
.
Second
)
target
:=
fmt
.
Sprintf
(
"[%s]:53"
,
config
.
Container
.
DNS
[
0
]
.
String
())
config
.
Logger
.
Info
(
"connecting outbound to guess IP"
,
"target"
,
target
)
conn
,
err
:=
net
.
Dial
(
"udp"
,
fmt
.
Sprintf
(
"[%s]:53"
,
target
)
)
conn
,
err
:=
net
.
Dial
(
"udp"
,
target
)
if
err
!=
nil
{
config
.
Logger
.
Error
(
err
,
"could not connect"
)
continue
...
...
This diff is collapsed.
Click to expand it.
pkg/selfcontain/net.go
+
11
−
12
View file @
96c26afb
package
selfcontain
import
(
"errors"
"fmt"
"io/ioutil"
"net"
...
...
@@ -24,47 +23,47 @@ const ACCEPT_DFTRTR = "net.ipv6.conf.eth0.accept_ra_defrtr"
func
(
c
*
Container
)
SetupNetworking
(
etc
string
)
error
{
ifaceName
,
err
:=
c
.
setupIPVlan
(
c
.
config
.
Master
,
1500
)
if
err
!=
nil
{
return
err
return
fmt
.
Errorf
(
"could not create interface: %w"
,
err
)
}
netns
,
err
:=
c
.
findNetNS
()
if
err
!=
nil
{
return
err
return
fmt
.
Errorf
(
"unable to find netns: %w"
,
err
)
}
err
=
netns
.
Do
(
func
(
_
ns
.
NetNS
)
error
{
// Rename the interface
iface
,
err
:=
netlink
.
LinkByName
(
ifaceName
)
if
err
!=
nil
{
return
err
return
fmt
.
Errorf
(
"could not find interface: %w"
,
err
)
}
err
=
netlink
.
LinkSetName
(
iface
,
"eth0"
)
if
err
!=
nil
{
return
err
return
fmt
.
Errorf
(
"could not rename: %w"
,
err
)
}
err
=
netlink
.
LinkSetUp
(
iface
)
if
err
!=
nil
{
return
err
return
fmt
.
Errorf
(
"could not set the interface up: %w"
,
err
)
}
// Setup addresses and routes
err
=
setupAddress
(
iface
,
c
.
config
.
IP
)
if
err
!=
nil
{
return
err
return
fmt
.
Errorf
(
"could not set the address: %w"
,
err
)
}
err
=
setupGw
(
iface
,
c
.
config
.
GW
)
if
err
!=
nil
{
return
err
return
fmt
.
Errorf
(
"could not set the gateway: %w"
,
err
)
}
// Setup DNS
err
=
setupDNS
(
c
.
config
.
DNS
,
etc
)
if
err
!=
nil
{
return
err
return
fmt
.
Errorf
(
"could not set the DNS: %w"
,
err
)
}
err
=
setupHosts
(
etc
)
if
err
!=
nil
{
return
err
return
fmt
.
Errorf
(
"could not write hosts file: %w"
,
err
)
}
err
=
setupCerts
(
etc
)
if
err
!=
nil
{
return
err
return
fmt
.
Errorf
(
"could not set certificates: %w"
,
err
)
}
return
nil
})
...
...
@@ -203,5 +202,5 @@ func setupCerts(etc string) error {
}
return
nil
}
return
errors
.
New
(
"no certificate available"
)
return
fmt
.
Errorf
(
"no certificate available"
)
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment