Files
nvke/controller/internal/agent/scripts/node-preflight-cloud-init.sh
vwilson-nvidia e92d0dc7e1 fix(controller): wait for cloud-init on legacy agents (#2432)
- Use a completion script for agents older than v0.1.24
- Wait for readiness to populate agent versions before preflight

Signed-off-by: Vivin Wilson <vwilson@nvidia.com>
2026-11-23 14:14:11 -05:00

38 lines
1.1 KiB
Bash

#!/bin/bash
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
export LC_ALL=C
marker=/var/lib/dsxos/.cidata-consumed
if [ -L "$marker" ]; then
echo 'DSX CIDATA completion marker is not a regular file' >&2
exit 1
fi
if detail=$(stat -L -- "$marker" 2>&1 >/dev/null); then
if [ ! -f "$marker" ]; then
echo 'DSX CIDATA completion marker is not a regular file' >&2
exit 1
fi
echo ready
exit 0
fi
case "$detail" in
*': No such file or directory') ;;
*) printf '%s\n' "$detail" >&2; exit 1 ;;
esac
report=$(cloud-init status --long 2>&1)
result=$?
if [ "$result" -ne 0 ] && [ "$result" -ne 2 ]; then
printf 'cloud-init exited %s: %s\n' "$result" "$report" >&2
exit 1
fi
state=$(printf '%s\n' "$report" | sed -n 's/^[[:space:]]*[Ss][Tt][Aa][Tt][Uu][Ss]:[[:space:]]*//p' | head -n 1 | tr '[:upper:]' '[:lower:]')
state="${state%"${state##*[![:space:]]}"}"
case "$state" in
done) echo ready ;;
error) printf 'cloud-init error status: %s\n' "$report" >&2; exit 1 ;;
*) echo notready ;;
esac