mirror of
https://github.com/chrislusf/seaweedfs
synced 2025-08-17 17:42:47 +02:00
* initial design * added simulation as tests * reorganized the codebase to move the simulation framework and tests into their own dedicated package * integration test. ec worker task * remove "enhanced" reference * start master, volume servers, filer Current Status ✅ Master: Healthy and running (port 9333) ✅ Filer: Healthy and running (port 8888) ✅ Volume Servers: All 6 servers running (ports 8080-8085) 🔄 Admin/Workers: Will start when dependencies are ready * generate write load * tasks are assigned * admin start wtih grpc port. worker has its own working directory * Update .gitignore * working worker and admin. Task detection is not working yet. * compiles, detection uses volumeSizeLimitMB from master * compiles * worker retries connecting to admin * build and restart * rendering pending tasks * skip task ID column * sticky worker id * test canScheduleTaskNow * worker reconnect to admin * clean up logs * worker register itself first * worker can run ec work and report status but: 1. one volume should not be repeatedly worked on. 2. ec shards needs to be distributed and source data should be deleted. * move ec task logic * listing ec shards * local copy, ec. Need to distribute. * ec is mostly working now * distribution of ec shards needs improvement * need configuration to enable ec * show ec volumes * interval field UI component * rename * integration test with vauuming * garbage percentage threshold * fix warning * display ec shard sizes * fix ec volumes list * Update ui.go * show default values * ensure correct default value * MaintenanceConfig use ConfigField * use schema defined defaults * config * reduce duplication * refactor to use BaseUIProvider * each task register its schema * checkECEncodingCandidate use ecDetector * use vacuumDetector * use volumeSizeLimitMB * remove remove * remove unused * refactor * use new framework * remove v2 reference * refactor * left menu can scroll now * The maintenance manager was not being initialized when no data directory was configured for persistent storage. * saving config * Update task_config_schema_templ.go * enable/disable tasks * protobuf encoded task configurations * fix system settings * use ui component * remove logs * interface{} Reduction * reduce interface{} * reduce interface{} * avoid from/to map * reduce interface{} * refactor * keep it DRY * added logging * debug messages * debug level * debug * show the log caller line * use configured task policy * log level * handle admin heartbeat response * Update worker.go * fix EC rack and dc count * Report task status to admin server * fix task logging, simplify interface checking, use erasure_coding constants * factor in empty volume server during task planning * volume.list adds disk id * track disk id also * fix locking scheduled and manual scanning * add active topology * simplify task detector * ec task completed, but shards are not showing up * implement ec in ec_typed.go * adjust log level * dedup * implementing ec copying shards and only ecx files * use disk id when distributing ec shards 🎯 Planning: ActiveTopology creates DestinationPlan with specific TargetDisk 📦 Task Creation: maintenance_integration.go creates ECDestination with DiskId 🚀 Task Execution: EC task passes DiskId in VolumeEcShardsCopyRequest 💾 Volume Server: Receives disk_id and stores shards on specific disk (vs.store.Locations[req.DiskId]) 📂 File System: EC shards and metadata land in the exact disk directory planned * Delete original volume from all locations * clean up existing shard locations * local encoding and distributing * Update docker/admin_integration/EC-TESTING-README.md Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> * check volume id range * simplify * fix tests * fix types * clean up logs and tests --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
381 lines
No EOL
14 KiB
Text
381 lines
No EOL
14 KiB
Text
package app
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/seaweedfs/seaweedfs/weed/admin/maintenance"
|
|
"github.com/seaweedfs/seaweedfs/weed/admin/config"
|
|
"github.com/seaweedfs/seaweedfs/weed/admin/view/components"
|
|
)
|
|
|
|
templ MaintenanceConfigSchema(data *maintenance.MaintenanceConfigData, schema *maintenance.MaintenanceConfigSchema) {
|
|
<div class="container-fluid">
|
|
<div class="row mb-4">
|
|
<div class="col-12">
|
|
<div class="d-flex justify-content-between align-items-center">
|
|
<h2 class="mb-0">
|
|
<i class="fas fa-cogs me-2"></i>
|
|
Maintenance Configuration
|
|
</h2>
|
|
<div class="btn-group">
|
|
<a href="/maintenance/tasks" class="btn btn-outline-primary">
|
|
<i class="fas fa-tasks me-1"></i>
|
|
View Tasks
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h5 class="mb-0">System Settings</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<form id="maintenanceConfigForm">
|
|
<!-- Dynamically render all schema fields in order -->
|
|
for _, field := range schema.Fields {
|
|
@ConfigField(field, data.Config)
|
|
}
|
|
|
|
<div class="d-flex gap-2">
|
|
<button type="button" class="btn btn-primary" onclick="saveConfiguration()">
|
|
<i class="fas fa-save me-1"></i>
|
|
Save Configuration
|
|
</button>
|
|
<button type="button" class="btn btn-secondary" onclick="resetToDefaults()">
|
|
<i class="fas fa-undo me-1"></i>
|
|
Reset to Defaults
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Task Configuration Cards -->
|
|
<div class="row mt-4">
|
|
<div class="col-md-4">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h5 class="mb-0">
|
|
<i class="fas fa-broom me-2"></i>
|
|
Volume Vacuum
|
|
</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<p class="card-text">Reclaims disk space by removing deleted files from volumes.</p>
|
|
<a href="/maintenance/config/vacuum" class="btn btn-primary">Configure</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-4">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h5 class="mb-0">
|
|
<i class="fas fa-balance-scale me-2"></i>
|
|
Volume Balance
|
|
</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<p class="card-text">Redistributes volumes across servers to optimize storage utilization.</p>
|
|
<a href="/maintenance/config/balance" class="btn btn-primary">Configure</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-4">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h5 class="mb-0">
|
|
<i class="fas fa-shield-alt me-2"></i>
|
|
Erasure Coding
|
|
</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<p class="card-text">Converts volumes to erasure coded format for improved durability.</p>
|
|
<a href="/maintenance/config/erasure_coding" class="btn btn-primary">Configure</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
function saveConfiguration() {
|
|
const form = document.getElementById('maintenanceConfigForm');
|
|
const formData = new FormData(form);
|
|
|
|
// Convert form data to JSON, handling interval fields specially
|
|
const config = {};
|
|
|
|
for (let [key, value] of formData.entries()) {
|
|
if (key.endsWith('_value')) {
|
|
// This is an interval value part
|
|
const baseKey = key.replace('_value', '');
|
|
const unitKey = baseKey + '_unit';
|
|
const unitValue = formData.get(unitKey);
|
|
|
|
if (unitValue) {
|
|
// Convert to seconds based on unit
|
|
const numValue = parseInt(value) || 0;
|
|
let seconds = numValue;
|
|
switch(unitValue) {
|
|
case 'minutes':
|
|
seconds = numValue * 60;
|
|
break;
|
|
case 'hours':
|
|
seconds = numValue * 3600;
|
|
break;
|
|
case 'days':
|
|
seconds = numValue * 24 * 3600;
|
|
break;
|
|
}
|
|
config[baseKey] = seconds;
|
|
}
|
|
} else if (key.endsWith('_unit')) {
|
|
// Skip unit keys - they're handled with their corresponding value
|
|
continue;
|
|
} else {
|
|
// Regular field
|
|
if (form.querySelector(`[name="${key}"]`).type === 'checkbox') {
|
|
config[key] = form.querySelector(`[name="${key}"]`).checked;
|
|
} else {
|
|
const numValue = parseFloat(value);
|
|
config[key] = isNaN(numValue) ? value : numValue;
|
|
}
|
|
}
|
|
}
|
|
|
|
fetch('/api/maintenance/config', {
|
|
method: 'PUT',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
body: JSON.stringify(config)
|
|
})
|
|
.then(response => {
|
|
if (response.status === 401) {
|
|
alert('Authentication required. Please log in first.');
|
|
window.location.href = '/login';
|
|
return;
|
|
}
|
|
return response.json();
|
|
})
|
|
.then(data => {
|
|
if (!data) return; // Skip if redirected to login
|
|
if (data.success) {
|
|
alert('Configuration saved successfully!');
|
|
location.reload();
|
|
} else {
|
|
alert('Error saving configuration: ' + (data.error || 'Unknown error'));
|
|
}
|
|
})
|
|
.catch(error => {
|
|
console.error('Error:', error);
|
|
alert('Error saving configuration: ' + error.message);
|
|
});
|
|
}
|
|
|
|
function resetToDefaults() {
|
|
if (confirm('Are you sure you want to reset to default configuration? This will overwrite your current settings.')) {
|
|
fetch('/maintenance/config/defaults', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
}
|
|
})
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
if (data.success) {
|
|
alert('Configuration reset to defaults!');
|
|
location.reload();
|
|
} else {
|
|
alert('Error resetting configuration: ' + (data.error || 'Unknown error'));
|
|
}
|
|
})
|
|
.catch(error => {
|
|
console.error('Error:', error);
|
|
alert('Error resetting configuration: ' + error.message);
|
|
});
|
|
}
|
|
}
|
|
</script>
|
|
}
|
|
|
|
// ConfigField renders a single configuration field based on schema with typed value lookup
|
|
templ ConfigField(field *config.Field, config *maintenance.MaintenanceConfig) {
|
|
if field.InputType == "interval" {
|
|
<!-- Interval field with number input + unit dropdown -->
|
|
<div class="mb-3">
|
|
<label for={ field.JSONName } class="form-label">
|
|
{ field.DisplayName }
|
|
if field.Required {
|
|
<span class="text-danger">*</span>
|
|
}
|
|
</label>
|
|
<div class="input-group">
|
|
<input
|
|
type="number"
|
|
class="form-control"
|
|
id={ field.JSONName + "_value" }
|
|
name={ field.JSONName + "_value" }
|
|
value={ fmt.Sprintf("%.0f", components.ConvertInt32SecondsToDisplayValue(getMaintenanceInt32Field(config, field.JSONName))) }
|
|
step="1"
|
|
min="1"
|
|
if field.Required {
|
|
required
|
|
}
|
|
/>
|
|
<select
|
|
class="form-select"
|
|
id={ field.JSONName + "_unit" }
|
|
name={ field.JSONName + "_unit" }
|
|
style="max-width: 120px;"
|
|
if field.Required {
|
|
required
|
|
}
|
|
>
|
|
<option
|
|
value="minutes"
|
|
if components.GetInt32DisplayUnit(getMaintenanceInt32Field(config, field.JSONName)) == "minutes" {
|
|
selected
|
|
}
|
|
>
|
|
Minutes
|
|
</option>
|
|
<option
|
|
value="hours"
|
|
if components.GetInt32DisplayUnit(getMaintenanceInt32Field(config, field.JSONName)) == "hours" {
|
|
selected
|
|
}
|
|
>
|
|
Hours
|
|
</option>
|
|
<option
|
|
value="days"
|
|
if components.GetInt32DisplayUnit(getMaintenanceInt32Field(config, field.JSONName)) == "days" {
|
|
selected
|
|
}
|
|
>
|
|
Days
|
|
</option>
|
|
</select>
|
|
</div>
|
|
if field.Description != "" {
|
|
<div class="form-text text-muted">{ field.Description }</div>
|
|
}
|
|
</div>
|
|
} else if field.InputType == "checkbox" {
|
|
<!-- Checkbox field -->
|
|
<div class="mb-3">
|
|
<div class="form-check form-switch">
|
|
<input
|
|
class="form-check-input"
|
|
type="checkbox"
|
|
id={ field.JSONName }
|
|
name={ field.JSONName }
|
|
if getMaintenanceBoolField(config, field.JSONName) {
|
|
checked
|
|
}
|
|
/>
|
|
<label class="form-check-label" for={ field.JSONName }>
|
|
<strong>{ field.DisplayName }</strong>
|
|
</label>
|
|
</div>
|
|
if field.Description != "" {
|
|
<div class="form-text text-muted">{ field.Description }</div>
|
|
}
|
|
</div>
|
|
} else {
|
|
<!-- Number field -->
|
|
<div class="mb-3">
|
|
<label for={ field.JSONName } class="form-label">
|
|
{ field.DisplayName }
|
|
if field.Required {
|
|
<span class="text-danger">*</span>
|
|
}
|
|
</label>
|
|
<input
|
|
type="number"
|
|
class="form-control"
|
|
id={ field.JSONName }
|
|
name={ field.JSONName }
|
|
value={ fmt.Sprintf("%d", getMaintenanceInt32Field(config, field.JSONName)) }
|
|
placeholder={ field.Placeholder }
|
|
if field.MinValue != nil {
|
|
min={ fmt.Sprintf("%v", field.MinValue) }
|
|
}
|
|
if field.MaxValue != nil {
|
|
max={ fmt.Sprintf("%v", field.MaxValue) }
|
|
}
|
|
step={ getNumberStep(field) }
|
|
if field.Required {
|
|
required
|
|
}
|
|
/>
|
|
if field.Description != "" {
|
|
<div class="form-text text-muted">{ field.Description }</div>
|
|
}
|
|
</div>
|
|
}
|
|
}
|
|
|
|
// Helper functions for form field types
|
|
|
|
func getNumberStep(field *config.Field) string {
|
|
if field.Type == config.FieldTypeFloat {
|
|
return "0.01"
|
|
}
|
|
return "1"
|
|
}
|
|
|
|
// Typed field getters for MaintenanceConfig - no interface{} needed
|
|
func getMaintenanceInt32Field(config *maintenance.MaintenanceConfig, fieldName string) int32 {
|
|
if config == nil {
|
|
return 0
|
|
}
|
|
|
|
switch fieldName {
|
|
case "scan_interval_seconds":
|
|
return config.ScanIntervalSeconds
|
|
case "worker_timeout_seconds":
|
|
return config.WorkerTimeoutSeconds
|
|
case "task_timeout_seconds":
|
|
return config.TaskTimeoutSeconds
|
|
case "retry_delay_seconds":
|
|
return config.RetryDelaySeconds
|
|
case "max_retries":
|
|
return config.MaxRetries
|
|
case "cleanup_interval_seconds":
|
|
return config.CleanupIntervalSeconds
|
|
case "task_retention_seconds":
|
|
return config.TaskRetentionSeconds
|
|
case "global_max_concurrent":
|
|
if config.Policy != nil {
|
|
return config.Policy.GlobalMaxConcurrent
|
|
}
|
|
return 0
|
|
default:
|
|
return 0
|
|
}
|
|
}
|
|
|
|
func getMaintenanceBoolField(config *maintenance.MaintenanceConfig, fieldName string) bool {
|
|
if config == nil {
|
|
return false
|
|
}
|
|
|
|
switch fieldName {
|
|
case "enabled":
|
|
return config.Enabled
|
|
default:
|
|
return false
|
|
}
|
|
}
|
|
|
|
// Helper function to convert schema to JSON for JavaScript
|
|
templ schemaToJSON(schema *maintenance.MaintenanceConfigSchema) {
|
|
{`{}`}
|
|
} |