Skip to content

Commit

Permalink
simplify cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasyang2022 committed Oct 16, 2024
1 parent 17f6de9 commit 5e7f7b0
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions test/run-functional-tests
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ deploy_ha_node() {
make_cmd="cd $PROJECT_INSIDE;./autogen.sh && ./configure --prefix /usr && make install && make install-crmconfDATA prefix= && cp /usr/bin/crm /usr/sbin"

info "Deploying \"$node_name\"..."
podman run -d $podman_options $podman_capabilties $CONTAINER_IMAGE &> /dev/null
podman run --rm -d $podman_options $podman_capabilties $CONTAINER_IMAGE &> /dev/null
for network in ${HA_NETWORK_ARRAY[@]};do
podman network connect $network $node_name
done
Expand Down Expand Up @@ -315,28 +315,17 @@ setup_cluster() {
cleanup_container() {
node=$1
info "Cleanup container \"$node\"..."
podman stop $node
podman stop --time 120 $node
podman rm $node
}


cleanup_cluster() {
podman ps --format json | jq -r '.[].Names[]' | grep -E 'hanode.*|qnetd-node' | xargs podman stop
exist_network_array=()
for network in ${HA_NETWORK_ARRAY[@]};do
podman network ls|grep -q $network && exist_network_array+=($network)
done
if [ ${#exist_network_array[@]} -eq 0 ];then
info "Already cleaned up"
return 0
fi

podman network inspect $exist_network_array
container_array=(`podman network inspect $exist_network_array | jq -r '.[].containers[].name' | sort | uniq`)
for node in ${container_array[@]};do
cleanup_container $node &
done
wait

for network in ${exist_network_array[@]};do
info "Cleanup ha specific container network \"$network\"..."
podman network rm $network
Expand Down

0 comments on commit 5e7f7b0

Please sign in to comment.