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 eb26fa1
Showing 1 changed file with 2 additions and 21 deletions.
23 changes: 2 additions & 21 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 @@ -312,31 +312,12 @@ setup_cluster() {
}


cleanup_container() {
node=$1
info "Cleanup container \"$node\"..."
podman stop $node
podman rm $node
}


cleanup_cluster() {
podman ps --format json | jq -r '.[].Names[]' | grep -E 'hanode.*|qnetd-node' | xargs podman stop --time 120
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 eb26fa1

Please sign in to comment.