From e52e23b427277deb4fd970dc927aae0c1a28b6ce Mon Sep 17 00:00:00 2001 From: Simon Dickhoven Date: Wed, 15 Oct 2025 13:45:44 -0400 Subject: [PATCH] fix(linkerd-cni): prevent parent from outpacing forked `monitor_cni_config()` process Signed-off-by: Simon Dickhoven --- cni-plugin/deployment/scripts/install-cni.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/cni-plugin/deployment/scripts/install-cni.sh b/cni-plugin/deployment/scripts/install-cni.sh index c6310bd3..1fd9342f 100755 --- a/cni-plugin/deployment/scripts/install-cni.sh +++ b/cni-plugin/deployment/scripts/install-cni.sh @@ -344,6 +344,21 @@ install_cni_bin # CNI config files. CNI_CONF_SHA='{}' monitor_cni_config & +monitor_pid=$! + +# The following logic waits (indefinitely if need be) for `inotifywait` in the +# forked `monitor_cni_config()` function to enter "interruptible sleep" state. +# This state indicates that `inotifywait` is fully up and ready to respond to +# filesystem events. +log "Wait for CNI config monitor to become ready" +while true; do + monitor_state=$( + (ps --ppid=$monitor_pid -o comm=,state= || true) | + awk '$1 == "inotifywait" && $2 == "S" {print "ok"}' + ) + [ -z "$monitor_state" ] || break + sleep .1 # 100ms +done # Append our config to any existing config file (*.conflist or *.conf) config_files=$(find "${HOST_CNI_NET}" -maxdepth 1 -type f ! -name '*linkerd*' \( -iname '*conflist' -o -iname '*conf' \))