genuinetools / netns Goto Github PK
View Code? Open in Web Editor NEWRunc hook (OCI compatible) for setting up default bridge networking for containers.
License: MIT License
Runc hook (OCI compatible) for setting up default bridge networking for containers.
License: MIT License
Hi Jess,
The .ip file doesn't appear to get populated by runc. I'm trying to reboot my project from a year ago, and this was the stumbling block I hit back then. I need the IP of the container in order to proxy traffic to it.
https://github.com/alexellis/faas-containerd
It seems like a restart hook should return an IP to containerd/runc? If not then to the .ip file, but nothing is logged out and nothing is created on the filesystem with a .ip
file. I've also tried hacking the file so that it writes to the default data directory.
Let me know if you have any ideas. @AkihiroSuda also had a look with me
Alex
netns appears to crash on an armv5 board when run on the command line or as a runc prehook with the following error (hostname and path replaced in the error):
root@<host>:~# netns ls
panic: runtime error: index out of range
goroutine 1 [running]:
go.etcd.io/bbolt.(*DB).page(...)
<path>/build/tmp/work/armv5ehf-vfp-oe-linux-gnueabi/netns/0.5.3-r0/git/src/import/vendor/pkg/mod/go.etcd.io/[email protected]/db.go:793
go.etcd.io/bbolt.(*Tx).page(...)
<path>/build/tmp/work/armv5ehf-vfp-oe-linux-gnueabi/netns/0.5.3-r0/git/src/import/vendor/pkg/mod/go.etcd.io/[email protected]/tx.go:576
go.etcd.io/bbolt.(*Bucket).pageNode(0x80a940, 0x726f7400, 0x0, 0xb, 0xb)
<path>/build/tmp/work/armv5ehf-vfp-oe-linux-gnueabi/netns/0.5.3-r0/git/src/import/vendor/pkg/mod/go.etcd.io/[email protected]/bucket.go:697 +0x1a8
go.etcd.io/bbolt.(*Cursor).First(0x85cd5c, 0x0, 0x0, 0x4b40dc, 0x0, 0x862100, 0x0)
<path>/build/tmp/work/armv5ehf-vfp-oe-linux-gnueabi/netns/0.5.3-r0/git/src/import/vendor/pkg/mod/go.etcd.io/[email protected]/cursor.go:34 +0x58
go.etcd.io/bbolt.(*Bucket).ForEach(0x80a940, 0x85cd90, 0xb, 0xb)
<path>/build/tmp/work/armv5ehf-vfp-oe-linux-gnueabi/netns/0.5.3-r0/git/src/import/vendor/pkg/mod/go.etcd.io/[email protected]/bucket.go:360 +0x8c
github.com/genuinetools/netns/network.(*Client).List.func1(0x862100, 0x2b65b0, 0x862100)
<path>/build/tmp/work/armv5ehf-vfp-oe-linux-gnueabi/netns/0.5.3-r0/git/src/import/network/list.go:42 +0xb8
go.etcd.io/bbolt.(*DB).View(0x868120, 0x85ce10, 0x0, 0x0)
<path>/build/tmp/work/armv5ehf-vfp-oe-linux-gnueabi/netns/0.5.3-r0/git/src/import/vendor/pkg/mod/go.etcd.io/[email protected]/db.go:626 +0x84
github.com/genuinetools/netns/network.(*Client).List(0x83a2c0, 0x0, 0x0, 0x0, 0x0, 0x0)
<path>/build/tmp/work/armv5ehf-vfp-oe-linux-gnueabi/netns/0.5.3-r0/git/src/import/network/list.go:38 +0x1f4
main.(*listCommand).Run(0x4b40dc, 0x302470, 0x80a880, 0x80c040, 0x0, 0x0, 0x0, 0x6)
<path>/build/tmp/work/armv5ehf-vfp-oe-linux-gnueabi/netns/0.5.3-r0/git/src/import/list.go:24 +0x24
github.com/genuinetools/pkg/cli.(*Program).run(0x83a280, 0x302470, 0x80a880, 0x80c040, 0x2, 0x2, 0x11e01, 0x80e3e8)
<path>/build/tmp/work/armv5ehf-vfp-oe-linux-gnueabi/netns/0.5.3-r0/git/src/import/vendor/pkg/mod/github.com/genuinetools/[email protected]/cli/cli.go:212 +0x39c
github.com/genuinetools/pkg/cli.(*Program).Run(0x83a280)
<path>/build/tmp/work/armv5ehf-vfp-oe-linux-gnueabi/netns/0.5.3-r0/git/src/import/vendor/pkg/mod/github.com/genuinetools/[email protected]/cli/cli.go:89 +0x4c
main.main()
<path>/build/tmp/work/armv5ehf-vfp-oe-linux-gnueabi/netns/0.5.3-r0/git/src/import/main.go:103 +0x574
this appears to be the section causing the error but it is unclear why:
func (db *DB) page(id pgid) *page {
pos := id * pgid(db.pageSize)
return (*page)(unsafe.Pointer(&db.data[pos]))
}```
Removing a bridge does not reset all the other configuration - routes etc.
Hi, I am facing an issue when running netns from v0.5.2 and from master (de81619). I get the following error when running sudo netns ls
after what looks like a successful "create":
opening database at /run/github.com/genuinetools/netns/bolt.db failed: write /run/github.com/genuinetools/netns/bolt.db: bad file descriptor
bolt.db
exists on the filesystem.
I am trying to use netns to provide network access to a container run through runC. After configuring the prestart hook, nothing seems to happen. No errors are reported, and no network bridge seems to be created.
Below is an example of the build, test, and an attempt at creating a bridge network off of the current master branch (de81619).
allana@guixsd /media/allana/persistent/github.com/netns [env]$ make clean
+ clean
rm -f netns
rm -f -r /media/allana/persistent/github.com/netns/cross
allana@guixsd /media/allana/persistent/github.com/netns [env]$ make static
+ static
CGO_ENABLED=0 go build \
-tags " static_build" \
-ldflags "-w -X github.com/genuinetools/netns/version.GITCOMMIT=de81619 -X github.com/genuinetools/netns/version.VERSION=v0.5.2 -extldflags -static" -o netns .
allana@guixsd /media/allana/persistent/github.com/netns [env]$ make test
+ test
? github.com/genuinetools/netns [no test files]
=== RUN TestInitBridgeIPAddrEmpty
--- PASS: TestInitBridgeIPAddrEmpty (0.00s)
=== RUN TestInitBridgeNameEmpty
--- PASS: TestInitBridgeNameEmpty (0.00s)
=== RUN TestInitBridgeDefaults
--- PASS: TestInitBridgeDefaults (0.21s)
=== RUN TestInitBridgeExists
--- PASS: TestInitBridgeExists (0.07s)
PASS
ok github.com/genuinetools/netns/bridge (cached)
? github.com/genuinetools/netns/netutils [no test files]
=== RUN TestCreateNetwork
--- PASS: TestCreateNetwork (0.41s)
=== RUN TestNewNetworkBridgeNameEmpty
--- PASS: TestNewNetworkBridgeNameEmpty (0.00s)
=== RUN TestNewNetworkStateDirPathEmpty
--- PASS: TestNewNetworkStateDirPathEmpty (0.00s)
=== RUN TestNewNetworkDefaults
--- PASS: TestNewNetworkDefaults (0.00s)
PASS
ok github.com/genuinetools/netns/network 0.417s
? github.com/genuinetools/netns/version [no test files]
allana@guixsd /media/allana/persistent/github.com/netns [env]$ sudo netns create
created bridge: &net.Interface{Index:11, MTU:1500, Name:"netns0", HardwareAddr:net.HardwareAddr{0x6, 0x70, 0x88, 0xe, 0xc3, 0x68}, Flags:0x13}
allana@guixsd /media/allana/persistent/github.com/netns [env]$ sudo netns ls
opening database at /run/github.com/genuinetools/netns/bolt.db failed: write /run/github.com/genuinetools/netns/bolt.db: bad file descriptor
Can this be a bug or is this solely user error on my part?
I am trying to set up bridge networking in a rootless runc container.
I set netns as hook in my runc config:
"hooks": {
"prestart" : [
{
"path" : "/path/to/netns",
"args" : [
"netns",
"--state-dir", "/path/to/netns-state"
]
}
]
}
I have not called any netns command before. What I would expect is that this sets up some default bridge.
This gives me a permission denied:
container_linux.go:348: starting container process caused "process_linux.go:402: container init caused \"process_linux.go:385: running prestart hook 0 caused \\\"error running hook: exit status 1, stdout: , stderr: opening database at /path/to/netns-state/bolt.db failed: open /path/to/netns-state/bolt.db: permission denied\\\\n\\\"\""
If I remove the --state-dir, I get the same issue with the default path.
How do I use this properly? Am I doing it wrong? Should I be calling something before, or create the bolt.db file? If yes, can you please add more information to the README?
Hello,
I want to set static ips, is there any way to do this?
Thanks!
Ivan
Creating a bridge with names "brmaths_overlay", "br_mathsoverlay" works, but not "br_maths_overlay". Trying to create this bridge shows an error
bridge creation for br_maths_overlay failed: numerical result out of range
I am calling netns like this:
netns --ip 192.168.124.1/24 --static-ip 192.168.124.123 --bridge br_mathsoverlay
This results in an error
adding route 192.168.123.1 to interface ethc26318 failed: network is unreachable
Removing the static ip removes the error.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.