Files
Sankofa/scripts/fix-and-create-all-osds.sh
defiQUG 33d50fb91e
Some checks failed
API CI / API Lint (push) Successful in 47s
API CI / API Type Check (push) Failing after 47s
API CI / API Test (push) Successful in 1m0s
API CI / API Build (push) Failing after 50s
API CI / Build Docker Image (push) Has been skipped
Build Crossplane Provider / build (push) Failing after 5m51s
CD Pipeline / Deploy to Staging (push) Failing after 29s
CI Pipeline / Lint and Type Check (push) Failing after 36s
CI Pipeline / Build (push) Has been skipped
CI Pipeline / Test Backend (push) Failing after 1m33s
CI Pipeline / Test Frontend (push) Failing after 30s
CI Pipeline / Security Scan (push) Failing after 1m16s
Crossplane Provider CI / Go Test (push) Failing after 3m23s
Crossplane Provider CI / Go Lint (push) Failing after 7m27s
Crossplane Provider CI / Go Build (push) Failing after 3m27s
Deploy to Staging / Deploy to Staging (push) Failing after 30s
Portal CI / Portal Lint (push) Failing after 21s
Portal CI / Portal Type Check (push) Failing after 21s
Portal CI / Portal Test (push) Failing after 21s
Portal CI / Portal Build (push) Failing after 22s
Test Suite / frontend-tests (push) Failing after 30s
Test Suite / api-tests (push) Failing after 49s
Test Suite / blockchain-tests (push) Failing after 30s
Type Check / type-check (map[directory:. name:root]) (push) Failing after 23s
Type Check / type-check (map[directory:api name:api]) (push) Failing after 21s
Type Check / type-check (map[directory:portal name:portal]) (push) Failing after 19s
Validate Configuration Files / validate (push) Failing after 1m52s
CD Pipeline / Deploy to Production (push) Has been skipped
chore: consolidate local WIP (repo cleanup 20260707)
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-07 09:41:34 -07:00

192 lines
6.0 KiB
Bash
Executable File

#!/bin/bash
# Complete script to fix bootstrap keyring and create OSDs on all 6 drives
# Run on R630-01 as root
set -e
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
DRIVES=("sdc" "sdd" "sde" "sdf" "sdg" "sdh")
echo "=========================================="
echo "Fix Bootstrap Keyring and Create All OSDs"
echo "=========================================="
echo ""
# Check if running as root
if [ "$EUID" -ne 0 ]; then
echo -e "${RED}ERROR: Please run as root${NC}"
exit 1
fi
echo -e "${BLUE}=== Step 1: Check Ceph Cluster Connectivity ===${NC}"
echo "-----------------------------------"
if ! command -v ceph &> /dev/null; then
echo -e "${RED}Ceph command not found. Please install ceph-common.${NC}"
exit 1
fi
echo "Testing Ceph connectivity..."
if ceph health &>/dev/null; then
echo -e "${GREEN} ✓ Ceph cluster is accessible${NC}"
ceph health
else
echo -e "${YELLOW} ⚠ Ceph cluster may not be fully accessible${NC}"
echo " Attempting to continue anyway..."
fi
echo ""
echo -e "${BLUE}=== Step 2: Fix Bootstrap Keyring ===${NC}"
echo "-----------------------------------"
BOOTSTRAP_DIR="/var/lib/ceph/bootstrap-osd"
BOOTSTRAP_KEYRING="$BOOTSTRAP_DIR/ceph.keyring"
# Create directory
mkdir -p "$BOOTSTRAP_DIR"
# Try to get bootstrap keyring from cluster
echo "Attempting to get bootstrap keyring from cluster..."
if ceph auth get client.bootstrap-osd -o "$BOOTSTRAP_KEYRING" 2>/dev/null; then
echo -e "${GREEN} ✓ Retrieved bootstrap keyring from cluster${NC}"
elif ceph auth list 2>/dev/null | grep -q "client.bootstrap-osd"; then
echo " Bootstrap keyring exists in cluster, exporting..."
ceph auth export client.bootstrap-osd -o "$BOOTSTRAP_KEYRING" 2>/dev/null || \
ceph auth get client.bootstrap-osd -o "$BOOTSTRAP_KEYRING" 2>/dev/null || true
else
echo -e "${YELLOW} ⚠ Bootstrap keyring not found in cluster${NC}"
echo " Attempting to create it..."
ceph auth add client.bootstrap-osd mon 'allow profile bootstrap-osd' -i "$BOOTSTRAP_KEYRING" 2>/dev/null || \
echo -e "${YELLOW} Could not create bootstrap keyring automatically${NC}"
fi
# Check if keyring exists now
if [ -f "$BOOTSTRAP_KEYRING" ]; then
echo -e "${GREEN} ✓ Bootstrap keyring exists: $BOOTSTRAP_KEYRING${NC}"
ls -lh "$BOOTSTRAP_KEYRING"
else
echo -e "${YELLOW} ⚠ Bootstrap keyring still not found${NC}"
echo " Will try alternative methods..."
fi
echo ""
echo -e "${BLUE}=== Step 3: Check for pveceph (Proxmox Ceph Tool) ===${NC}"
echo "-----------------------------------"
USE_PVECEPH=false
if command -v pveceph &> /dev/null; then
echo -e "${GREEN} ✓ pveceph found - will use Proxmox Ceph tool${NC}"
USE_PVECEPH=true
else
echo -e "${YELLOW} pveceph not found - will use ceph-volume${NC}"
fi
echo ""
echo -e "${BLUE}=== Step 4: Create OSDs on All Drives ===${NC}"
echo "-----------------------------------"
osd_count=0
failed_drives=()
for drive in "${DRIVES[@]}"; do
if [ ! -b "/dev/$drive" ]; then
echo -e "${YELLOW} /dev/$drive not found, skipping...${NC}"
continue
fi
echo -e "${BLUE} Creating OSD on /dev/$drive...${NC}"
# Try pveceph first if available
if [ "$USE_PVECEPH" = true ]; then
if pveceph create "/dev/$drive" 2>&1 | tee /tmp/ceph-osd-${drive}.log; then
echo -e "${GREEN} ✓ OSD created on /dev/$drive (using pveceph)${NC}"
osd_count=$((osd_count + 1))
continue
else
echo -e "${YELLOW} pveceph failed, trying ceph-volume...${NC}"
fi
fi
# Try ceph-volume
if ceph-volume lvm create --data "/dev/$drive" 2>&1 | tee /tmp/ceph-osd-${drive}.log; then
echo -e "${GREEN} ✓ OSD created on /dev/$drive${NC}"
osd_count=$((osd_count + 1))
else
echo -e "${YELLOW} ⚠ OSD creation had issues${NC}"
failed_drives+=("$drive")
# Check if OSD was partially created
sleep 2
if ceph osd tree 2>/dev/null | grep -q "osd\."; then
echo " Checking if OSD exists in cluster..."
# Count OSDs before and after to see if one was created
fi
fi
echo ""
done
echo "=========================================="
echo -e "${GREEN}OSD Creation Summary${NC}"
echo "=========================================="
echo ""
echo "Successfully created: $osd_count OSD(s) out of ${#DRIVES[@]} drives"
if [ ${#failed_drives[@]} -gt 0 ]; then
echo -e "${YELLOW}Failed drives: ${failed_drives[@]}${NC}"
echo "Check logs in /tmp/ceph-osd-*.log for details"
fi
echo ""
echo -e "${BLUE}=== Step 5: Verify Ceph Status ===${NC}"
echo "-----------------------------------"
echo "OSD Tree:"
ceph osd tree 2>/dev/null || echo -e "${YELLOW}Cannot get OSD tree${NC}"
echo ""
echo "Ceph Health:"
ceph health 2>/dev/null || echo -e "${YELLOW}Cannot get health${NC}"
echo ""
echo "OSD Details:"
ceph osd df 2>/dev/null || echo -e "${YELLOW}Cannot get OSD details${NC}"
echo ""
echo "Current OSD count:"
OSD_COUNT=$(ceph osd tree 2>/dev/null | grep -c "osd\." || echo "0")
echo " Total OSDs: $OSD_COUNT"
if [ "$OSD_COUNT" -ge 3 ]; then
echo -e "${GREEN} ✓ SUCCESS: Have 3+ OSDs (fixes TOO_FEW_OSDS error)${NC}"
else
echo -e "${YELLOW} ⚠ Still need more OSDs (currently have $OSD_COUNT, need 3+)${NC}"
fi
echo ""
echo "=========================================="
if [ "$osd_count" -gt 0 ]; then
echo -e "${GREEN}Process Complete!${NC}"
echo ""
echo "Next steps:"
echo "1. Monitor Ceph health: ceph health detail"
echo "2. Check for remaining issues: ceph health"
echo "3. If some OSDs failed, check logs: /tmp/ceph-osd-*.log"
else
echo -e "${YELLOW}No OSDs were created${NC}"
echo ""
echo "Troubleshooting:"
echo "1. Check Ceph cluster connectivity: ceph health"
echo "2. Check bootstrap keyring: ls -la $BOOTSTRAP_KEYRING"
echo "3. Check logs: /tmp/ceph-osd-*.log"
echo "4. Try manual creation: ceph-volume lvm create --data /dev/sdc"
fi
echo "=========================================="
echo ""