Skip to content

Commit 86e7f1d

Browse files
committed
Fix monitoring stuff.
1 parent 12aef4a commit 86e7f1d

2 files changed

Lines changed: 82 additions & 1 deletion

File tree

Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,13 @@ integration: init-block
187187
@echo Ensuring apiserver stopped before the CLI integration tests...
188188
@bin/container system stop && sleep 3 && scripts/ensure-container-stopped.sh
189189
@echo Running the integration tests...
190-
bin/container system start $(SYSTEM_START_OPTS) && \
190+
@if [ -n "$(LOG_ROOT)" ]; then \
191+
echo "Starting startup monitor..."; \
192+
scripts/monitor-startup.sh "$(LOG_ROOT)/startup-monitor.log" 30 & \
193+
MONITOR_PID=$$!; \
194+
echo "Monitor running with PID $$MONITOR_PID"; \
195+
fi; \
196+
bin/container system start --timeout 60 $(SYSTEM_START_OPTS) && \
191197
echo "Starting CLI integration tests" && \
192198
{ \
193199
exit_code=0; \

scripts/monitor-startup.sh

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#! /bin/bash
2+
# Copyright © 2025-2026 Apple Inc. and the container project authors.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# https://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
# Monitor system startup for debugging CI delays
17+
# This script runs in the background and captures:
18+
# 1. Extended attributes on binaries (quarantine checks)
19+
# 2. launchd service state
20+
# 3. Process table every second
21+
22+
LOG_FILE="${1:-/tmp/startup-monitor.log}"
23+
DURATION="${2:-30}"
24+
25+
# Ensure the log directory exists
26+
LOG_DIR=$(dirname "$LOG_FILE")
27+
mkdir -p "$LOG_DIR"
28+
29+
# Redirect all output to log file
30+
exec > "$LOG_FILE" 2>&1
31+
32+
echo "=== Startup Monitor Started at $(date -u +"%Y-%m-%dT%H:%M:%SZ") ==="
33+
echo
34+
35+
# Check for quarantine attributes on binaries
36+
echo "=== Extended Attributes on Binaries ==="
37+
for binary in bin/container-apiserver \
38+
libexec/container/plugins/container-network-vmnet/bin/container-network-vmnet \
39+
libexec/container/plugins/container-runtime-linux/bin/container-runtime-linux \
40+
libexec/container/plugins/container-core-images/bin/container-core-images; do
41+
if [ -f "$binary" ]; then
42+
echo "--- $binary ---"
43+
xattr -l "$binary" 2>&1 || echo "No extended attributes or error reading xattr"
44+
fi
45+
done
46+
echo
47+
48+
# Monitor loop
49+
echo "=== Process and Service Monitoring (every 1 second for ${DURATION}s) ==="
50+
for i in $(seq 1 $DURATION); do
51+
echo "--- Snapshot $i at $(date -u +"%Y-%m-%dT%H:%M:%SZ") ---"
52+
53+
# Capture container-related processes
54+
echo "Container processes:"
55+
ps -ef | grep -E 'container-apiserver|container-network-vmnet|container-runtime|launchd' | grep -v grep || echo "No container processes found"
56+
57+
# Check launchd service state for network plugin
58+
echo
59+
echo "Launchd service state:"
60+
DOMAIN=$(launchctl managername 2>/dev/null | tr '[:upper:]' '[:lower:]' | sed 's/aqua/gui/' | sed "s/background/user/" | sed "s/system/system/" )
61+
if [ "$DOMAIN" = "gui" ] || [ "$DOMAIN" = "user" ]; then
62+
DOMAIN="${DOMAIN}/$(id -u)"
63+
fi
64+
65+
# Try to print state for default network service
66+
launchctl print "${DOMAIN}/com.apple.container.network.container-network-vmnet.default" 2>&1 || echo "Service not registered yet"
67+
68+
echo
69+
echo "---"
70+
echo
71+
72+
sleep 1
73+
done
74+
75+
echo "=== Startup Monitor Ended at $(date -u +"%Y-%m-%dT%H:%M:%SZ") ==="

0 commit comments

Comments
 (0)