fix: Show docker errors on snowflake-proxy creation failure (#38)

- Capture and display docker run stderr instead of silently discarding it
- Suppress docker volume create / docker rm stdout leaks (snowflake-data)
- Auto-pull snowflake image if not cached locally before docker run
- Add Phase 4 to update flow: pull snowflake image alongside conduit image
- Fix same stdout leaks in start_conduit/restart_conduit/recreate_containers
This commit is contained in:
SamNet-dev
2026-02-09 18:45:41 -06:00
parent aacaa36e88
commit 19c17d1eac

View File

@@ -1126,13 +1126,19 @@ run_snowflake_container() {
local sf_mem=$(get_snowflake_memory) local sf_mem=$(get_snowflake_memory)
# Remove existing container # Remove existing container
docker rm -f "$cname" 2>/dev/null || true docker rm -f "$cname" >/dev/null 2>&1 || true
docker volume create "$vname" 2>/dev/null || true docker volume create "$vname" >/dev/null 2>&1 || true
# Pull image if not available locally
if ! docker image inspect "$SNOWFLAKE_IMAGE" >/dev/null 2>&1; then
docker pull "$SNOWFLAKE_IMAGE" 2>/dev/null || true
fi
local actual_cpus=$(awk -v req="$sf_cpus" -v cores="$(nproc 2>/dev/null || echo 1)" \ local actual_cpus=$(awk -v req="$sf_cpus" -v cores="$(nproc 2>/dev/null || echo 1)" \
'BEGIN{c=req+0; if(c>cores+0) c=cores+0; printf "%.2f",c}') 'BEGIN{c=req+0; if(c>cores+0) c=cores+0; printf "%.2f",c}')
docker run -d \ local _sf_err
_sf_err=$(docker run -d \
--name "$cname" \ --name "$cname" \
--restart unless-stopped \ --restart unless-stopped \
--log-opt max-size=10m \ --log-opt max-size=10m \
@@ -1148,7 +1154,12 @@ run_snowflake_container() {
--health-start-period=3600s \ --health-start-period=3600s \
-v "${vname}:/var/lib/snowflake" \ -v "${vname}:/var/lib/snowflake" \
"$SNOWFLAKE_IMAGE" \ "$SNOWFLAKE_IMAGE" \
-metrics -metrics-address "127.0.0.1" -metrics-port "${mport}" 2>/dev/null -metrics -metrics-address "127.0.0.1" -metrics-port "${mport}" 2>&1)
local _sf_rc=$?
if [ $_sf_rc -ne 0 ]; then
echo -e " ${DIM}Docker: ${_sf_err}${NC}" >&2
fi
return $_sf_rc
} }
stop_snowflake() { stop_snowflake() {
@@ -4092,17 +4103,17 @@ start_conduit() {
if [ "$needs_recreate" = true ]; then if [ "$needs_recreate" = true ]; then
echo "Settings changed for ${name}, recreating..." echo "Settings changed for ${name}, recreating..."
docker rm -f "$name" 2>/dev/null || true docker rm -f "$name" >/dev/null 2>&1 || true
docker volume create "$vol" 2>/dev/null || true docker volume create "$vol" >/dev/null 2>&1 || true
fix_volume_permissions $i fix_volume_permissions $i
run_conduit_container $i run_conduit_container $i
else else
# Settings unchanged — just resume the stopped container # Settings unchanged — just resume the stopped container
docker start "$name" 2>/dev/null docker start "$name" >/dev/null 2>&1
fi fi
else else
# Container doesn't exist — create fresh # Container doesn't exist — create fresh
docker volume create "$vol" 2>/dev/null || true docker volume create "$vol" >/dev/null 2>&1 || true
fix_volume_permissions $i fix_volume_permissions $i
run_conduit_container $i run_conduit_container $i
fi fi
@@ -4261,12 +4272,12 @@ restart_conduit() {
echo -e "${RED}✗ Failed to recreate ${name}${NC}" echo -e "${RED}✗ Failed to recreate ${name}${NC}"
fi fi
else else
docker start "$name" 2>/dev/null docker start "$name" >/dev/null 2>&1
echo -e "${GREEN}✓ ${name} started${NC}" echo -e "${GREEN}✓ ${name} started${NC}"
fi fi
else else
# Container doesn't exist — create fresh # Container doesn't exist — create fresh
docker volume create "$vol" 2>/dev/null || true docker volume create "$vol" >/dev/null 2>&1 || true
fix_volume_permissions $i fix_volume_permissions $i
run_conduit_container $i run_conduit_container $i
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
@@ -9903,7 +9914,7 @@ recreate_containers() {
fi fi
for i in $(seq 1 $CONTAINER_COUNT); do for i in $(seq 1 $CONTAINER_COUNT); do
local name=$(get_container_name $i) local name=$(get_container_name $i)
docker rm -f "$name" 2>/dev/null || true docker rm -f "$name" >/dev/null 2>&1 || true
done done
fix_volume_permissions fix_volume_permissions
for i in $(seq 1 $CONTAINER_COUNT); do for i in $(seq 1 $CONTAINER_COUNT); do
@@ -10006,6 +10017,17 @@ update_conduit() {
fi fi
fi fi
# --- Phase 4: Snowflake image update (if enabled) ---
if [ "$SNOWFLAKE_ENABLED" = "true" ]; then
echo ""
echo -e "${BOLD}Phase 4: Updating Snowflake proxy image...${NC}"
if docker pull "$SNOWFLAKE_IMAGE" 2>/dev/null | tail -1; then
echo -e " ${GREEN}✓ Snowflake image up to date${NC}"
else
echo -e " ${YELLOW}✗ Could not pull Snowflake image (will retry on next start)${NC}"
fi
fi
echo "" echo ""
echo -e "${GREEN}═══ Update complete ═══${NC}" echo -e "${GREEN}═══ Update complete ═══${NC}"
if [ "$script_updated" = true ]; then if [ "$script_updated" = true ]; then