nbd-client fails to connect Error: Socket failed: Connection refused

Bug #2060745 reported by Thiago Martins
12
This bug affects 1 person
Affects Status Importance Assigned to Milestone
nbd
New
Unknown
nbd (Ubuntu)
Fix Released
High
Mitchell Dzurick
Noble
Fix Committed
High
Mitchell Dzurick

Bug Description

[ Impact ]

nbdtab uses a port of 0 by default which is not sensible. This means that if you do not set a default port in nbdtab, it will fail.

You will see an error such as: Error: Socket failed: Connection refused

[ Test Plan ]

$ lxc launch ubuntu:noble n-vm --vm
$ lxc shell n-vm
# apt update -y && apt install -y nbd-client nbd-server
# dpkg -s nbd-client | grep Version:
Version: 1:3.26.1-1build1
# modprobe nbd
# truncate -s 1T /vol-0.img
# cat > /etc/nbd-server/conf.d/exports.conf << _EOF_
[vol0]
exportname = /vol-0.img
_EOF_
# systemctl restart nbd-server.service

Verify that NBD is working properly:

# nbd-client localhost /dev/nbd0 -name vol0

It should work.

To clean it up:

# nbd-client -d /dev/nbd0

Now, trigger the problem:

# cat >> /etc/nbdtab << _EOF_
nbd0 localhost vol0
_EOF_
# nbd-client nbd0

You should see the error:

# nbd-client nbd0
Error: Socket failed: Connection refused

Test the fix:
# add-apt-repository -y ppa:mitchdz/lp2060745-nbd-port-fix
# apt update -y && apt upgrade -y
# dpkg -s nbd-client | grep Version:
Version: 1:3.26.1-1ubuntu0.1~noble1
# nbd-client -d /dev/nbd0
< no errors here>

[ Where problems could occur ]
* This changes the default port, so issues using custom ports could arise. This seems unlikely since it is a one line change that should get overridden.

Related branches

Revision history for this message
Thiago Martins (martinx) wrote :
Revision history for this message
Athos Ribeiro (athos-ribeiro) wrote :
Changed in nbd (Ubuntu):
status: New → Triaged
tags: added: server-todo
Changed in nbd:
status: Unknown → New
Bryce Harrington (bryce)
Changed in nbd (Ubuntu):
assignee: nobody → Mitchell Dzurick (mitchdz)
description: updated
summary: - nbd-client fails to connect when using /etc/nbdtab on Ubuntu 24.04
- (Noble)
+ nbd-client fails to connect Error: Socket failed: Connection refused
description: updated
Changed in nbd (Ubuntu Noble):
status: Triaged → In Progress
importance: Undecided → High
Revision history for this message
Andreas Hasenack (ahasenack) wrote :

a) Please upload this fix to Oracular as well.

b) Interesting, this was failing in noble already before the release, i.e., the existing DEP8 test covered this scenario already: https://autopkgtest.ubuntu.com/packages/nbd/noble/amd64

Changed in nbd (Ubuntu Noble):
status: In Progress → Fix Committed
tags: added: verification-needed verification-needed-noble
Revision history for this message
Andreas Hasenack (ahasenack) wrote : Please test proposed package

Hello Thiago, or anyone else affected,

Accepted nbd into noble-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/nbd/1:3.26.1-1ubuntu0.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-noble to verification-done-noble. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-noble. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Revision history for this message
Mitchell Dzurick (mitchdz) wrote :

Thanks Andreas!

Regarding comment #3

a) debian version has this fix, and quite a few updates to the debian/* directory, so I think we might as well do an early oracular merge to get that fix in.

B) I'm curious why the excuses page didn't pick up those autopkgtests during the sync?

Revision history for this message
Mitchell Dzurick (mitchdz) wrote :

I didn't see a bug to track the Oracular merge, so I made it here https://bugs.launchpad.net/ubuntu/+source/nbd/+bug/2064688

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

Uploaded to oracular:
Uploading nbd_3.26.1-1ubuntu1.dsc
Uploading nbd_3.26.1-1ubuntu1.debian.tar.xz
Uploading nbd_3.26.1-1ubuntu1_source.buildinfo
Uploading nbd_3.26.1-1ubuntu1_source.changes

Changed in nbd (Ubuntu):
status: In Progress → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package nbd - 1:3.26.1-1ubuntu1

---------------
nbd (1:3.26.1-1ubuntu1) oracular; urgency=medium

  * d/p/0002-Set-sensible-default-for-port.patch: When no port is specified
    in nbdtab, set default to NBD_DEFAULT_PORT (i.e. "10809") to fix issue
    where "0" is assumed.
    (LP: #2060745)

 -- Mitchell Dzurick <email address hidden> Fri, 03 May 2024 23:27:15 -0700

Changed in nbd (Ubuntu):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.