Skip to content

Commit 0848461

Browse files
committed
Enhance Docker workflow scripts with improved status checks and error handling; update README to remove outdated documentation
1 parent b42db1b commit 0848461

File tree

7 files changed

+139
-33
lines changed

7 files changed

+139
-33
lines changed

.github/workflows/test-all-deployment-methods.yml

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,22 +93,25 @@ jobs:
9393
echo "| Test | Status | Details |" >> comprehensive-report.md
9494
echo "|------|--------|---------|" >> comprehensive-report.md
9595
96-
# Extract and format each test result
97-
jq -r 'to_entries[] | "\(.key)|\(.value.result)|\(.value.message)"' "$json_file" | while IFS='|' read -r test_name result message; do
96+
# Use a temporary file to avoid subshell issues with counters
97+
temp_results=$(mktemp)
98+
jq -r 'to_entries[] | "\(.key)|\(.value.result)|\(.value.message)"' "$json_file" > "$temp_results"
99+
100+
while IFS='|' read -r test_name result message; do
98101
case "$result" in
99-
"PASS") status_icon="✅"; ((total_passed++)) ;;
100-
"PARTIAL") status_icon="⚠️"; ((total_partial++)) ;;
101-
"FAIL") status_icon="❌"; ((total_failed++)) ;;
102-
*) status_icon="❓"; ((total_failed++)) ;;
102+
"PASS") status_icon="✅" ;;
103+
"PARTIAL") status_icon="⚠️" ;;
104+
"FAIL") status_icon="❌" ;;
105+
*) status_icon="❓" ;;
103106
esac
104-
((total_tests++))
105107
106108
# Format test name for readability
107109
formatted_name=$(echo "$test_name" | sed 's/_/ /g' | sed 's/\b\w/\u&/g')
108110
echo "| $formatted_name | $status_icon $result | $message |" >> comprehensive-report.md
109-
done
111+
done < "$temp_results"
112+
rm "$temp_results"
110113
111-
# Get summary counts from JSON
114+
# Get summary counts from JSON (fix the counting issue)
112115
method_passed=$(jq '[.[] | select(.result == "PASS")] | length' "$json_file")
113116
method_partial=$(jq '[.[] | select(.result == "PARTIAL")] | length' "$json_file")
114117
method_total=$(jq '. | length' "$json_file")
@@ -126,7 +129,7 @@ jobs:
126129
echo "- 📊 Success Rate: $success_rate%" >> comprehensive-report.md
127130
fi
128131
129-
# Update global counters
132+
# Update global counters properly
130133
total_passed=$((total_passed + method_passed))
131134
total_partial=$((total_partial + method_partial))
132135
total_failed=$((total_failed + method_failed))

.github/workflows/test-legacy-method.yml

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -99,30 +99,55 @@ jobs:
9999
id: test-status
100100
run: |
101101
echo "=== Testing Legacy Method - Status ==="
102+
# Give containers time to fully start
103+
sleep 20
104+
102105
status_success=0
103106
104-
# Check script status
105-
if ./manage-clients.sh status; then
106-
echo "✅ Script status check passed"
107+
# Check if docker-compose file exists
108+
if [ -f "docker-compose.generated.yml" ]; then
109+
echo "✅ Generated compose file exists"
107110
((status_success++))
108111
else
109-
echo "❌ Script status check failed"
112+
echo "❌ Generated compose file missing"
110113
fi
111114
112-
# Check docker-compose status
113-
if docker-compose -f docker-compose.generated.yml ps; then
114-
echo "✅ Docker-compose status check passed"
115+
# Check docker-compose status first
116+
if docker-compose -f docker-compose.generated.yml ps | grep -q "Up"; then
117+
echo "✅ Docker-compose shows containers running"
115118
((status_success++))
116119
else
117-
echo "❌ Docker-compose status check failed"
120+
echo "❌ Docker-compose shows no running containers"
121+
docker-compose -f docker-compose.generated.yml ps
118122
fi
119123
120-
if [ $status_success -eq 2 ]; then
121-
echo "result=PASS" >> $GITHUB_OUTPUT
122-
echo "message=Status check completed successfully (2/2)" >> $GITHUB_OUTPUT
124+
# Check docker ps for our containers
125+
running_containers=$(docker ps --filter "name=wow-clients-client" --format "{{.Names}}" | wc -l)
126+
if [ "$running_containers" -gt 0 ]; then
127+
echo "✅ Found $running_containers running containers with expected name pattern"
128+
((status_success++))
129+
else
130+
echo "❌ No containers found with expected name pattern"
131+
docker ps --filter "name=wow"
132+
fi
133+
134+
# Check script status (with our improved error handling)
135+
if ./manage-clients.sh status; then
136+
echo "✅ Script status check passed"
137+
((status_success++))
123138
else
139+
echo "❌ Script status check failed"
140+
fi
141+
142+
if [ $status_success -eq 4 ]; then
143+
echo "result=PASS" >> $GITHUB_OUTPUT
144+
echo "message=Status check completed successfully (4/4 checks passed)" >> $GITHUB_OUTPUT
145+
elif [ $status_success -gt 0 ]; then
124146
echo "result=PARTIAL" >> $GITHUB_OUTPUT
125-
echo "message=Status check partially passed ($status_success/2)" >> $GITHUB_OUTPUT
147+
echo "message=Status check partially passed ($status_success/4 checks passed)" >> $GITHUB_OUTPUT
148+
else
149+
echo "result=FAIL" >> $GITHUB_OUTPUT
150+
echo "message=Status check failed (0/4 checks passed)" >> $GITHUB_OUTPUT
126151
fi
127152
128153
- name: Test Legacy - Container Verification

.github/workflows/test-swarm-method.yml

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,55 @@ jobs:
7878
id: test-status
7979
run: |
8080
echo "=== Testing Swarm Method - Status ==="
81+
# Give services time to start
82+
sleep 20
83+
84+
status_success=0
85+
86+
# Check if swarm is active
87+
if docker info --format '{{.Swarm.LocalNodeState}}' | grep -q "active"; then
88+
echo "✅ Swarm mode is active"
89+
((status_success++))
90+
else
91+
echo "❌ Swarm mode is not active"
92+
fi
93+
94+
# Check if our stack is deployed
95+
if docker stack ls --format "{{.Name}}" | grep -q "^wow-clients$"; then
96+
echo "✅ Stack 'wow-clients' is deployed"
97+
((status_success++))
98+
else
99+
echo "❌ Stack 'wow-clients' is not deployed"
100+
fi
101+
102+
# Check if our service exists
103+
if docker service ls --filter "name=wow-clients_wow-client" --format "{{.Name}}" | grep -q "wow-clients_wow-client"; then
104+
echo "✅ Service 'wow-clients_wow-client' exists"
105+
((status_success++))
106+
else
107+
echo "❌ Service 'wow-clients_wow-client' does not exist"
108+
fi
109+
110+
# Run the status command (should now pass with the fixed script)
81111
if ./manage-clients-swarm.sh status; then
82-
echo "Services:"
83-
docker service ls
112+
echo "✅ Status command executed successfully"
113+
((status_success++))
114+
else
115+
echo "❌ Status command failed"
116+
fi
117+
118+
echo "Services:"
119+
docker service ls
120+
121+
if [ $status_success -eq 4 ]; then
84122
echo "result=PASS" >> $GITHUB_OUTPUT
85-
echo "message=Status check completed successfully" >> $GITHUB_OUTPUT
123+
echo "message=Status check completed successfully (4/4 checks passed)" >> $GITHUB_OUTPUT
124+
elif [ $status_success -gt 0 ]; then
125+
echo "result=PARTIAL" >> $GITHUB_OUTPUT
126+
echo "message=Status check partially passed ($status_success/4 checks passed)" >> $GITHUB_OUTPUT
86127
else
87128
echo "result=FAIL" >> $GITHUB_OUTPUT
88-
echo "message=Status check failed" >> $GITHUB_OUTPUT
129+
echo "message=Status check failed (0/4 checks passed)" >> $GITHUB_OUTPUT
89130
fi
90131
91132
- name: Test Swarm - Scale Up

README.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ This is currently suited for World of Warcraft: Wrath of the Lich King client bu
1818
- [🔧 Troubleshooting](#-troubleshooting)
1919
- [🚀 Advanced Usage](#-advanced-usage)
2020

21-
## 📚 Documentation
22-
23-
- **[Volume Cleanup Guide](VOLUME-CLEANUP-GUIDE.md)** - Comprehensive guide for managing container volumes and data cleanup
24-
- **[Dynamic Orchestration Guide](README-dynamic.md)** - Advanced scaling and orchestration methods for large deployments
25-
2621
### Management Scripts Available:
2722
- `manage-clients-dynamic.sh` - **Recommended**: Direct Docker container management with unlimited scaling
2823
- `manage-clients.sh` - Docker Compose based management (legacy)

manage-clients-dynamic.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,12 @@ function show_status() {
289289

290290
echo ""
291291
echo "Resource usage:"
292-
docker stats --no-stream -f name="${PROJECT_NAME}-client-" --format "table {{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}" 2>/dev/null || echo "No running containers to show stats for"
292+
local running_containers=$(docker ps -q -f name="${PROJECT_NAME}-client-")
293+
if [ -n "$running_containers" ]; then
294+
docker stats --no-stream --format "table {{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}" $running_containers
295+
else
296+
echo "No running containers to show stats for"
297+
fi
293298
}
294299

295300
function clean_volumes() {

manage-clients-swarm.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,16 @@ function show_status() {
100100
echo "WoW Client Service Status:"
101101
echo "========================="
102102

103+
# Check if we're in swarm mode first
104+
if ! docker info --format '{{.Swarm.LocalNodeState}}' 2>/dev/null | grep -q "active"; then
105+
echo "Error: Docker is not in swarm mode. Run '$0 init' first."
106+
return 1
107+
fi
108+
103109
# Check if stack exists
104110
if ! docker stack ls --format "{{.Name}}" | grep -q "^${STACK_NAME}$"; then
105111
echo "Stack '$STACK_NAME' is not deployed"
106-
return
112+
return 1
107113
fi
108114

109115
# Show service status

manage-clients.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ function show_status() {
111111
echo "WoW Client Instance Status:"
112112
echo "=========================="
113113

114+
local found_containers=0
115+
114116
for i in {1..20}; do
115117
local container_name="wow-client-$i"
116118
local status=$(docker ps --filter "name=$container_name" --format "{{.Status}}" 2>/dev/null)
@@ -121,14 +123,43 @@ function show_status() {
121123
echo " Instance $i: RUNNING ($status)"
122124
echo " VNC: localhost:$vnc_port"
123125
echo " API: localhost:$api_port"
126+
found_containers=1
124127
elif docker ps -a --filter "name=$container_name" --format "{{.Names}}" | grep -q "^$container_name$"; then
125128
echo " Instance $i: STOPPED"
129+
found_containers=1
126130
fi
127131
done
128132

129133
echo ""
130134
echo "Active containers:"
131135
docker ps --filter "name=wow-client" --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"
136+
137+
echo ""
138+
echo "Resource usage:"
139+
local running_containers=$(docker ps -q --filter "name=wow-client")
140+
if [ -n "$running_containers" ]; then
141+
docker stats --no-stream --format "table {{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}" $running_containers
142+
else
143+
echo "No running containers to show stats for"
144+
fi
145+
146+
# If we expected containers but didn't find any, that's an error
147+
if [ $found_containers -eq 0 ]; then
148+
# Check for containers created by other methods (Docker Compose or Dynamic)
149+
local compose_containers=$(docker ps --filter "name=wow-clients-client" --format "{{.Names}}" | wc -l)
150+
local all_wow_containers=$(docker ps --filter "name=wow" --format "{{.Names}}" | wc -l)
151+
152+
if [ $compose_containers -gt 0 ]; then
153+
echo ""
154+
echo "Note: Found $compose_containers containers created by other methods (Dynamic/Compose):"
155+
docker ps --filter "name=wow-clients-client" --format " {{.Names}} ({{.Status}})"
156+
echo "Use './manage-clients-dynamic.sh status' to manage these containers."
157+
return 0 # Don't treat this as an error
158+
elif [ $all_wow_containers -eq 0 ]; then
159+
echo "Warning: No WoW client containers found"
160+
return 1
161+
fi
162+
fi
132163
}
133164

134165
function clean_volumes() {

0 commit comments

Comments
 (0)