mirror of
https://github.com/outbackdingo/cozystack.git
synced 2026-01-27 18:18:41 +00:00
[dx] better check for processes in self destructing enviroments (#1140)
Signed-off-by: Andrei Kvapil <kvapss@gmail.com> <!-- Thank you for making a contribution! Here are some tips for you: - Start the PR title with the [label] of Cozystack component: - For system components: [platform], [system], [linstor], [cilium], [kube-ovn], [dashboard], [cluster-api], etc. - For managed apps: [apps], [tenant], [kubernetes], [postgres], [virtual-machine] etc. - For development and maintenance: [tests], [ci], [docs], [maintenance]. - If it's a work in progress, consider creating this PR as a draft. - Don't hesistate to ask for opinion and review in the community chats, even if it's still a draft. - Add the label `backport` if it's a bugfix that needs to be backported to a previous version. --> ## What this PR does ### Release note <!-- Write a release note: - Explain what has changed internally and for users. - Start with the same [label] as in the PR title - Follow the guidelines at https://github.com/kubernetes/community/blob/master/contributors/guide/release-notes.md. --> ```release-note [dx] better check for processes in self destructing enviroments ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Updated system image to include additional utilities for process management. * **Refactor** * Simplified internal process filtering to improve reliability and maintainability. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -9,7 +9,7 @@ ARG TARGETOS
|
||||
ARG TARGETARCH
|
||||
|
||||
RUN apt update -q
|
||||
RUN apt install -yq --no-install-recommends genisoimage ca-certificates qemu-kvm qemu-utils iproute2 iptables wget xz-utils netcat curl jq make git
|
||||
RUN apt install -yq --no-install-recommends psmisc genisoimage ca-certificates qemu-kvm qemu-utils iproute2 iptables wget xz-utils netcat curl jq make git
|
||||
RUN curl -sSL "https://github.com/siderolabs/talos/releases/download/v${TALOSCTL_VERSION}/talosctl-${TARGETOS}-${TARGETARCH}" -o /usr/local/bin/talosctl \
|
||||
&& chmod +x /usr/local/bin/talosctl
|
||||
RUN curl -sSL "https://dl.k8s.io/release/v${KUBECTL_VERSION}/bin/${TARGETOS}/${TARGETARCH}/kubectl" -o /usr/local/bin/kubectl \
|
||||
|
||||
@@ -17,36 +17,16 @@ while [ $# -gt 0 ]; do
|
||||
esac
|
||||
done
|
||||
|
||||
ALL_PROCS=$(ps -eo pid=,ppid=,comm=)
|
||||
|
||||
get_descendants() {
|
||||
PARENT="$1"
|
||||
echo "$PARENT"
|
||||
echo "$ALL_PROCS" | while read -r PID PPID CMD; do
|
||||
PID=$(echo "$PID" | tr -d ' ')
|
||||
PPID=$(echo "$PPID" | tr -d ' ')
|
||||
if [ "$PPID" = "$PARENT" ]; then
|
||||
echo "$PID"
|
||||
get_descendants "$PID"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
is_own_tree() {
|
||||
PID="$1"
|
||||
echo "$DESCENDANTS" | grep -q -x "$PID"
|
||||
}
|
||||
|
||||
check_once() {
|
||||
DESCENDANTS="$(get_descendants "$SELF_PID" | sort -u)"
|
||||
OWN_PIDS=$(pstree -p $$ | grep -o '[0-9]\+' | sort -u)
|
||||
ALL_PROCS=$(ps -eo pid=,comm=)
|
||||
|
||||
EXTERNAL_PIDS=$(
|
||||
echo "$ALL_PROCS" | while read -r PID PPID CMD; do
|
||||
echo "$ALL_PROCS" | while read -r PID CMD; do
|
||||
PID=$(echo "$PID" | tr -d ' ')
|
||||
CMD=$(echo "$CMD" | tr -d ' ')
|
||||
|
||||
if is_own_tree "$PID"; then
|
||||
continue
|
||||
fi
|
||||
echo "$OWN_PIDS" | grep -q -x "$PID" && continue
|
||||
|
||||
case "$CMD" in
|
||||
*qemu*) continue ;;
|
||||
|
||||
Reference in New Issue
Block a user