Skip to content

Commit 37dec7c

Browse files
author
Bob Gregor
committed
feat: Add comprehensive system validation for new developers
- Validate OS compatibility (macOS/Linux, Windows guidance) - Check memory, disk space, and virtualization - Provide install guidance for missing tools (crc, jq) - Warn about port conflicts and system requirements - Document remaining assumptions (internet, VPN, corporate networks) Result: Much more robust onboarding experience with helpful error messages
1 parent 94d89e6 commit 37dec7c

File tree

2 files changed

+118
-6
lines changed

2 files changed

+118
-6
lines changed

components/scripts/local-dev/README.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
brew install crc
1111

1212
# Get Red Hat pull secret (free account):
13-
# 1. Visit: https://console.redhat.com/openshift/create/local
13+
# 1. Visit: https://console.redhat.com/openshift/create/local
1414
# 2. Download to ~/.crc/pull-secret.json
15-
# 3. Run: crc setup
15+
# That's it! The script handles crc setup and configuration automatically.
1616
```
1717

1818
### 2. Start Development Environment
@@ -57,10 +57,14 @@ oc get pods -n vteam-dev # Check pod status
5757

5858
## System Requirements
5959

60-
- **CPU**: 4 cores, **RAM**: 11GB, **Disk**: 50GB
61-
- **OS**: macOS 10.15+ or Linux with KVM
60+
- **CPU**: 4 cores, **RAM**: 11GB, **Disk**: 50GB (auto-validated)
61+
- **OS**: macOS 10.15+ or Linux with KVM (auto-detected)
62+
- **Internet**: Download access for images (~2GB first time)
63+
- **Network**: No VPN conflicts with CRC networking
6264
- **Reduce if needed**: `CRC_CPUS=2 CRC_MEMORY=6144 make dev-start`
6365

66+
*Note: The script automatically validates resources and provides helpful guidance.*
67+
6468
## Common Issues & Fixes
6569

6670
**CRC won't start:**
@@ -80,9 +84,14 @@ CRC_MEMORY=6144 make dev-start
8084

8185
**Complete reset:**
8286
```bash
83-
crc stop && crc delete && crc setup && make dev-start
87+
crc stop && crc delete && make dev-start
8488
```
8589

90+
**Corporate environment issues:**
91+
- **VPN**: Disable during setup if networking fails
92+
- **Proxy**: May need `HTTP_PROXY`/`HTTPS_PROXY` environment variables
93+
- **Firewall**: Ensure CRC downloads aren't blocked
94+
8695
---
8796

8897
**📖 Detailed Guides:**

components/scripts/local-dev/crc-start.sh

Lines changed: 104 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,109 @@ success() { printf "\033[0;32m%s\033[0m\n" "$*"; }
4141
need_cmd() {
4242
if ! command -v "$1" >/dev/null 2>&1; then
4343
err "Missing required command: $1"
44+
case "$1" in
45+
crc)
46+
err "Install CRC:"
47+
err " macOS: brew install crc"
48+
err " Linux: https://crc.dev/crc/getting_started/getting_started/installing/"
49+
;;
50+
jq)
51+
err "Install jq:"
52+
err " macOS: brew install jq"
53+
err " Linux: sudo apt install jq # or yum install jq"
54+
;;
55+
esac
4456
exit 1
4557
fi
4658
}
4759

60+
check_system_resources() {
61+
log "Checking system resources..."
62+
63+
# Check OS compatibility
64+
local os_name="$(uname -s)"
65+
case "$os_name" in
66+
Darwin|Linux)
67+
log "OS detected: $os_name"
68+
;;
69+
*)
70+
err "Unsupported OS: $os_name"
71+
err "CRC requires macOS or Linux. For Windows, use WSL2."
72+
exit 1
73+
;;
74+
esac
75+
76+
# Check available memory (basic check)
77+
if [[ -f /proc/meminfo ]]; then
78+
local available_mem_kb
79+
available_mem_kb=$(grep MemAvailable /proc/meminfo | awk '{print $2}')
80+
local required_mem_kb=$((CRC_MEMORY * 1024))
81+
if [[ "$available_mem_kb" -lt "$required_mem_kb" ]]; then
82+
warn "Available memory (${available_mem_kb}KB) may be insufficient for CRC (${required_mem_kb}KB)"
83+
warn "Consider reducing: CRC_MEMORY=6144 make dev-start"
84+
fi
85+
fi
86+
87+
# Check disk space in home directory
88+
local available_space_gb
89+
if command -v df >/dev/null 2>&1; then
90+
available_space_gb=$(df -h "$HOME" | awk 'NR==2 {print $4}' | sed 's/G//')
91+
if [[ "$available_space_gb" -lt "$CRC_DISK" ]] 2>/dev/null; then
92+
warn "Available disk space (~${available_space_gb}GB) may be insufficient for CRC (${CRC_DISK}GB)"
93+
warn "Consider reducing: CRC_DISK=30 make dev-start"
94+
fi
95+
fi
96+
97+
# Check virtualization (basic check for Linux)
98+
if [[ -f /proc/cpuinfo ]] && ! grep -q -E '(vmx|svm)' /proc/cpuinfo; then
99+
warn "Virtualization may not be enabled. CRC requires VT-x/AMD-V."
100+
warn "Enable virtualization in BIOS/UEFI settings."
101+
fi
102+
103+
# Check if ports might be in use (basic check)
104+
if command -v lsof >/dev/null 2>&1; then
105+
for port in 6443 443 80; do
106+
if lsof -iTCP:$port -sTCP:LISTEN >/dev/null 2>&1; then
107+
warn "Port $port appears to be in use - may conflict with CRC"
108+
fi
109+
done
110+
fi
111+
}
112+
48113
#########################
49114
# CRC Setup (from original)
50115
#########################
116+
check_crc_setup() {
117+
# Check if CRC has been set up
118+
if ! crc version >/dev/null 2>&1; then
119+
err "CRC not properly installed or not in PATH"
120+
exit 1
121+
fi
122+
123+
# Check if pull secret is configured
124+
local pull_secret_path="$HOME/.crc/pull-secret.json"
125+
if [[ ! -f "$pull_secret_path" ]]; then
126+
err "Pull secret not found. You need to:"
127+
err "1. Get your pull secret from https://console.redhat.com/openshift/create/local"
128+
err "2. Save it to $pull_secret_path"
129+
exit 1
130+
fi
131+
132+
# Configure CRC if not already done
133+
if ! crc config get enable-cluster-monitoring >/dev/null 2>&1; then
134+
log "Running initial CRC setup..."
135+
crc setup
136+
fi
137+
138+
# Apply resource configuration
139+
log "Configuring CRC resources (${CRC_CPUS} CPUs, ${CRC_MEMORY}MB RAM, ${CRC_DISK}GB disk)..."
140+
crc config set cpus "$CRC_CPUS" >/dev/null
141+
crc config set memory "$CRC_MEMORY" >/dev/null
142+
crc config set disk-size "$CRC_DISK" >/dev/null
143+
crc config set pull-secret-file "$pull_secret_path" >/dev/null
144+
crc config set enable-cluster-monitoring false >/dev/null
145+
}
146+
51147
ensure_crc_cluster() {
52148
local crc_status
53149
crc_status=$(crc status -o json 2>/dev/null | jq -r '.crcStatus // "Stopped"' 2>/dev/null || echo "Stopped")
@@ -171,10 +267,17 @@ EOF
171267
log "Checking prerequisites..."
172268
need_cmd crc
173269
need_cmd jq
174-
need_cmd oc
270+
271+
# Optional tools with warnings
272+
if ! command -v git >/dev/null 2>&1; then
273+
warn "Git not found - needed if you haven't cloned the repo yet"
274+
fi
275+
276+
check_system_resources
175277

176278
log "Starting CRC-based local development environment..."
177279

280+
check_crc_setup
178281
ensure_crc_cluster
179282
configure_oc_context
180283
ensure_project

0 commit comments

Comments
 (0)