Commit 9c9f7ddb authored by Krzysztof Karas's avatar Krzysztof Karas Committed by Tomasz Zawadzki
Browse files

lib/event: make SPDK app exit upon RPC server launch failure



Whenever an application cannot start a server, it will print an error,
but not exit upon detecting that condition, so we implicitly disable
the server by just ignoring its inability to launch.

We should not allow RPC servers to fail their initialization while
allowing SPDK app to continue working. Instead, we should exit the
app, whenever sever failed to start on a valid RPC address.

Change-Id: I10a779c71ed5101d12d69383d646f44bad6d9565
Signed-off-by: default avatarKrzysztof Karas <krzysztof.karas@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/22153


Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Community-CI: Mellanox Build Bot
parent 13481a59
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -165,9 +165,7 @@ spdk_rpc_initialize(const char *listen_addr, const struct spdk_rpc_opts *opts)
	if (init_server->server == NULL) {
		SPDK_ERRLOG("Unable to start RPC service at %s\n", listen_addr);
		free(init_server);
		/* TODO: Eventually, treat this as an error. But it historically has not
		 * been and many tests rely on this gracefully failing. */
		return 0;
		return -EINVAL;
	}

	rpc_set_spdk_log_opts(opts);
+17 −0
Original line number Diff line number Diff line
@@ -57,8 +57,25 @@ test_skip_rpc_with_delay() {
	NOT $SPDK_BIN_DIR/spdk_tgt --no-rpc-server -m 0x1 --wait-for-rpc
}

test_exit_on_failed_rpc_init() {
	$SPDK_BIN_DIR/spdk_tgt -m 0x1 &
	local spdk_pid=$!
	waitforlisten $spdk_pid

	trap 'killprocess $spdk_pid; exit 1' SIGINT SIGTERM EXIT
	# RPC listening sockets must be unique for each SPDK instance, so this will fail
	NOT $SPDK_BIN_DIR/spdk_tgt -m 0x2

	trap - SIGINT SIGTERM EXIT
	killprocess $spdk_pid
}

run_test "skip_rpc" test_skip_rpc
run_test "skip_rpc_with_json" test_skip_rpc_with_json
run_test "skip_rpc_with_delay" test_skip_rpc_with_delay
# Only one DPDK process can run under FreeBSD (see lib/eal/freebsd/eal_hugepage_info.c in DPDK)
if [ $(uname) != "FreeBSD" ]; then
	run_test "exit_on_failed_rpc_init" test_exit_on_failed_rpc_init
fi

rm $CONFIG_PATH