joggerjoel commented on issue #12580:
URL: https://github.com/apache/apisix/issues/12580#issuecomment-3258430118
# Minimal Dockerfile to reproduce etcd hanging issue with APISIX
# This reproduces the issue where APISIX hangs on init_etcd phase
# preventing proper route synchronization with etcd
FROM apache/apisix:3.13.0-debian
# Switch to root for debugging
USER root
# Install debugging tools
RUN apt-get update && apt-get install -y \
curl \
netcat-openbsd \
procps \
&& rm -rf /var/lib/apt/lists/*
# Create minimal APISIX configuration that reproduces the hanging issue
RUN mkdir -p /usr/local/apisix/conf
# Minimal config that causes etcd hanging
COPY <<EOF /usr/local/apisix/conf/config.yaml
deployment:
role: traditional
admin_key:
- name: admin
key: YurWsfrexXabWoiFRfGSvfpxTlnfOsWH
role: admin
apisix:
node_listen: 80
enable_admin: true
admin_listen:
ip: 0.0.0.0
port: 9180
etcd:
host:
- "http://etcd:2379"
prefix: "/apisix"
timeout: 30
# Minimal plugin configuration
plugins:
- http
- serverless-pre-function
EOF
# Create a script to demonstrate the hanging issue
COPY <<EOF /usr/local/apisix/demonstrate_bug.sh
#!/bin/bash
echo "=== APISIX Etcd Hanging Bug Demonstration ==="
echo "This script demonstrates the etcd hanging issue with APISIX"
echo ""
echo "1. Starting APISIX..."
echo " Expected: APISIX should hang on 'init_etcd' phase"
echo " Actual: APISIX hangs and never completes initialization"
echo ""
# Start APISIX in background and capture logs
echo "Starting APISIX process..."
/usr/local/apisix/bin/apisix start > /tmp/apisix.log 2>&1 &
APISIX_PID=$!
echo "APISIX PID: $APISIX_PID"
echo ""
# Wait a bit and check if it's hanging
sleep 10
echo "2. Checking APISIX status after 10 seconds..."
if ps -p $APISIX_PID > /dev/null; then
echo " ✓ APISIX process is still running (PID: $APISIX_PID)"
echo " ❌ This indicates the hanging issue - APISIX should have
completed init by now"
else
echo " ✗ APISIX process has exited"
fi
echo ""
echo "3. Checking APISIX logs for hanging indicators..."
echo " Looking for 'init_etcd' hanging patterns..."
# Check for hanging patterns in logs
if grep -q "init_etcd" /tmp/apisix.log; then
echo " ❌ Found 'init_etcd' in logs - this is where APISIX hangs"
echo " Last few lines of log:"
tail -5 /tmp/apisix.log
else
echo " No 'init_etcd' found in logs"
fi
echo ""
echo "4. Testing etcd connectivity..."
echo " Checking if etcd is reachable from APISIX container..."
# Test etcd connectivity
if nc -z etcd 2379; then
echo " ✓ etcd is reachable on port 2379"
else
echo " ❌ etcd is not reachable on port 2379"
fi
echo ""
echo "5. Testing Admin API (should fail due to hanging)..."
echo " Attempting to access Admin API..."
# Test admin API
if curl -s -f http://localhost:9180/apisix/admin/services -H "X-API-KEY:
YurWsfrexXabWoiFRfGSvfpxTlnfOsWH" > /dev/null; then
echo " ✓ Admin API is responding (unexpected - hanging issue may be
resolved)"
else
echo " ❌ Admin API is not responding (expected due to hanging)"
fi
echo ""
echo "=== Bug Demonstration Complete ==="
echo ""
echo "Expected behavior:"
echo "- APISIX should complete initialization and respond to Admin API"
echo ""
echo "Actual behavior (bug):"
echo "- APISIX hangs on 'init_etcd' phase"
echo "- Admin API is not accessible"
echo "- Routes cannot be synchronized with etcd"
echo ""
echo "This demonstrates the etcd hanging issue that prevents APISIX"
echo "from properly synchronizing with etcd for route management."
# Keep container running for inspection
echo "Container will remain running for manual inspection..."
echo "Use 'docker exec -it <container> bash' to investigate further"
tail -f /dev/null
EOF
RUN chmod +x /usr/local/apisix/demonstrate_bug.sh
# Switch back to apisix user
USER apisix
# Expose ports
EXPOSE 80 9180
# Default command to demonstrate the bug
CMD ["/usr/local/apisix/demonstrate_bug.sh"]
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]