# Firefly Issues - Complete Analysis

**Date**: 2026-01-02  
**Status**: ⚠️ **ALL ISSUES IDENTIFIED**  
**Containers**: VMID 6200 (r630-02), VMID 6201 (ml110)

---

## Complete Issue Summary

### VMID 6200 (firefly-1) - r630-02

#### 🔴 **CRITICAL ISSUE #1: Port 5001 Conflict**

**Problem**: 
- `firefly-core` cannot start because port 5001 is already allocated by `firefly-ipfs`
- Error: `Bind for 0.0.0.0:5001 failed: port is already allocated`

**Current Port Usage**:
- `firefly-ipfs`: Using port 5001 (IPFS API)
- `firefly-core`: Trying to use port 5001 (CONFLICT)

**Root Cause**:
In docker-compose.yml, both services are configured to use port 5001:
- `firefly-ipfs` needs port 5001 for IPFS API
- `firefly-core` is incorrectly configured to also use port 5001

**Fix Required**:
Remove port 5001 from `firefly-core` ports configuration. Firefly-core should only expose port 5000 (API port). The IPFS API is accessed internally via Docker network, not through host port mapping.

**Current Configuration** (WRONG):
```yaml
firefly-core:
  ports:
    - "5000:5000"  # Firefly API - CORRECT
    - "5001:5001"  # CONFLICT - Should be removed
```

**Correct Configuration**:
```yaml
firefly-core:
  ports:
    - "5000:5000"  # Firefly API only
  # Port 5001 removed - IPFS is accessed internally
```

#### ⚠️ **ISSUE #2: Systemd Service Failure**

**Problem**: 
- Service has failed 10+ times
- Systemd has disabled auto-restart due to repeated failures
- Service status: `inactive (dead)`

**Root Cause**: 
- Caused by port conflict (Issue #1)
- Service cannot start, so systemd keeps retrying until limit reached

**Fix Required**: 
- Fix port conflict first
- Reset failed state: `systemctl reset-failed firefly.service`
- Start service: `systemctl start firefly.service`

#### ⚠️ **ISSUE #3: firefly-core Container Status**

**Problem**: 
- Container is in "Created" state but not running
- Cannot start due to port conflict

**Current Status**:
- ✅ `firefly-postgres`: Up and running
- ✅ `firefly-ipfs`: Up and healthy (using port 5001)
- ❌ `firefly-core`: Created but cannot start

**Fix Required**: 
- Remove the created container: `docker rm firefly-core`
- Fix port conflict in docker-compose.yml
- Restart service to create new container

---

### VMID 6201 (firefly-ali-1) - ml110

#### 🔴 **CRITICAL ISSUE #1: Container Stopped**

**Problem**: 
- Container is not running
- Status: `stopped`

**Impact**: 
- Cannot access container to check Firefly installation
- All services unavailable

**Fix Required**: 
- Start container: `pct start 6201`

#### 🔴 **CRITICAL ISSUE #2: Firefly Not Installed**

**Problem**: 
- `/opt/firefly` directory does not exist
- Firefly is not installed in this container

**Evidence**:
- Directory check: `Directory not found`
- No docker-compose.yml
- No Docker containers
- No systemd service

**Fix Required**: 
- Complete Firefly installation:
  1. Install Docker and docker-compose
  2. Create `/opt/firefly` directory
  3. Create docker-compose.yml
  4. Create systemd service
  5. Start Firefly

#### ⚠️ **ISSUE #3: No Systemd Service**

**Problem**: 
- No Firefly systemd service unit found
- Service not configured

**Fix Required**: 
- Create systemd service unit similar to VMID 6200
- Enable service: `systemctl enable firefly.service`

#### ⚠️ **ISSUE #4: Docker May Not Be Installed**

**Problem**: 
- No Docker containers found
- Docker may not be installed or not accessible

**Fix Required**: 
- Verify Docker installation
- Install if missing: `apt-get install -y docker.io docker-compose`
- Start Docker service: `systemctl start docker`

---

## Detailed Issue Breakdown

### VMID 6200 Issues

| # | Issue | Severity | Status | Impact |
|---|-------|----------|--------|--------|
| 1 | Port 5001 conflict | 🔴 Critical | Active | firefly-core cannot start |
| 2 | Systemd service failure | ⚠️ High | Active | Service disabled from auto-restart |
| 3 | firefly-core container stuck | ⚠️ Medium | Active | Container in "Created" state |

**Total Issues**: 3  
**Critical**: 1  
**High**: 1  
**Medium**: 1

### VMID 6201 Issues

| # | Issue | Severity | Status | Impact |
|---|-------|----------|--------|--------|
| 1 | Container stopped | 🔴 Critical | Active | Container not accessible |
| 2 | Firefly not installed | 🔴 Critical | Active | Firefly completely unavailable |
| 3 | No systemd service | ⚠️ Medium | Active | Cannot manage via systemd |
| 4 | Docker may not be installed | ⚠️ Medium | Active | Firefly cannot run without Docker |

**Total Issues**: 4  
**Critical**: 2  
**Medium**: 2

---

## Configuration Analysis

### VMID 6200 docker-compose.yml

**Current Configuration** (with issue):
```yaml
services:
  firefly-ipfs:
    image: ipfs/kubo:latest
    ports:
      - "5001:5001"  # IPFS API - CORRECT
      - "4001:4001"  # IPFS Swarm - CORRECT
      
  firefly-core:
    image: ghcr.io/hyperledger/firefly:latest
    ports:
      - "5000:5000"  # Firefly API - CORRECT
      - "5001:5001"  # CONFLICT - Should be removed
    environment:
      - FF_IPFS_API=http://ipfs:5001  # Internal access - CORRECT
```

**Issue**: 
- `firefly-core` is trying to map port 5001 to host, but it should only access IPFS internally
- IPFS is already using port 5001 on the host
- Firefly-core accesses IPFS via Docker network (`http://ipfs:5001`), not host port

**Correct Configuration**:
```yaml
firefly-core:
  ports:
    - "5000:5000"  # Only Firefly API port
  # Remove port 5001 mapping
  environment:
    - FF_IPFS_API=http://ipfs:5001  # Internal access via Docker network
```

---

## Fix Priority

### Immediate (VMID 6200)

1. **Fix port conflict** (5 minutes)
   - Edit docker-compose.yml
   - Remove port 5001 from firefly-core
   - Remove stuck container
   - Restart service

2. **Reset systemd service** (1 minute)
   - Reset failed state
   - Start service
   - Verify it starts successfully

### Short-term (VMID 6201)

1. **Start container** (1 minute)
   - `pct start 6201`

2. **Install Firefly** (30 minutes)
   - Install Docker if needed
   - Create Firefly directory structure
   - Create docker-compose.yml
   - Create systemd service
   - Start Firefly

---

## Verification Checklist

### After Fixing VMID 6200

- [ ] Port 5001 conflict resolved
- [ ] firefly-core container running
- [ ] Systemd service active
- [ ] All 3 containers running (postgres, ipfs, firefly-core)
- [ ] Firefly API accessible on port 5000
- [ ] No port conflicts

### After Fixing VMID 6201

- [ ] Container running
- [ ] Docker installed and running
- [ ] Firefly directory exists
- [ ] docker-compose.yml configured
- [ ] Systemd service created and enabled
- [ ] All Firefly containers running
- [ ] Firefly API accessible

---

**Last Updated**: 2026-01-02  
**Analysis Script**: `scripts/analyze-firefly-issues.sh`  
**Total Issues Identified**: 7 (3 for VMID 6200, 4 for VMID 6201)  
**Critical Issues**: 3  
**Status**: ⚠️ **ALL ISSUES IDENTIFIED - FIXES REQUIRED**
