Skip to content

Commit 306bafe

Browse files
Dobbyclaude
andcommitted
fix(verify): replace IMDS extension check with waagent service detection
IMDS doesn't expose allowExtensionOperations — the field always returns "unknown". Switch to checking walinuxagent service status and waagent.conf Extensions.Enabled setting, which reliably detects whether az vm run-command can reach the VM. Tested on staging CVM (elfie-dock.privateclaw.dev) — waagent active shows the expected WARN on staging. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 01c2654 commit 306bafe

1 file changed

Lines changed: 17 additions & 10 deletions

File tree

privateclaw

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -589,22 +589,29 @@ PYEOF
589589
echo " Firewall: $UFW_STATUS"
590590
fi
591591

592-
EXTENSIONS_ALLOWED=$(curl -sf -H "Metadata: true" \
593-
"http://169.254.169.254/metadata/instance/compute/osProfile/allowExtensionOperations?api-version=2021-02-01&format=text" 2>/dev/null || echo "unknown")
594-
if [ "$EXTENSIONS_ALLOWED" = "false" ]; then
595-
echo " Azure VM Extensions: disabled (PASS)"
596-
elif [ "$EXTENSIONS_ALLOWED" = "true" ]; then
597-
echo " Azure VM Extensions: enabled (WARN)"
592+
# Check if Azure Guest Agent can receive extensions
593+
# Method 1: Check walinuxagent service status
594+
WAAGENT_STATUS=$(systemctl is-active walinuxagent 2>/dev/null || echo "inactive")
595+
# Method 2: Check waagent.conf Extensions.Enabled setting
596+
EXTENSIONS_CONF=$(grep -i "^Extensions.Enabled" /etc/waagent.conf 2>/dev/null | cut -d= -f2 | tr -d ' ' || echo "unknown")
597+
598+
if [ "$WAAGENT_STATUS" = "inactive" ] || [ "$EXTENSIONS_CONF" = "n" ]; then
599+
echo " VM Extensions: disabled (waagent $WAAGENT_STATUS, config=$EXTENSIONS_CONF)"
600+
EXTENSIONS_DISABLED="true"
601+
elif [ "$WAAGENT_STATUS" = "active" ] && [ "$EXTENSIONS_CONF" != "n" ]; then
602+
echo " VM Extensions: WARN — waagent is running, az vm run-command may work"
603+
EXTENSIONS_DISABLED="false"
598604
else
599-
echo " Azure VM Extensions: unknown (WARN)"
605+
echo " VM Extensions: waagent=$WAAGENT_STATUS, config=$EXTENSIONS_CONF"
606+
EXTENSIONS_DISABLED="false"
600607
fi
601608

602609
# Overall: PASS requires SSH keys<=1 AND firewall active AND extensions disabled.
603-
# Extensions enabled/unknown is a WARN (staging intentionally has them on).
604-
if [ "$KEY_COUNT" -le 1 ] && [ "$EXTENSIONS_ALLOWED" = "false" ]; then
610+
# Extensions enabled is a WARN (staging intentionally has them on).
611+
if [ "$KEY_COUNT" -le 1 ] && [ "$EXTENSIONS_DISABLED" = "true" ]; then
605612
echo " Status: PASS"
606613
PASS_COUNT=$((PASS_COUNT + 1))
607-
elif [ "$KEY_COUNT" -le 1 ] && { [ "$EXTENSIONS_ALLOWED" = "true" ] || [ "$EXTENSIONS_ALLOWED" = "unknown" ]; }; then
614+
elif [ "$KEY_COUNT" -le 1 ] && [ "$EXTENSIONS_DISABLED" = "false" ]; then
608615
echo " Status: WARN (VM extensions not disabled — expected on staging, not on prod)"
609616
FAIL_COUNT=$((FAIL_COUNT + 1))
610617
else

0 commit comments

Comments
 (0)