Merge ~ahasenack/ubuntu/+source/samba:jammy-ctdb-nfs-mvp-fixes into ubuntu/+source/samba:ubuntu/devel

Proposed by Andreas Hasenack
Status: Merged
Merged at revision: b7f95dfc7e76d7946589abe99860206092326867
Proposed branch: ~ahasenack/ubuntu/+source/samba:jammy-ctdb-nfs-mvp-fixes
Merge into: ubuntu/+source/samba:ubuntu/devel
Diff against target: 356 lines (+104/-78)
7 files modified
debian/changelog (+18/-0)
debian/ctdb.example.enable.nfs.sh (+22/-32)
debian/ctdb.example.nfs.conf (+20/-0)
debian/ctdb.example.quota (+5/-0)
debian/patches/fix-nfs-service-name-to-nfs-kernel-server.patch (+37/-28)
debian/rules (+2/-2)
dev/null (+0/-16)
Reviewer Review Type Date Requested Status
Miriam España Acebal (community) Approve
Canonical Server Core Reviewers Pending
Review via email: mp+417186@code.launchpad.net

Description of the change

Small, if not minimal, set of changes to make ctdb compatible with the new nfs-utils NFS server/client in jammy. Without these, it still somewhat works, but there are corner cases due to the debian packaging not removing the now obsolete /etc/default/nfs-* config files.

Some remarks:

# quota rpc service
The debian/ubuntu/ quota rpc (rpc.rquotad) service has a quirk that it will scan /etc/fstab and only start if it detects relevant quota mount options. When no such options exist, the service will stop with exit 0. ctdb eventually detects that rpc.rquotad isn't running, and tries to start it again, and this loops forever.
I contacted upstream[1] for a way to signal the scripts that quota isn't mandatory, and there is a series of commits[2] to address that, but too fresh for jammy I think, and somewhat of a feature change. I then went with the workaround that Rafael had used already, which is to not define nfs_rquotad_service, in which case ctdb will try to handle it manually and not via the service command.
For users who know they will really not need rpc.rquotad running, they can then just remove the /etc/ctdb/nfs-checks.d/50.rquotad.check file, and ctdb won't check (nor restart) this quota service anymore.

# the nfs_*_service variables in the nfs-linux-kernel-callout script
The content of those variables, if defined, will be used as the service name in the service command, like "service $nfs_rquotad_service start".
Some nfs services, however, start other services. NFS is that complicated, yes. So if a service variable is not defined, it doesn't really mean it won't be started. They can still be started by the checks, individually. That's what happened with the rpc.rquotad service described above.
The previous version of the fix-nfs-service-name-to-nfs-kernel-server was undefining basically all service variables, and then having the script rely on its own parsing of /etc/default/nfs-* scripts to find out which command line options it should use, and start the services manually. I chose to define the variables instead, so normal systemd units would be used, and no command-line option figuring out is needed, because the daemons all read from /etc/nfs.conf{,.d/*}. The exception being rpc.rquotad, as explained above, but it uses its own config in /etc/default/quota, so not really affected by the nfs-utils config file change.

# nfsconf changes
The meat of this MP. I tried the less invasive alternative for this. I changed Rafael's patch, isntead of creating a new one on top of it with the nfsconf changes. The patch name isn't that great anymore, but I thought renaming the patch would be worse for a review. If you prefer, I can add a patch on top of the original one that just changes the service name.

# ctdb "service" name
There is a mistake in the original patch where it was renaming "nfs" to "nfs-common" or "nfs-kernel-server", but in some cases that was incorrect. The "nfs" key was used for a directory in /var/lib//var/lib/ctdb/scripts/service/<key>, and as a result the previous package, and this one (because I didn't change it) have:

/var/lib/ctdb/scripts/service/nfs
/var/lib/ctdb/scripts/service/nfs-kernel-server

Fixing that now would mean moving state files from nfs-kernel-server into nfs in a maintainer script, and that's too big a change for this MVP branch. As far as I can tell, things are working as they are, fortunately or unfortunately.

# the enable-nfs.sh
This is a script written by Rafael back when he first tackled ctdb in ubuntu and made it work. It came as a result of his work in bug #722201[3] and this discourse post[4]. I changed it for the new nfs-utils version we have, but didn't make other big improvements to the script. Keep in mind it's an example script. It complements and implements parts of the upstream documentation[5].

PPA: https://launchpad.net/~ahasenack/+archive/ubuntu/samba-ctdb-nfs-mvp-fixes/+packages

If you want to test this on your own, get in touch. That discourse post is a start, but there are many details.

1. https://lists.samba.org/archive/samba-technical/2022-March/137176.html
2. https://git.samba.org/?p=martins/samba.git;a=shortlog;h=refs/heads/ctdb-nfs
3. https://bugs.launchpad.net/debian/+source/ctdb/+bug/722201
4. https://discourse.ubuntu.com/t/ctdb-create-a-3-node-nfs-ha-backed-by-a-clustered-filesystem/11608
5. https://wiki.samba.org/index.php/Setting_up_CTDB_for_Clustered_NFS

To post a comment you must log in.
Revision history for this message
Miriam España Acebal (mirespace) wrote :

Hi Andreas,

intense merge proposal! As spoken, I did a review of the code without testing itself, checking for typos or missed things and trying to understand the a bit the logic.

I don't find any strange. At the beginning, the changes around nfs-kernel-server files confuse me a bit because I was seeing service and conf didn't match or removed but after reading carefully your "# ctdb "service" name" I totally agree that is out of the scope of this MP.

Also, I checked that the new files are shipped in the *.deb from your PPA (I've checked what I might have forgotten).

Thanks for this MP.

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

Thanks a lot Miriam!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/debian/changelog b/debian/changelog
index 7f8f905..88d399e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,21 @@
1samba (2:4.15.5~dfsg-0ubuntu3) jammy; urgency=medium
2
3 * Update nfs scripts for new nfs.conf config (LP: #1961840):
4 - d/p/fix-nfs-service-name-to-nfs-kernel-server.patch: updated to use
5 nfsconf(8) if it's available, instead of parsing the old config
6 files in /etc/default/nfs-*
7 - d/ctdb.example.nfs.conf: /etc/nfs.conf to be used by the example
8 enable-nfs.sh example script
9 - d/ctdb.example.quota: quota config file to be used by the example
10 enable-nfs.sh script
11 - d/ctdb.example.nfs-{common,kernel-server}: obsolete, replaced by
12 nfs.conf
13 - d/ctdb.example.enable.nfs.sh: handle new nfs.conf and other
14 changes in the new nfs server packages
15 - d/rules: install the new/changed ctdb example nfs files
16
17 -- Andreas Hasenack <andreas@canonical.com> Mon, 21 Mar 2022 11:55:54 -0300
18
1samba (2:4.15.5~dfsg-0ubuntu2) jammy; urgency=medium19samba (2:4.15.5~dfsg-0ubuntu2) jammy; urgency=medium
220
3 * d/p/lp-1951490-fix-printing-KB5006743.patch: Fix printing after21 * d/p/lp-1951490-fix-printing-KB5006743.patch: Fix printing after
diff --git a/debian/ctdb.example.enable.nfs.sh b/debian/ctdb.example.enable.nfs.sh
index 2a99074..f719e63 100755
--- a/debian/ctdb.example.enable.nfs.sh
+++ b/debian/ctdb.example.enable.nfs.sh
@@ -19,6 +19,14 @@ backupfile() {
19 [ -f $1 ] && cp $1 $1.prvctdb || true19 [ -f $1 ] && cp $1 $1.prvctdb || true
20}20}
2121
22renamefiles() {
23 for f; do
24 [ -f "$f" ] || continue
25 echo "Renaming $f to $f.prvctdb"
26 mv "$f" "$f".prvctdb
27 done
28}
29
22checkservice() {30checkservice() {
23 (systemctl list-unit-files | grep -q $1.service) || die "service $1 not found"31 (systemctl list-unit-files | grep -q $1.service) || die "service $1 not found"
24}32}
@@ -46,20 +54,6 @@ appendfile() {
46 cat $base/$origfile >> $replfile54 cat $base/$origfile >> $replfile
47}55}
4856
49appendnfsenv() {
50
51 file=$1 ; [ -f $file ] || die "inexistent file $file";
52
53 echo appending NFS_HOSTNAME to $file...
54
55 grep -q "NFS_HOSTNAME" $file || \
56 {
57 echo
58 echo "echo NFS_HOSTNAME=\\\"\$NFS_HOSTNAME\\\"" \>\> \/run\/sysconfig\/nfs-utils
59 echo
60 } >> $file
61}
62
63execnfsenv() {57execnfsenv() {
6458
65 file=$1 ; [ -f $file ] || due "inexistent file $file";59 file=$1 ; [ -f $file ] || due "inexistent file $file";
@@ -71,7 +65,7 @@ execnfsenv() {
7165
72fixnfshostname() {66fixnfshostname() {
7367
74 file=$1 ; [ -f $file ] || due "inexistent file $file";68 type nfsconf > /dev/null 2>&1 || die "nfsconf(8) not found"
7569
76 if [ "$ghostname" == "" ]; then70 if [ "$ghostname" == "" ]; then
77 echo "What is the FQDN for the public IP address of this host ?"71 echo "What is the FQDN for the public IP address of this host ?"
@@ -79,8 +73,8 @@ fixnfshostname() {
79 read ghostname73 read ghostname
80 fi74 fi
8175
82 echo placing hostname $ghostname into $file...76 echo "Setting $ghostname in nfs.conf..."
83 sed -i "s:PLACE_HOSTNAME_HERE:$ghostname:g" $file77 nfsconf --set statd name "$ghostname"
84}78}
8579
86# end of functions --80# end of functions --
@@ -90,13 +84,14 @@ fixnfshostname() {
90echo """84echo """
91This script will enable CTDB NFS HA by changing the following files:85This script will enable CTDB NFS HA by changing the following files:
9286
93(1) /etc/default/nfs-common ( replace )87(1) /etc/nfs.conf ( replace )
94(2) /etc/default/nfs-kernel-server ( replace )88(2) /etc/nfs.conf.d/*.conf ( rename )
95(3) /etc/services ( append )89(3) /etc/services ( append )
96(4) /etc/sysctl.d/99-nfs-static-ports.conf ( create )90(4) /etc/sysctl.d/99-nfs-static-ports.conf ( create )
97(5) /usr/lib/systemd/scripts/nfs-utils_env.sh ( modify )91(5) /etc/default/quota ( replace )
9892
99and disabling the following services:93and disabling the following services, as they will be managed
94by ctdb:
10095
101(1) rpcbind96(1) rpcbind
102(2) nfs-kernel-server97(2) nfs-kernel-server
@@ -124,10 +119,10 @@ checkservice rpcbind
124echo "requirements okay!"119echo "requirements okay!"
125echo120echo
126121
127backupfile /etc/default/nfs-common122backupfile /etc/nfs.conf
128backupfile /etc/default/nfs-kernel-server123renamefiles /etc/nfs.conf.d/*.conf
129backupfile /etc/services124backupfile /etc/services
130backupfile /usr/lib/systemd/scripts/nfs-utils_env.sh125backupfile /etc/default/quota
131echo126echo
132127
133set +e128set +e
@@ -150,20 +145,15 @@ echo
150145
151set -e146set -e
152147
153replacefile nfs-common /etc/default/nfs-common148replacefile nfs.conf /etc/nfs.conf
154replacefile nfs-kernel-server /etc/default/nfs-kernel-server
155replacefile 99-nfs-static-ports.conf /etc/sysctl.d/99-nfs-static-ports.conf149replacefile 99-nfs-static-ports.conf /etc/sysctl.d/99-nfs-static-ports.conf
150replacefile quota /etc/default/quota
156echo151echo
157152
158appendfile services /etc/services153appendfile services /etc/services
159echo154echo
160155
161fixnfshostname /etc/default/nfs-common156fixnfshostname
162fixnfshostname /etc/default/nfs-kernel-server
163echo
164
165appendnfsenv /usr/lib/systemd/scripts/nfs-utils_env.sh
166execnfsenv /usr/lib/systemd/scripts/nfs-utils_env.sh
167echo157echo
168158
169sysctlrefresh159sysctlrefresh
diff --git a/debian/ctdb.example.nfs-common b/debian/ctdb.example.nfs-common
170deleted file mode 100644160deleted file mode 100644
index 9d4f22c..0000000
--- a/debian/ctdb.example.nfs-common
+++ /dev/null
@@ -1,19 +0,0 @@
1# CTDB: /etc/default/nfs-common for clustering
2
3NFS_HOSTNAME="PLACE_HOSTNAME_HERE"
4
5# rpc.statd - daemon listening for reboot notifications (locks related)
6NEED_STATD="yes"
7STATDOPTS="-n ${NFS_HOSTNAME} -p 32765 -o 32766 -H /etc/ctdb/statd-callout -T 32768 -U 32768"
8STATD_HOSTNAME="$NFS_HOSTNAME"
9
10# rpc.gssd - security context for rpc connections
11NEED_GSSD="no"
12
13# rpc.idmapd - NFSv4 <-> name mapping daemon (fallback nowadays)
14# recent kernels use nfsidmap(8) instead
15NEED_IDMAPD="no"
16
17# rpc.quota - usage quota
18RPCRQUOTADOPTS="-p 32769"
19
diff --git a/debian/ctdb.example.nfs-kernel-server b/debian/ctdb.example.nfs-kernel-server
20deleted file mode 1006440deleted file mode 100644
index 6aa5df9..0000000
--- a/debian/ctdb.example.nfs-kernel-server
+++ /dev/null
@@ -1,16 +0,0 @@
1# CTDB: /etc/default/nfs-kernel-server for clustering
2
3NFS_HOSTNAME="PLACE_HOSTNAME_HERE"
4
5# rpc.nfsd - user level part of nfs service (kernel: nfsd module)
6RPCNFSDPRIORITY=0
7RPCNFSDCOUNT=8
8RPCNFSDOPTS="-N 4"
9
10# rpc.mountd - server side of nfs mount protocol
11RPCMOUNTDOPTS="-p 32767 --manage-gids --no-nfs-version 4"
12
13# rpc.svcgssd - userspace daemon to handle sec context for kernel rpcsec_gss
14NEED_SVCGSSD="no"
15RPCSVCGSSDOPTS=""
16
diff --git a/debian/ctdb.example.nfs.conf b/debian/ctdb.example.nfs.conf
17new file mode 1006440new file mode 100644
index 0000000..5cfa13a
--- /dev/null
+++ b/debian/ctdb.example.nfs.conf
@@ -0,0 +1,20 @@
1[general]
2pipefs-directory = /run/rpc_pipefs
3
4[lockd]
5port = 32768
6udp-port = 32768
7
8[mountd]
9manage-gids = 1
10port = 32767
11
12[nfsd]
13threads = 8
14vers4 = n
15
16[statd]
17ha-callout = /etc/ctdb/statd-callout
18name = @NFS_HOSTNAME@
19outgoing-port = 32766
20port = 32765
diff --git a/debian/ctdb.example.quota b/debian/ctdb.example.quota
0new file mode 10064421new file mode 100644
index 0000000..00eab66
--- /dev/null
+++ b/debian/ctdb.example.quota
@@ -0,0 +1,5 @@
1# Set to "true" if warnquota should be run in cron.daily
2run_warnquota=
3
4# Add options to rpc.rquotad here
5RPCRQUOTADOPTS="-p 32769"
diff --git a/debian/patches/fix-nfs-service-name-to-nfs-kernel-server.patch b/debian/patches/fix-nfs-service-name-to-nfs-kernel-server.patch
index 70afeba..0010ab2 100644
--- a/debian/patches/fix-nfs-service-name-to-nfs-kernel-server.patch
+++ b/debian/patches/fix-nfs-service-name-to-nfs-kernel-server.patch
@@ -4,13 +4,15 @@ Subject: fix nfs related service names
4Upstream defines nfs related service names based on the Linux4Upstream defines nfs related service names based on the Linux
5distribution. This patch fixes the names for Debian and derivatives.5distribution. This patch fixes the names for Debian and derivatives.
66
7Update by Andreas Hasenack <andreas@canonical.com> (LP: #1961840):
8Use nfsconf(8) if it's available, instead of parsing the old config
9files in /etc/default/nfs-*
10
7Bug-Debian: https://bugs.debian.org/92993111Bug-Debian: https://bugs.debian.org/929931
8Bug-Ubuntu: https://bugs.launchpad.net/bugs/72220112Bug-Ubuntu: https://bugs.launchpad.net/bugs/722201
9Last-Update: 2018-08-0513Last-Update: 2022-03-16
10Index: samba/ctdb/config/events/legacy/06.nfs.script14--- a/ctdb/config/events/legacy/06.nfs.script
11===================================================================15+++ b/ctdb/config/events/legacy/06.nfs.script
12--- samba.orig/ctdb/config/events/legacy/06.nfs.script 2020-11-24 18:11:53.506104058 -0500
13+++ samba/ctdb/config/events/legacy/06.nfs.script 2020-11-24 18:11:53.502104093 -0500
14@@ -6,7 +6,7 @@16@@ -6,7 +6,7 @@
15 17
16 . "${CTDB_BASE}/functions"18 . "${CTDB_BASE}/functions"
@@ -20,11 +22,9 @@ Index: samba/ctdb/config/events/legacy/06.nfs.script
20 22
21 load_script_options "service" "60.nfs"23 load_script_options "service" "60.nfs"
22 24
23Index: samba/ctdb/config/events/legacy/60.nfs.script25--- a/ctdb/config/events/legacy/60.nfs.script
24===================================================================26+++ b/ctdb/config/events/legacy/60.nfs.script
25--- samba.orig/ctdb/config/events/legacy/60.nfs.script 2020-11-24 18:11:53.506104058 -050027@@ -6,9 +6,11 @@
26+++ samba/ctdb/config/events/legacy/60.nfs.script 2020-11-24 18:11:53.502104093 -0500
27@@ -6,9 +6,9 @@
28 28
29 . "${CTDB_BASE}/functions"29 . "${CTDB_BASE}/functions"
30 30
@@ -32,14 +32,14 @@ Index: samba/ctdb/config/events/legacy/60.nfs.script
32+service_name="nfs-kernel-server"32+service_name="nfs-kernel-server"
33 33
34-load_system_config "nfs"34-load_system_config "nfs"
35+load_system_config "nfs-kernel-server"35+if ! type nfsconf > /dev/null 2>&1; then
36+ load_system_config "nfs-kernel-server"
37+fi
36 38
37 load_script_options39 load_script_options
38 40
39Index: samba/ctdb/config/nfs-linux-kernel-callout41--- a/ctdb/config/nfs-linux-kernel-callout
40===================================================================42+++ b/ctdb/config/nfs-linux-kernel-callout
41--- samba.orig/ctdb/config/nfs-linux-kernel-callout 2020-11-24 18:11:53.506104058 -0500
42+++ samba/ctdb/config/nfs-linux-kernel-callout 2020-11-24 18:11:53.502104093 -0500
43@@ -14,7 +14,7 @@43@@ -14,7 +14,7 @@
44 44
45 # As above, edit the default value below. CTDB_NFS_DISTRO_STYLE is a45 # As above, edit the default value below. CTDB_NFS_DISTRO_STYLE is a
@@ -49,31 +49,40 @@ Index: samba/ctdb/config/nfs-linux-kernel-callout
49 49
50 case "$nfs_distro_style" in50 case "$nfs_distro_style" in
51 systemd-*)51 systemd-*)
52@@ -33,6 +33,14 @@52@@ -32,7 +32,22 @@
53 : # Defaults only
53 ;;54 ;;
54 *-debian)55 *-debian)
55 nfs_rquotad_service="quotarpc"56- nfs_rquotad_service="quotarpc"
56+ nfs_lock_service=""57+ # XXX
57+ nfs_lock_service=""58+ # Undefine nfs_rquotad_services because the quotarpc service won't
58+ nfs_mountd_service=""59+ # start unless there are specific "quota" mount options in /etc/fstab.
59+ nfs_status_service=""60+ # In this way, we let ctdb start it up manually once the
61+ # /etc/ctdb/nfs-checks.d/50.rquotad.check detects rpc.rquotad isn't
62+ # running.
63+ # Users who really don't want rpc.rquotad running should then move
64+ # the 50.rquotad.check script away.
60+ nfs_rquotad_service=""65+ nfs_rquotad_service=""
61+ nfs_service="nfs-kernel-server"66+ nfs_service="nfs-kernel-server"
62+ nfs_config="/etc/default/nfs-kernel-server"67+ if type nfsconf >/dev/null 2>&1; then
68+ nfs_config=""
69+ else
70+ nfs_config="/etc/default/nfs-kernel-server"
71+ fi
63+ nfs_rquotad_config="/etc/default/quota"72+ nfs_rquotad_config="/etc/default/quota"
64 ;;73 ;;
65 *)74 *)
66 echo "Internal error"75 echo "Internal error"
67Index: samba/ctdb/config/statd-callout76--- a/ctdb/config/statd-callout
68===================================================================77+++ b/ctdb/config/statd-callout
69--- samba.orig/ctdb/config/statd-callout 2020-11-24 18:11:53.506104058 -050078@@ -29,7 +29,9 @@
70+++ samba/ctdb/config/statd-callout 2020-11-24 18:11:53.502104093 -0500
71@@ -29,7 +29,7 @@
72 }79 }
73 80
74 # Try different variables to find config file for NFS_HOSTNAME81 # Try different variables to find config file for NFS_HOSTNAME
75-load_system_config "nfs" "nfs-common"82-load_system_config "nfs" "nfs-common"
76+load_system_config "nfs-kernel-server"83+if ! type nfsconf > /dev/null 2>&1; then
84+ load_system_config "nfs-common" "nfs-kernel-server"
85+fi
77 86
78 # If NFS_HOSTNAME not set then try to pull it out of /etc/nfs.conf87 # If NFS_HOSTNAME not set then try to pull it out of /etc/nfs.conf
79 if [ -z "$NFS_HOSTNAME" ] && type nfsconf >/dev/null 2>&1 ; then88 if [ -z "$NFS_HOSTNAME" ] && type nfsconf >/dev/null 2>&1 ; then
diff --git a/debian/rules b/debian/rules
index 26d2df6..655be1a 100755
--- a/debian/rules
+++ b/debian/rules
@@ -222,8 +222,8 @@ override_dh_installexamples-arch:
222 # CTDB config examples and helper scripts222 # CTDB config examples and helper scripts
223 mkdir -p ctdb/doc/examples/nfs-kernel-server223 mkdir -p ctdb/doc/examples/nfs-kernel-server
224 cp debian/ctdb.example.enable.nfs.sh ctdb/doc/examples/nfs-kernel-server/enable-nfs.sh224 cp debian/ctdb.example.enable.nfs.sh ctdb/doc/examples/nfs-kernel-server/enable-nfs.sh
225 cp debian/ctdb.example.nfs-common ctdb/doc/examples/nfs-kernel-server/nfs-common225 cp debian/ctdb.example.nfs.conf ctdb/doc/examples/nfs-kernel-server/nfs.conf
226 cp debian/ctdb.example.nfs-kernel-server ctdb/doc/examples/nfs-kernel-server/nfs-kernel-server226 cp debian/ctdb.example.quota ctdb/doc/examples/nfs-kernel-server/quota
227 cp debian/ctdb.example.services ctdb/doc/examples/nfs-kernel-server/services227 cp debian/ctdb.example.services ctdb/doc/examples/nfs-kernel-server/services
228 cp debian/ctdb.example.sysctl-nfs-static-ports.conf ctdb/doc/examples/nfs-kernel-server/99-nfs-static-ports.conf228 cp debian/ctdb.example.sysctl-nfs-static-ports.conf ctdb/doc/examples/nfs-kernel-server/99-nfs-static-ports.conf
229 dh_installexamples229 dh_installexamples

Subscribers

People subscribed via source and target branches