abligh / gonbdserver Goto Github PK
View Code? Open in Web Editor NEWAnd NBD server written in golang
License: MIT License
And NBD server written in golang
License: MIT License
I am getting a panic on the golang test cases.
The output when running go test -v ./... is as follows:
? _/tmp/gonbdserver [no test files]
--- FAIL: TestConnection (0.00s)
panic: template: config:21: illegal number syntax: "-" [recovered]
panic: template: config:21: illegal number syntax: "-"
goroutine 6 [running]:
testing.tRunner.func1(0xc82009e120)
/usr/lib/go/src/testing/testing.go:450 +0x171
text/template.Must(0x0, 0x7f475bdae028, 0xc82000b520, 0x0)
/usr/lib/go/src/text/template/helper.go:23 +0x4b
_/tmp/gonbdserver/nbd.StartNbd(0xc82009e120, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
/tmp/gonbdserver/nbd/nbd_test.go:101 +0xd97
_/tmp/gonbdserver/nbd.doTestConnection(0xc82009e120, 0xc80e7d4400)
/tmp/gonbdserver/nbd/nbd_test.go:443 +0x7e
_/tmp/gonbdserver/nbd.TestConnection(0xc82009e120)
/tmp/gonbdserver/nbd/nbd_test.go:459 +0x26
testing.tRunner(0xc82009e120, 0xe6c460)
/usr/lib/go/src/testing/testing.go:456 +0x98
created by testing.RunTests
/usr/lib/go/src/testing/testing.go:561 +0x86d
goroutine 1 [chan receive]:
testing.RunTests(0x8bf418, 0xe6c460, 0xa, 0xa, 0x1)
/usr/lib/go/src/testing/testing.go:562 +0x8ad
testing.(*M).Run(0xc82009dee8, 0x7f475bdb2298)
/usr/lib/go/src/testing/testing.go:494 +0x70
main.main()
_/tmp/gonbdserver/nbd/_test/_testmain.go:72 +0x116
goroutine 17 [syscall, locked to thread]:
runtime.goexit()
/usr/lib/go/src/runtime/asm_amd64.s:1696 +0x1
goroutine 5 [syscall]:
os/signal.loop()
/usr/lib/go/src/os/signal/signal_unix.go:22 +0x18
created by os/signal.init.1
/usr/lib/go/src/os/signal/signal_unix.go:28 +0x37
FAIL _/tmp/gonbdserver/nbd 0.046s
-------- END OF OUTPUT -------
I am running on a fully updated ubuntu 15.10 box with golang version 1.5.1
I can see this project was written a while ago, I wonder if the go garbage collector matured enough since then that this code is no longer necessary.
I wonder what the authors opinions on that are.
Using nbd-client version 3.7 from ubuntu 14.04.1, connecting to gonbdserver, the created nbd device is read-only. blockdev --getro returns 1.
Using blockdev --setrw will cause it --getro to return 0, but writes will fail and dmesg will show "block nbd0: Write on read-only".
Using the nbd-server package to serve the device gives a writable device. Uncommenting the Dispatch debug line shows only NBD_CMD_READs being dispatched until the final NBD_CMD_DISC.
My impression is that something during the initial setup is signaling that it's a read only device somehow.
Any ideas on what I can try to debug this? gonbdserver.conf is:
servers:
- protocol: tcp
address: 127.0.0.1:6666
exports:
- name: foo
driver: file
path: /tmp/test
workers: 2
logging:
Connecting using: nbd-client -N foo 127.0.0.1 6666 /dev/nbd0
I wasn't sure what this was about, immediately. There's no way I'm the only person who found this who didn't know what NBD meant right away.
more of a suggestion than an issue, I guess.
On a default linux system, without the ceph developer packages installed, the build currently fails:
github.com/ceph/go-ceph/rados/conn.go:5:29: fatal error: rados/librados.h: No such file or directory
// #include <rados/librados.h>
Wouldn't it be better to reverse the build directive in rbd.go from // +build linux,!noceph
to // +build linux,ceph
so one can choose to explicitly enable the RbdBackend instead?
This is especially annoying if you want to import the nbd code in an external project where this blocks a normal go get
installation.
In nbd/config.go
there are 3 handwritten functions defined (isTrue, isFalse and isTrueFalse) that all seem to serve the purpose as what strconv.ParseBool. Could it be possible to remove the custom code (and thus avoid having to maintain that), and replace it with the standard Golang (and idiomatic) approach?
Where isFalse is used you would have to simply negate the bool result in a non-error case (!result
). Where isTrueFalse you would use in a non-error case the result
bool param directly where now the first result param is used, and you would use the negated version (!result
) of that bool param where you now use the second result param is used.
Or is there a special reason that I'm missing that would explain why you would write custom code for this?
https://github.com/abligh/gonbdserver/blob/master/nbd/connection.go#L485 :
case NBD_CMD_FLUSH:
c.backend.Flush(ctx)
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.