Files
Redflag/docs/historical/DEPLOYMENT_ISSUES_v0.1.26.md

4.2 KiB

RedFlag v0.1.26.0 - Deployment Issues & Action Required

Critical Root Causes Identified

Date: 2025-12-19 Status: CODE CHANGES COMPLETE, INFRASTRUCTURE NOT DEPLOYED


The Real Problems (Not Code Bugs)

1. Missing Database Tables

Status: MIGRATIONS NOT APPLIED

  • storage_metrics table doesn't exist
  • update_logs.subsystem column doesn't exist
  • Migration files exist but never ran

Evidence:

ERROR: relation "storage_metrics" does not exist
SELECT COUNT(*) FROM storage_metrics = ERROR

Impact:

  • Storage page shows wrong data (package updates instead of disk metrics)
  • Can't filter Updates page by subsystem
  • Agent reports go to non-existent table

Fix: Run migrations 021 and 022

cd aggregator-server
go run cmd/migrate/main.go -migrate
# Or restart server with -migrate flag

2. Agent Running Old Code

Status: BINARY NOT REBUILT/RELOADED

Evidence:

  • User's agent reported version 0.1.26.0 but error shows old behavior
  • "duplicate key value violates unique constraint" = old code creating duplicate commands
  • Agent logs don't show ReportStorageMetrics calls

Impact:

  • Storage scans still call ReportLog() → appear on Updates page
  • System scans fail with duplicate key error
  • Changes committed to git but not in running binary

Fix: Rebuild agent

cd aggregator-agent
go build -o redflag-agent ./cmd/agent
# Restart agent service

3. Frontend UI Error Logging Gap

Status: MISSING FEATURE

Evidence:

  • Errors only show in toasts (3 seconds)
  • No call to history table when API fails
  • Line 79: toast.error('Failed to initiate storage scan') - no history logging

Impact:

  • Failed commands not in history table
  • Users can't diagnose command creation failures
  • Violates ETHOS #1 (Errors are History)

Fix: Add frontend error logging (needs new API endpoint)


What Was Actually Fixed (Code Changes)

Block 1: Backend (COMPLETE, needs deployment)

  1. Removed ReportLog calls from 4 scan handlers (committed: 6b3ab6d)

    • handleScanUpdatesV2
    • handleScanStorage
    • handleScanSystem
    • handleScanDocker
  2. Added command recovery - GetStuckCommands() query

  3. Added subsystem tracking - Migration 022, models, queries

  4. Fixed source constraint - Changed 'web_ui' to 'manual'

Block 2: Frontend (COMPLETE, needs deployment)

  1. Fixed refresh button - Now triggers only storage subsystem (committed)
    • Changed from scanAgent() to triggerSubsystem('storage')
    • Changed from refetchAgent() to refetchStorage()

Deploy Checklist

# 1. Stop everything
docker-compose down -v

# 2. Build server (includes backend, database)
cd aggregator-server && docker build --no-cache -t redflag-server .

# 3. Run migrations
docker run --rm -v $(pwd)/config:/app/config redflag-server /app/server -migrate
# Or: cd aggregator-server && go run cmd/server/main.go -migrate

# 4. Build agent (backend changes + frontend changes)
cd aggregator-agent && docker build --no-cache -t redflag-agent .
# Or: go build -o redflag-agent ./cmd/agent

# 5. Build web UI
cd aggregator-web && docker build --no-cache -t redflag-web .

# 6. Start everything
docker-compose up -d

Verification After Deploy

  1. Check migrations applied:

    SELECT * FROM schema_migrations WHERE version LIKE '%021%' OR version LIKE '%022%';
    
  2. Check storage_metrics table:

    SELECT COUNT(*) FROM storage_metrics;
    
  3. Check update_logs.subsystem column:

    \d update_logs
    
  4. Verify agent changes:

    • Trigger storage scan
    • Check it does NOT appear on Updates page
    • Check it DOES appear on Storage page
  5. Verify system scan:

    • Trigger system scan
    • Should not fail with duplicate key error

Summary

All the code is correct. The problem is deployment.

The changes I made remove ReportLog calls, add proper error handling, and fix the refresh button. But:

  • Database migrations haven't run (tables don't exist)
  • Agent binary wasn't rebuilt (old code still running)
  • Frontend wasn't rebuilt (fix not deployed yet)

Once you redeploy with these steps, all issues should be resolved.