# Firefly Issues Analysis - VMIDs 6200 and 6201

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

---

## Executive Summary

Analysis of both Firefly containers reveals several issues:

- **VMID 6200**: Port conflict preventing firefly-core from starting
- **VMID 6201**: Container stopped, Firefly not installed

---

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

### Container Status
- **Status**: ✅ Running
- **Hostname**: firefly-1
- **IP**: DHCP
- **Storage**: thin1-r630-02:vm-6200-disk-0
- **Disk Usage**: 5% (OK)

### Issues Identified

#### 🔴 **CRITICAL: Port Conflict (Port 5001)**

**Problem**: 
- `firefly-core` container cannot start due to port conflict
- Error: `Bind for 0.0.0.0:5001 failed: port is already allocated`
- Port 5001 is already in use by `firefly-ipfs` container

**Root Cause**:
- Both `firefly-ipfs` and `firefly-core` are trying to bind to port 5001
- In docker-compose.yml:
  - `firefly-ipfs` uses: `"5001:5001"` and `"4001:4001"`
  - `firefly-core` uses: `"5000:5000"` and `"5001:5001"` (CONFLICT)

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

**Impact**: 
- Firefly core service is not running
- Only supporting services (PostgreSQL, IPFS) are operational
- Firefly API is not accessible

#### ⚠️ **Systemd Service Failure**

**Problem**:
- Systemd service `firefly.service` is inactive
- Service has failed 10+ times
- Restart counter exceeded, service disabled from auto-restarting

**Error Messages**:
```
ERROR: for firefly-core  Cannot start service firefly-core: 
failed to set up container networking: 
driver failed programming external connectivity on endpoint firefly-core: 
Bind for 0.0.0.0:5001 failed: port is already allocated
```

**Impact**: 
- Service cannot start automatically
- Manual intervention required

#### ⚠️ **Network Connectivity**

**Problem**: 
- Network connectivity test failed
- May be related to container network configuration

**Impact**: 
- Low (container is running, but network test failed)

### What's Working

✅ Firefly directory exists: `/opt/firefly`  
✅ docker-compose.yml exists and configured  
✅ Docker image available: `ghcr.io/hyperledger/firefly:latest`  
✅ PostgreSQL container running  
✅ IPFS container running and healthy  
✅ Systemd service unit configured  

### Configuration Details

**docker-compose.yml Configuration**:
```yaml
services:
  firefly-core:
    image: ghcr.io/hyperledger/firefly:latest
    ports:
      - "5000:5000"  # Firefly API
      - "5001:5001"  # CONFLICT with firefly-ipfs
    environment:
      - FF_BLOCKCHAIN_RPC=http://192.168.11.250:8545
      - FF_BLOCKCHAIN_WS=ws://192.168.11.250:8546
      - FF_CHAIN_ID=138
      
  ipfs:
    image: ipfs/kubo:latest
    ports:
      - "5001:5001"  # CONFLICT with firefly-core
      - "4001:4001"
```

---

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

### Container Status
- **Status**: ❌ Stopped
- **Hostname**: firefly-ali-1
- **IP**: 192.168.11.57/24 (Static)
- **Storage**: local-lvm:vm-6201-disk-0,size=50G

### Issues Identified

#### 🔴 **CRITICAL: Container Stopped**

**Problem**: 
- Container is not running
- Cannot analyze Firefly installation while stopped

**Impact**: 
- Firefly service is completely unavailable
- No services running

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

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

**Impact**: 
- Firefly cannot be started
- Installation required

#### ⚠️ **No Systemd Service**

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

**Impact**: 
- Cannot manage Firefly via systemd
- Manual startup required

#### ⚠️ **No Docker Containers**

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

**Impact**: 
- Firefly cannot run (requires Docker)

### What's Missing

❌ Firefly directory: `/opt/firefly`  
❌ docker-compose.yml  
❌ Docker images  
❌ Systemd service unit  
❌ Docker containers  

---

## Summary of Issues

### VMID 6200 (firefly-1)

| Issue | Severity | Status | Fix Required |
|-------|----------|--------|--------------|
| Port 5001 conflict | 🔴 Critical | Active | Yes - Remove port 5001 from firefly-core |
| Systemd service failure | ⚠️ High | Active | Yes - Fix port conflict first |
| Network connectivity | ⚠️ Low | Active | Investigate |

**Priority**: 🔴 **HIGH** - Port conflict prevents core service from starting

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

| Issue | Severity | Status | Fix Required |
|-------|----------|--------|--------------|
| Container stopped | 🔴 Critical | Active | Yes - Start container |
| Firefly not installed | 🔴 Critical | Active | Yes - Install Firefly |
| No systemd service | ⚠️ Medium | Active | Yes - Configure service |
| No Docker containers | ⚠️ Medium | Active | Yes - Install/configure Docker |

**Priority**: 🔴 **HIGH** - Complete installation required

---

## Recommended Fixes

### For VMID 6200 (Port Conflict)

**Solution**: Remove port 5001 from firefly-core configuration

1. **Edit docker-compose.yml**:
   ```yaml
   firefly-core:
     ports:
       - "5000:5000"  # Keep only Firefly API port
       # Remove: - "5001:5001"  # This conflicts with IPFS
   ```

2. **Remove conflicting container**:
   ```bash
   docker rm firefly-core
   ```

3. **Restart service**:
   ```bash
   systemctl reset-failed firefly.service
   systemctl start firefly.service
   ```

**Expected Result**: 
- firefly-core starts successfully
- Only port 5000 exposed for Firefly API
- IPFS continues using port 5001

### For VMID 6201 (Not Installed)

**Solution**: Install Firefly from scratch

1. **Start container**:
   ```bash
   pct start 6201
   ```

2. **Install Docker** (if not installed):
   ```bash
   apt-get update
   apt-get install -y docker.io docker-compose
   ```

3. **Create Firefly directory**:
   ```bash
   mkdir -p /opt/firefly
   cd /opt/firefly
   ```

4. **Create docker-compose.yml**:
   - Use similar configuration to VMID 6200
   - Ensure no port conflicts
   - Configure for Chain ID 138

5. **Create systemd service**:
   - Similar to VMID 6200 configuration
   - Enable and start service

**Expected Result**: 
- Firefly fully installed and running
- All services operational

---

## Next Steps

1. **Immediate**: Fix port conflict on VMID 6200
2. **Short-term**: Start and install Firefly on VMID 6201
3. **Verification**: Test both Firefly instances
4. **Documentation**: Update configuration documentation

---

**Last Updated**: 2026-01-02  
**Analysis Script**: `scripts/analyze-firefly-issues.sh`  
**Status**: ⚠️ **ISSUES IDENTIFIED - FIXES REQUIRED**
