diff mbox series

[1/1] rpc_lib.sh: Check for running RPC

Message ID 20220124065937.17383-1-pvorel@suse.cz
State Accepted
Headers show
Series [1/1] rpc_lib.sh: Check for running RPC | expand

Commit Message

Petr Vorel Jan. 24, 2022, 6:59 a.m. UTC
instead of just rpcbind/portmap was running.

This should fix problem for some containers where rpcbind has not been
started and calling rpcinfo should do the socket activation.

Reported-by: Nikita Yushchenko <nikita.yushchenko@virtuozzo.com>
Suggested-by: NeilBrown <neilb@suse.de>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
Hi all,

Nikita, does it really fix your case? Or there needs to be 2 rpcinfo -p
calls with sleep in between?

Kind regards,
Petr

 .../network/rpc/basic_tests/rpc01/rpc01.sh    |  2 +-
 testcases/network/rpc/basic_tests/rpc_lib.sh  | 22 ++++++++++++-------
 .../rpc/basic_tests/rpcinfo/rpcinfo01.sh      |  2 +-
 testcases/network/rpc/rpc-tirpc/rpc_test.sh   |  2 +-
 4 files changed, 17 insertions(+), 11 deletions(-)

Comments

Nikita Yushchenko Jan. 24, 2022, 2:26 p.m. UTC | #1
24.01.2022 09:59, Petr Vorel wrote:
> instead of just rpcbind/portmap was running.
> 
> This should fix problem for some containers where rpcbind has not been
> started and calling rpcinfo should do the socket activation.
> 
> Reported-by: Nikita Yushchenko <nikita.yushchenko@virtuozzo.com>
> Suggested-by: NeilBrown <neilb@suse.de>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
> Hi all,
> 
> Nikita, does it really fix your case? Or there needs to be 2 rpcinfo -p
> calls with sleep in between?

Yes, it fixes that.

Btw, easy test is:
   systemctl stop rpcbind.service
   runltp -f net.rpc

After applying your patch, that results in no TCONF from rcp01.sh, because rpcbind.socket is still 
there, and systemd restarts rpcbind on request.

Nikita
Petr Vorel Jan. 24, 2022, 5:20 p.m. UTC | #2
Hi Nikita,


> Yes, it fixes that.

> Btw, easy test is:
>   systemctl stop rpcbind.service
>   runltp -f net.rpc

> After applying your patch, that results in no TCONF from rcp01.sh, because
> rpcbind.socket is still there, and systemd restarts rpcbind on request.
Thanks for verifying it!

Kind regards,
Petr
Petr Vorel Jan. 24, 2022, 9:10 p.m. UTC | #3
> > Nikita, does it really fix your case? Or there needs to be 2 rpcinfo -p
> > calls with sleep in between?

> Yes, it fixes that.

> Btw, easy test is:
>   systemctl stop rpcbind.service
>   runltp -f net.rpc

> After applying your patch, that results in no TCONF from rcp01.sh, because
> rpcbind.socket is still there, and systemd restarts rpcbind on request.

FYI merged, with fixing $x variable to $services.
Again, thanks both for your work.

Kind regards,
Petr

> Nikita
diff mbox series

Patch

diff --git a/testcases/network/rpc/basic_tests/rpc01/rpc01.sh b/testcases/network/rpc/basic_tests/rpc01/rpc01.sh
index 9ca5daae62..a4989b98f2 100755
--- a/testcases/network/rpc/basic_tests/rpc01/rpc01.sh
+++ b/testcases/network/rpc/basic_tests/rpc01/rpc01.sh
@@ -19,7 +19,7 @@  do_cleanup()
 
 do_setup()
 {
-	check_portmap_rpcbind
+	check_rpc
 
 	tst_res TINFO "start rpc_server"
 	ROD rpc_server
diff --git a/testcases/network/rpc/basic_tests/rpc_lib.sh b/testcases/network/rpc/basic_tests/rpc_lib.sh
index c7c868709b..477408bcef 100644
--- a/testcases/network/rpc/basic_tests/rpc_lib.sh
+++ b/testcases/network/rpc/basic_tests/rpc_lib.sh
@@ -1,15 +1,21 @@ 
 #!/bin/sh
-# Copyright (c) 2020 Petr Vorel <pvorel@suse.cz>
+# Copyright (c) 2020-2021 Petr Vorel <pvorel@suse.cz>
 
+TST_NEEDS_CMDS="rpcinfo $TST_NEEDS_CMDS"
 . tst_net.sh
 
-check_portmap_rpcbind()
+check_rpc()
 {
-	if pgrep portmap > /dev/null; then
-		PORTMAPPER="portmap"
-	else
-		pgrep rpcbind > /dev/null && PORTMAPPER="rpcbind" || \
-			tst_brk TCONF "portmap or rpcbind is not running"
+	local services
+
+	tst_res TINFO "check registered RPC with rpcinfo"
+
+	services=$(rpcinfo -p)
+
+	if [ $? -ne 0 ] || ! echo "$services" | grep -q '[0-9]'; then
+		tst_brk TCONF "no RPC services, is rpcbind/portmap running?"
 	fi
-	tst_res TINFO "using $PORTMAPPER"
+
+	tst_res TINFO "registered RPC"
+	echo "$x"
 }
diff --git a/testcases/network/rpc/basic_tests/rpcinfo/rpcinfo01.sh b/testcases/network/rpc/basic_tests/rpcinfo/rpcinfo01.sh
index 811f79ef76..ade9711223 100755
--- a/testcases/network/rpc/basic_tests/rpcinfo/rpcinfo01.sh
+++ b/testcases/network/rpc/basic_tests/rpcinfo/rpcinfo01.sh
@@ -11,7 +11,7 @@  TST_NEEDS_CMDS="rpcinfo wc"
 
 do_setup()
 {
-	check_portmap_rpcbind
+	check_rpc
 
 	# Create file with 1 tcp and 1 udp line. Use for variable assignments.
 	rpcinfo -p $(tst_ipaddr) | grep tcp | sed -n 2p > rpc_out
diff --git a/testcases/network/rpc/rpc-tirpc/rpc_test.sh b/testcases/network/rpc/rpc-tirpc/rpc_test.sh
index 54a689649c..e1d952da81 100755
--- a/testcases/network/rpc/rpc-tirpc/rpc_test.sh
+++ b/testcases/network/rpc/rpc-tirpc/rpc_test.sh
@@ -45,7 +45,7 @@  rpc_parse_args()
 
 setup()
 {
-	check_portmap_rpcbind
+	check_rpc
 
 	if [ -n "$SERVER" ]; then
 		CLEANER="rpc_cleaner"