Fix BZZZ deployment system and deploy to ironwood

## Major Fixes:
1. **Config Download Fixed**: Frontend now sends machine_ip (snake_case) instead of machineIP (camelCase)
2. **Config Generation Fixed**: GenerateConfigForMachineSimple now provides valid whoosh_api.base_url
3. **Validation Fixed**: Deployment validation now checks for agent:, whoosh_api:, ai: (complex structure)
4. **Hardcoded Values Removed**: No more personal names/paths in deployment system

## Deployment Results:
-  Config validation passes: "Configuration loaded and validated successfully"
-  Remote deployment works: BZZZ starts in normal mode on deployed machines
-  ironwood (192.168.1.113) successfully deployed with systemd service
-  P2P networking operational with peer discovery

## Technical Details:
- Updated api/setup_manager.go: Fixed config generation and validation logic
- Updated main.go: Fixed handleDownloadConfig to return proper JSON response
- Updated ServiceDeployment.tsx: Fixed field name for API compatibility
- Added version tracking system

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
anthonyrawlins
2025-08-31 21:49:05 +10:00
parent be761cfe20
commit da1b42dc33
14 changed files with 923 additions and 285 deletions

View File

@@ -14,7 +14,8 @@ import {
CloudArrowDownIcon,
Cog6ToothIcon,
XMarkIcon,
ComputerDesktopIcon
ComputerDesktopIcon,
ArrowDownTrayIcon
} from '@heroicons/react/24/outline'
interface Machine {
@@ -303,9 +304,10 @@ export default function ServiceDeployment({
// Show actual backend steps if provided
if (result.steps) {
result.steps.forEach((step: string) => {
logs.push(step)
addConsoleLog(`📋 ${step}`)
result.steps.forEach((step: any) => {
const stepText = `${step.name}: ${step.status}${step.error ? ` - ${step.error}` : ''}${step.duration ? ` (${step.duration})` : ''}`
logs.push(stepText)
addConsoleLog(`📋 ${stepText}`)
})
}
addConsoleLog(`🎉 CHORUS:agents service is now running on ${machine?.hostname}`)
@@ -378,6 +380,50 @@ export default function ServiceDeployment({
})
}
const downloadConfig = async (machineId: string) => {
try {
const machine = machines.find(m => m.id === machineId)
if (!machine) return
const response = await fetch('/api/setup/download-config', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
machine_ip: machine.ip,
config: {
ports: {
api: configData?.network?.bzzzPort || 8080,
mcp: configData?.network?.mcpPort || 3000,
webui: configData?.network?.webUIPort || 8080,
p2p: configData?.network?.p2pPort || 7000
},
security: configData?.security,
autoStart: config.autoStart
}
})
})
if (response.ok) {
const result = await response.json()
// Create blob and download
const blob = new Blob([result.configYAML], { type: 'text/yaml' })
const url = URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = url
link.download = `bzzz-config-${machine.hostname}-${machine.ip}.yaml`
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
URL.revokeObjectURL(url)
} else {
console.error('Failed to download config:', await response.text())
}
} catch (error) {
console.error('Config download error:', error)
}
}
const getStatusIcon = (status: string) => {
switch (status) {
case 'connected': return <CheckCircleIcon className="h-5 w-5 text-eucalyptus-600" />
@@ -481,36 +527,31 @@ export default function ServiceDeployment({
<table className="min-w-full divide-y divide-gray-200">
<thead className="bg-gray-50">
<tr>
<th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Select
<th className="px-2 py-2 text-left text-xs font-medium text-gray-500 uppercase tracking-wider sm:px-4 sm:py-3">
<span className="sr-only sm:not-sr-only">Select</span>
<span className="sm:hidden">✓</span>
</th>
<th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Machine
<th className="px-2 py-2 text-left text-xs font-medium text-gray-500 uppercase tracking-wider sm:px-4 sm:py-3">
Machine / Connection
</th>
<th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
<th className="px-2 py-2 text-left text-xs font-medium text-gray-500 uppercase tracking-wider sm:px-4 sm:py-3 hidden md:table-cell">
Operating System
</th>
<th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
IP Address
</th>
<th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
SSH Status
</th>
<th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
<th className="px-2 py-2 text-left text-xs font-medium text-gray-500 uppercase tracking-wider sm:px-4 sm:py-3">
Deploy Status
</th>
<th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
<th className="px-2 py-2 text-left text-xs font-medium text-gray-500 uppercase tracking-wider sm:px-4 sm:py-3">
Actions
</th>
<th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Remove
<th className="px-1 py-2 text-left text-xs font-medium text-gray-500 uppercase tracking-wider sm:px-2 sm:py-3">
<span className="sr-only">Remove</span>
</th>
</tr>
</thead>
<tbody className="bg-white divide-y divide-gray-200">
{machines.map((machine) => (
<tr key={machine.id} className={machine.selected ? 'bg-blue-50' : ''}>
<td className="px-6 py-4 whitespace-nowrap">
<td className="px-2 py-2 whitespace-nowrap sm:px-4 sm:py-3">
<input
type="checkbox"
checked={machine.selected}
@@ -518,118 +559,130 @@ export default function ServiceDeployment({
className="h-4 w-4 text-bzzz-primary focus:ring-bzzz-primary border-gray-300 rounded"
/>
</td>
<td className="px-6 py-4 whitespace-nowrap">
<td className="px-2 py-2 whitespace-nowrap sm:px-4 sm:py-3">
<div>
<div className="text-sm font-medium text-gray-900">{machine.hostname}</div>
{machine.systemInfo && (
<div className="text-xs text-gray-500">
{machine.systemInfo.cpu} cores • {machine.systemInfo.memory}GB RAM • {machine.systemInfo.disk}GB disk
<div className="text-xs text-gray-500 space-y-1">
<div className="inline-flex items-center space-x-2">
<span>{machine.ip}</span>
<span className="inline-flex items-center" title={`SSH Status: ${machine.sshStatus.replace('_', ' ')}`}>
{getStatusIcon(machine.sshStatus)}
</span>
</div>
)}
</div>
</td>
<td className="px-6 py-4 whitespace-nowrap">
<div className="text-sm text-gray-900">{machine.os}</div>
<div className="text-xs text-gray-500">{machine.osVersion}</div>
</td>
<td className="px-6 py-4 whitespace-nowrap text-sm text-gray-900">
{machine.ip}
</td>
<td className="px-6 py-4 whitespace-nowrap">
<div className="flex items-center">
{getStatusIcon(machine.sshStatus)}
<span className="ml-2 text-sm text-gray-900 capitalize">
{machine.sshStatus.replace('_', ' ')}
</span>
</div>
</td>
<td className="px-6 py-4 whitespace-nowrap">
<div className="flex items-center">
{getStatusIcon(machine.deployStatus)}
<div className="ml-2 flex-1">
<div className="text-sm text-gray-900 capitalize">
{machine.deployStatus.replace('_', ' ')}
</div>
{machine.deployStatus === 'installing' && (
<div className="mt-1">
<div className="text-xs text-gray-500 mb-1">
{machine.deployStep || 'Deploying...'}
</div>
<div className="w-full bg-gray-200 rounded-full h-2">
<div
className="bg-blue-500 h-2 rounded-full transition-all duration-300"
style={{ width: `${machine.deployProgress || 0}%` }}
/>
</div>
<div className="text-xs text-gray-500 mt-1">
{machine.deployProgress || 0}%
</div>
{machine.systemInfo && (
<div className="text-gray-400">
{machine.systemInfo.cpu}c • {machine.systemInfo.memory}GB • {machine.systemInfo.disk}GB
</div>
)}
</div>
</div>
</td>
<td className="px-6 py-4 whitespace-nowrap text-sm font-medium space-x-2">
{machine.id !== 'localhost' && machine.sshStatus !== 'connected' && (
<button
type="button"
onClick={() => testSSHConnection(machine.id)}
className="text-blue-600 hover:text-blue-900"
disabled={machine.sshStatus === 'testing'}
>
Test SSH
</button>
)}
{machine.sshStatus === 'connected' && machine.deployStatus === 'not_deployed' && (
<button
type="button"
onClick={() => deployToMachine(machine.id)}
className="text-eucalyptus-600 hover:text-eucalyptus-600"
>
Install
</button>
)}
{machine.sshStatus === 'connected' && machine.deployStatus === 'error' && (
<button
type="button"
onClick={() => deployToMachine(machine.id)}
className="text-amber-600 hover:text-amber-700 mr-2"
title="Retry deployment"
>
<ArrowPathIcon className="h-4 w-4 inline mr-1" />
Retry
</button>
)}
{machine.deployStatus !== 'not_deployed' && (
<>
<button
type="button"
onClick={() => setShowLogs(machine.id)}
className="text-gray-600 hover:text-gray-900 mr-2"
title="View deployment logs"
>
<DocumentTextIcon className="h-4 w-4 inline" />
</button>
<button
type="button"
onClick={() => setShowConsole(machine.id)}
className="text-blue-600 hover:text-blue-900"
title="Open deployment console"
>
<ComputerDesktopIcon className="h-4 w-4 inline" />
</button>
</>
)}
<td className="px-2 py-2 whitespace-nowrap sm:px-4 sm:py-3 hidden md:table-cell">
<div className="text-sm text-gray-900">{machine.os}</div>
<div className="text-xs text-gray-500">{machine.osVersion}</div>
</td>
<td className="px-6 py-4 whitespace-nowrap text-sm font-medium">
<td className="px-2 py-2 whitespace-nowrap sm:px-4 sm:py-3">
<div className="flex items-center">
<div className="inline-flex items-center" title={`Deploy Status: ${machine.deployStatus.replace('_', ' ')}`}>
{getStatusIcon(machine.deployStatus)}
</div>
{machine.deployStatus === 'installing' && (
<div className="ml-2 flex-1">
<div className="text-xs text-gray-500 mb-1 truncate">
{machine.deployStep || 'Deploying...'}
</div>
<div className="w-full bg-gray-200 rounded-full h-2">
<div
className="bg-blue-500 h-2 rounded-full transition-all duration-300"
style={{ width: `${machine.deployProgress || 0}%` }}
/>
</div>
<div className="text-xs text-gray-500 mt-1">
{machine.deployProgress || 0}%
</div>
</div>
)}
</div>
</td>
<td className="px-2 py-2 whitespace-nowrap text-sm font-medium sm:px-4 sm:py-3">
<div className="flex flex-wrap gap-1">
{machine.id !== 'localhost' && machine.sshStatus !== 'connected' && (
<button
type="button"
onClick={() => testSSHConnection(machine.id)}
className="text-blue-600 hover:text-blue-700 text-xs px-2 py-1 bg-blue-50 rounded"
disabled={machine.sshStatus === 'testing'}
title="Test SSH connection"
>
Test SSH
</button>
)}
{machine.sshStatus === 'connected' && machine.deployStatus === 'not_deployed' && (
<button
type="button"
onClick={() => deployToMachine(machine.id)}
className="text-eucalyptus-600 hover:text-eucalyptus-700 text-xs px-2 py-1 bg-eucalyptus-50 rounded"
title="Deploy BZZZ"
>
Install
</button>
)}
{machine.sshStatus === 'connected' && machine.deployStatus === 'error' && (
<button
type="button"
onClick={() => deployToMachine(machine.id)}
className="text-amber-600 hover:text-amber-700 text-xs px-2 py-1 bg-amber-50 rounded inline-flex items-center"
title="Retry deployment"
>
<ArrowPathIcon className="h-3 w-3 mr-1" />
Retry
</button>
)}
{machine.sshStatus === 'connected' && (
<button
type="button"
onClick={() => downloadConfig(machine.id)}
className="text-purple-600 hover:text-purple-700 text-xs px-2 py-1 bg-purple-50 rounded inline-flex items-center"
title="Download configuration file"
>
<ArrowDownTrayIcon className="h-3 w-3 mr-1" />
<span className="hidden sm:inline">Config</span>
</button>
)}
{machine.deployStatus !== 'not_deployed' && (
<>
<button
type="button"
onClick={() => setShowLogs(machine.id)}
className="text-gray-600 hover:text-gray-700 text-xs px-2 py-1 bg-gray-50 rounded inline-flex items-center"
title="View deployment logs"
>
<DocumentTextIcon className="h-3 w-3 mr-1" />
<span className="hidden sm:inline">Logs</span>
</button>
<button
type="button"
onClick={() => setShowConsole(machine.id)}
className="text-blue-600 hover:text-blue-700 text-xs px-2 py-1 bg-blue-50 rounded inline-flex items-center"
title="Open deployment console"
>
<ComputerDesktopIcon className="h-3 w-3 mr-1" />
<span className="hidden sm:inline">Console</span>
</button>
</>
)}
</div>
</td>
<td className="px-1 py-2 whitespace-nowrap text-sm font-medium sm:px-2 sm:py-3">
{machine.id !== 'localhost' && (
<button
type="button"
onClick={() => removeMachine(machine.id)}
className="text-red-600 hover:text-red-900 p-1 rounded hover:bg-red-50"
className="text-red-600 hover:text-red-700 p-1 rounded hover:bg-red-50"
title="Remove machine"
>
<XMarkIcon className="h-4 w-4" />