diff mbox series

[RFC,3/7] selftests: openvswitch: use non-graceful kills when needed

Message ID 20240216152846.1850120-4-aconole@redhat.com (mailing list archive)
State RFC
Delegated to: Netdev Maintainers
Headers show
Series selftests: openvswitch: cleanups for running as selftests | expand

Checks

Context Check Description
netdev/series_format warning Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/build_tools success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang success Errors and warnings before: 8 this patch: 8
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success net selftest script(s) already in Makefile
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 8 this patch: 8
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 18 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Aaron Conole Feb. 16, 2024, 3:28 p.m. UTC
Normally a spawned process under OVS is given a SIGTERM when the test
ends as part of cleanup.  However, in case the process is still lingering
for some reason, we also send a SIGKILL to force it down faster.

Signed-off-by: Aaron Conole <aconole@redhat.com>
---
 tools/testing/selftests/net/openvswitch/openvswitch.sh | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Adrián Moreno Feb. 21, 2024, 5:32 p.m. UTC | #1
On 2/16/24 16:28, Aaron Conole wrote:
> Normally a spawned process under OVS is given a SIGTERM when the test
> ends as part of cleanup.  However, in case the process is still lingering
> for some reason, we also send a SIGKILL to force it down faster.
> 
> Signed-off-by: Aaron Conole <aconole@redhat.com>
> ---
>   tools/testing/selftests/net/openvswitch/openvswitch.sh | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/testing/selftests/net/openvswitch/openvswitch.sh b/tools/testing/selftests/net/openvswitch/openvswitch.sh
> index a5dbde482ba4..678a72ad47c1 100755
> --- a/tools/testing/selftests/net/openvswitch/openvswitch.sh
> +++ b/tools/testing/selftests/net/openvswitch/openvswitch.sh
> @@ -91,7 +91,8 @@ ovs_add_if () {
>   		python3 $ovs_base/ovs-dpctl.py add-if \
>   		    -u "$2" "$3" >$ovs_dir/$3.out 2>$ovs_dir/$3.err &
>   		pid=$!
> -		on_exit "ovs_sbx $1 kill -TERM $pid 2>/dev/null"
> +		on_exit "ovs_sbx $1 kill --timeout 1000 TERM \
> +                                        --timeout 1000 KILL $pid 2>/dev/null"
>   	fi
>   }
>   

AFAIK, this will immediately send TERM, then wait 1s, send TERM again, wait 1s 
then send KILL. Is that what you intended? To avoid the double TERM you could:

kill --timeout 1000 KILL --signal TERM $pid

--
Adrián Moreno

> @@ -108,7 +109,8 @@ ovs_netns_spawn_daemon() {
>   	info "spawning cmd: $*"
>   	ip netns exec $netns $*  >> $ovs_dir/stdout  2>> $ovs_dir/stderr &
>   	pid=$!
> -	ovs_sbx "$sbx" on_exit "kill -TERM $pid 2>/dev/null"
> +	ovs_sbx "$sbx" on_exit "kill --timeout 1000 TERM \
> +                                    --timeout 1000 KILL $pid 2>/dev/null"
>   }
>   
>   ovs_add_netns_and_veths () {
Aaron Conole Feb. 21, 2024, 9:11 p.m. UTC | #2
Adrian Moreno <amorenoz@redhat.com> writes:

> On 2/16/24 16:28, Aaron Conole wrote:
>> Normally a spawned process under OVS is given a SIGTERM when the test
>> ends as part of cleanup.  However, in case the process is still lingering
>> for some reason, we also send a SIGKILL to force it down faster.
>> Signed-off-by: Aaron Conole <aconole@redhat.com>
>> ---
>>   tools/testing/selftests/net/openvswitch/openvswitch.sh | 6 ++++--
>>   1 file changed, 4 insertions(+), 2 deletions(-)
>> diff --git a/tools/testing/selftests/net/openvswitch/openvswitch.sh
>> b/tools/testing/selftests/net/openvswitch/openvswitch.sh
>> index a5dbde482ba4..678a72ad47c1 100755
>> --- a/tools/testing/selftests/net/openvswitch/openvswitch.sh
>> +++ b/tools/testing/selftests/net/openvswitch/openvswitch.sh
>> @@ -91,7 +91,8 @@ ovs_add_if () {
>>   		python3 $ovs_base/ovs-dpctl.py add-if \
>>   		    -u "$2" "$3" >$ovs_dir/$3.out 2>$ovs_dir/$3.err &
>>   		pid=$!
>> -		on_exit "ovs_sbx $1 kill -TERM $pid 2>/dev/null"
>> +		on_exit "ovs_sbx $1 kill --timeout 1000 TERM \
>> +                                        --timeout 1000 KILL $pid 2>/dev/null"
>>   	fi
>>   }
>>   
>
> AFAIK, this will immediately send TERM, then wait 1s, send TERM again,
> wait 1s then send KILL. Is that what you intended? To avoid the double
> TERM you could:

Okay, I'll adjust it.

> --
> Adrián Moreno
>
>> @@ -108,7 +109,8 @@ ovs_netns_spawn_daemon() {
>>   	info "spawning cmd: $*"
>>   	ip netns exec $netns $*  >> $ovs_dir/stdout  2>> $ovs_dir/stderr &
>>   	pid=$!
>> -	ovs_sbx "$sbx" on_exit "kill -TERM $pid 2>/dev/null"
>> +	ovs_sbx "$sbx" on_exit "kill --timeout 1000 TERM \
>> +                                    --timeout 1000 KILL $pid 2>/dev/null"
>>   }
>>     ovs_add_netns_and_veths () {
diff mbox series

Patch

diff --git a/tools/testing/selftests/net/openvswitch/openvswitch.sh b/tools/testing/selftests/net/openvswitch/openvswitch.sh
index a5dbde482ba4..678a72ad47c1 100755
--- a/tools/testing/selftests/net/openvswitch/openvswitch.sh
+++ b/tools/testing/selftests/net/openvswitch/openvswitch.sh
@@ -91,7 +91,8 @@  ovs_add_if () {
 		python3 $ovs_base/ovs-dpctl.py add-if \
 		    -u "$2" "$3" >$ovs_dir/$3.out 2>$ovs_dir/$3.err &
 		pid=$!
-		on_exit "ovs_sbx $1 kill -TERM $pid 2>/dev/null"
+		on_exit "ovs_sbx $1 kill --timeout 1000 TERM \
+                                        --timeout 1000 KILL $pid 2>/dev/null"
 	fi
 }
 
@@ -108,7 +109,8 @@  ovs_netns_spawn_daemon() {
 	info "spawning cmd: $*"
 	ip netns exec $netns $*  >> $ovs_dir/stdout  2>> $ovs_dir/stderr &
 	pid=$!
-	ovs_sbx "$sbx" on_exit "kill -TERM $pid 2>/dev/null"
+	ovs_sbx "$sbx" on_exit "kill --timeout 1000 TERM \
+                                    --timeout 1000 KILL $pid 2>/dev/null"
 }
 
 ovs_add_netns_and_veths () {