Skip to content

Commit c13f8df

Browse files
Added handling of force removal of stuck podman containers in stopping state (#2926)
* fixed permission matching logic * fixed permission matching logic * fixed permission matching logic * fixed permission matching logic * updated PAR URL * Added to support handling of stuck podman container * fixed lint * Update agentAutoUpdate.sh * Update agentAutoUpdate.sh * Update agentAutoUpdate.sh * Fixed handling of force removal of stuck podman containers in stopping state * Fixed handling of force removal of stuck podman containers in stopping state
1 parent bac5614 commit c13f8df

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

OracleIdentityGovernance/samples/scripts/agentManagement.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,28 @@ else
718718
fi
719719
}
720720

721+
forceRmPodman()
722+
{
723+
# Get the main process for the container.
724+
CONTAINER_ID=$(podman ps -a | grep "$AI" | awk '{print $1}')
725+
if [ -n "${CONTAINER_ID}" ]; then
726+
echo Container ID : "$CONTAINER_ID"
727+
CONTAINER_PROCESS_ID=$(ps -ef | grep -v grep | grep "$CONTAINER_ID" | awk '{print $2}')
728+
echo Container Process ID: ${CONTAINER_PROCESS_ID}
729+
730+
# Kill any processes containing the process ID.
731+
# This kills the child processes too.
732+
# shellcheck disable=SC2046
733+
kill -9 `ps -ef | grep -v grep | grep ${CONTAINER_PROCESS_ID} | awk '{print $2}'`
734+
735+
# Stop the container, as Podman doesn't notice the processes are dead until you interact with the container.
736+
echo "Removing container. Ignore errors."
737+
podman rm -f "$AI"
738+
else
739+
echo "Container Already Removed"
740+
fi
741+
}
742+
721743
# shellcheck source=/dev/null
722744
stop()
723745
{
@@ -779,6 +801,7 @@ kill()
779801
podman exec "$AI" /bin/bash -c 'agent --config /app/data/conf/config.json ido lcm -i status_check; while [[ "$?" != "2" && "$?" != "255" ]]; do sleep 5s;agent --config /app/data/conf/config.json ido lcm -i status_check; done' >/dev/null
780802
fi
781803
podman rm -f "$AI"
804+
forceRmPodman
782805
fi
783806
}
784807

0 commit comments

Comments
 (0)