Some checks failed
go: build dev binaries / cleanup (push) Successful in 4s
Codespell / Check for spelling errors (push) Failing after 3s
docker: build dev containers / build-rust-binaries (amd64, x86_64-unknown-linux-musl) (push) Failing after 3s
docker: build dev containers / build-dev-containers (push) Has been skipped
docker: build dev containers / build-rust-binaries (arm64, true, aarch64-unknown-linux-musl) (push) Failing after 3s
End to End / FUSE Mount (push) Failing after 2s
EC Integration Tests / EC Integration Tests (push) Failing after 30s
FUSE DLM Integration Tests / FUSE DLM Integration Tests (push) Failing after 3s
FUSE Volume Server Failover Tests / FUSE Volume Server Failover (push) Failing after 3s
FUSE Integration Tests / FUSE Integration Testing (push) Failing after 2s
FUSE P2P Peer Chunk Sharing Integration Tests / FUSE P2P Peer Chunk Sharing (push) Failing after 3s
go: build binary / Go Vet (push) Failing after 2s
go: build binary / Go Vet 32-bit (push) Failing after 3s
go: build binary / Build (push) Failing after 4s
go: build binary / Build cross-platform (freebsd/amd64) (push) Failing after 3s
go: build binary / Build cross-platform (windows/amd64) (push) Failing after 3s
go: build binary / Build cross-platform (darwin/arm64) (push) Failing after 3s
go: build binary / Build cross-platform (windows/arm64) (push) Failing after 3s
go: build binary / Test (push) Failing after 2s
go: build binary / Test 32-bit (push) Failing after 3s
helm: lint and test charts / lint-test (push) Failing after 3s
Java Client Integration Tests / Java Integration Tests (11) (push) Failing after 3s
Java Client Integration Tests / Java Integration Tests (17) (push) Failing after 3s
go: build dev binaries / build_dev_linux_windows (amd64, linux) (push) Failing after 2s
go: build dev binaries / build_dev_linux_windows (amd64, windows) (push) Failing after 3s
go: build dev binaries / build_dev_darwin (amd64, darwin) (push) Has been skipped
go: build dev binaries / build_dev_darwin (arm64, darwin) (push) Has been skipped
Java Client Unit Tests / Java Unit Tests (11) (push) Failing after 3s
Java Client Unit Tests / Java Unit Tests (17) (push) Failing after 2s
Java Client Unit Tests / Java Unit Tests (21) (push) Failing after 3s
Java Client Unit Tests / Java Unit Tests (8) (push) Failing after 3s
Kafka Quick Test (Load Test with Schema Registry) / Kafka Client Load Test (Quick) (push) Failing after 3s
Kafka Gateway Tests / Kafka Unit Tests (unit-tests-1) (push) Failing after 11s
Kafka Gateway Tests / Kafka Integration Tests (Critical) (integration-1) (push) Failing after 3s
Kafka Gateway Tests / Kafka End-to-End Tests (with SMQ) (e2e-1) (push) Failing after 3s
Kafka Gateway Tests / Kafka Consumer Group Tests (Highly Isolated) (consumer-group-1) (push) Failing after 2s
Kafka Gateway Tests / Kafka Client Compatibility (with SMQ) (client-compat-1) (push) Failing after 3s
Kafka Gateway Tests / Kafka SMQ Integration Tests (Full Stack) (smq-integration-1) (push) Failing after 3s
Kafka Gateway Tests / Kafka Protocol Tests (Isolated) (protocol-1) (push) Failing after 3s
KMS Tests / KMS Provider Integration Tests (push) Failing after 2s
KMS Tests / S3 KMS End-to-End Tests (push) Failing after 3s
Master Cold Start Tests / Master Cold Start Tests (push) Failing after 4s
Metadata Subscribe Integration Tests / Metadata Subscribe Integration Tests (push) Failing after 3s
Multi-Master Tests / Multi-Master Failover Tests (push) Failing after 3s
Performance / CPU and Heap Profile (push) Failing after 2s
Performance / S3 Read/Write Benchmark (rust volume) (push) Failing after 3s
pjdfstest POSIX Compliance / pjdfstest (push) Failing after 2s
Plugin Worker Integration Tests / Plugin Worker: erasure_coding (push) Failing after 3s
Plugin Worker Integration Tests / Plugin Worker: vacuum (push) Failing after 3s
Rust Volume Server Tests / Rust Integration Tests (push) Failing after 3s
Rust Volume Server Tests / Go Tests with Rust Volume (grpc - Shard 1) (push) Failing after 2s
Rust Volume Server Tests / Go Tests with Rust Volume (http - Shard 1) (push) Failing after 3s
Rust Volume Server Tests / Go Tests with Rust Volume (grpc - Shard 2) (push) Failing after 3s
Rust Volume Server Tests / Go Tests with Rust Volume (http - Shard 2) (push) Failing after 3s
Rust Volume Server Tests / Go Tests with Rust Volume (grpc - Shard 3) (push) Failing after 3s
S3 IAM Integration Tests / S3 IAM Distributed Tests (push) Failing after 2s
S3 IAM Integration Tests / S3 IAM Performance Tests (push) Failing after 3s
Performance / Throughput Benchmark (go volume) (push) Failing after 3s
Performance / Throughput Benchmark (rust volume) (push) Failing after 2s
Performance / S3 Read/Write Benchmark (go volume) (push) Failing after 3s
Plugin Worker Integration Tests / Plugin Worker: volume_balance (push) Failing after 3s
PostgreSQL Gateway Tests / PostgreSQL Basic Tests (push) Failing after 3s
Rust Volume Server Tests / Rust Unit Tests (push) Failing after 2s
Rust Volume Server Tests / Go Tests with Rust Volume (http - Shard 3) (push) Failing after 3s
Rust Plugin Worker Tests / Rust Plugin Worker Build and Unit Tests (push) Failing after 3s
rust: build dev volume server binaries / cleanup (push) Successful in 3s
S3 ETag and ACL Tests / S3 ETag + ACL Integration Tests (push) Failing after 3s
S3 IAM Integration Tests / IAM Unit Tests (push) Failing after 3s
S3 IAM Integration Tests / S3 IAM Integration Tests (advanced) (push) Failing after 3s
S3 IAM Integration Tests / S3 IAM Integration Tests (basic) (push) Failing after 2s
S3 IAM Integration Tests / S3 IAM Integration Tests (group) (push) Failing after 3s
S3 IAM Integration Tests / S3 IAM Integration Tests (policy-enforcement) (push) Failing after 2s
S3 IAM Integration Tests / S3 IAM Integration Tests (sts) (push) Failing after 4s
S3 Keycloak Integration Tests / S3 Keycloak Integration Tests (push) Failing after 3s
S3 PyArrow Parquet Tests / PyArrow Parquet Tests (Python 3.11) (push) Failing after 3s
S3 PyArrow Parquet Tests / Go Unit Tests (Implicit Directory) (push) Has been cancelled
S3 PyArrow Parquet Tests / PyArrow Parquet Tests (Python 3.12) (push) Has been cancelled
rust: build dev volume server binaries / build-rust-volume-dev-darwin (darwin-amd64, x86_64-apple-darwin) (push) Has been cancelled
rust: build dev volume server binaries / build-rust-volume-dev-darwin (darwin-arm64, aarch64-apple-darwin) (push) Has been cancelled
rust: build dev volume server binaries / build-rust-volume-dev-linux (linux-amd64, x86_64-unknown-linux-gnu) (push) Has been cancelled
S3 PyArrow Parquet Tests / PyArrow Parquet Tests (Python 3.9) (push) Has been cancelled
S3 Proxy Signature Tests / S3 Proxy Signature Verification Tests (push) Has been cancelled
S3 SDK V2 Route Disambiguation Tests / S3 SDK V2 Routing Tests (push) Has been cancelled
S3 SSE Tests / S3 SSE Integration Tests (quick) (push) Has been cancelled
S3 SSE Tests / S3 SSE Compatibility Test (push) Has been cancelled
S3 SSE Tests / S3 SSE Metadata Persistence Test (push) Has been cancelled
S3 SSE Tests / S3 SSE Copy Operations Test (push) Has been cancelled
S3 SSE Tests / S3 SSE Multipart Upload Test (push) Has been cancelled
S3 SSE Tests / S3 SSE Performance Test (push) Has been cancelled
S3 SSE Tests / S3 Volume Encryption Test (push) Has been cancelled
S3 SSE Tests / S3 SSE Integration Tests (comprehensive) (push) Has been cancelled
Spark Integration Tests / Spark Integration Tests (push) Failing after 2s
Telemetry Integration Tests / telemetry-integration-test (push) Failing after 3s
Volume Server Integration Tests / Volume Server Integration Tests (grpc - Shard 1) (push) Failing after 3s
Volume Server Integration Tests / Volume Server Integration Tests (http - Shard 1) (push) Failing after 3s
Ceph S3 tests / Basic S3 tests (KV store) (push) Has been cancelled
Ceph S3 tests / S3 Versioning & Object Lock tests (push) Has been cancelled
S3 Policy Integration Tests / S3 Policy Unit Tests (push) Failing after 3s
Ceph S3 tests / S3 CORS tests (push) Has been cancelled
Ceph S3 tests / SeaweedFS Custom S3 Copy tests (push) Has been cancelled
Ceph S3 tests / Basic S3 tests (SQL store) (push) Has been cancelled
test s3 over https using aws-cli / awscli-tests (push) Has been cancelled
TLS Rotation Integration Tests / TLS Rotation Integration Tests (push) Has been cancelled
Vacuum Integration Tests / Vacuum Integration Tests (push) Has been cancelled
S3 Policy Integration Tests / S3 Policy Variables Integration Tests (push) Failing after 3s
S3 Policy Integration Tests / S3 Policy Enforcement Integration Tests (advanced-policy) (push) Failing after 3s
S3 Policy Integration Tests / S3 Policy Enforcement Integration Tests (basic-policy) (push) Failing after 2s
S3 Policy Integration Tests / S3 Policy Enforcement Integration Tests (contextual-policy) (push) Failing after 4s
S3 Policy Integration Tests / Trusted Proxy Detection Tests (push) Failing after 2s
S3 Policy Integration Tests / S3 Policy Shell Integration Tests (push) Failing after 3s
Samba on FUSE Integration / samba-integration (push) Failing after 2s
SFTP Integration Tests / SFTP Integration Testing (push) Failing after 3s
terraform: validate and test modules / fmt, validate, plan-level tests (push) Failing after 3s
terraform: validate and test modules / local cluster smoke test (real weed) (push) Failing after 2s
Volume Server Integration Tests / Volume Server Integration Tests (grpc - Shard 3) (push) Failing after 3s
Volume Server Integration Tests / Volume Server Integration Tests (grpc - Shard 2) (push) Failing after 3s
Volume Server Integration Tests / Volume Server Integration Tests (http - Shard 2) (push) Failing after 2s
Volume Server Integration Tests / Volume Server Integration Tests (http - Shard 3) (push) Failing after 5s
mount: windows conformance / WinFsp conformance (push) Has been cancelled
mount: windows / Mount on Windows (push) Has been cancelled
312 lines
9.5 KiB
Go
312 lines
9.5 KiB
Go
package maintenance
|
|
|
|
import (
|
|
"sync"
|
|
"time"
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/glog"
|
|
"github.com/seaweedfs/seaweedfs/weed/worker/types"
|
|
)
|
|
|
|
// PendingOperationType represents the type of pending operation
|
|
type PendingOperationType string
|
|
|
|
const (
|
|
OpTypeVolumeMove PendingOperationType = "volume_move"
|
|
OpTypeVolumeBalance PendingOperationType = "volume_balance"
|
|
OpTypeErasureCoding PendingOperationType = "erasure_coding"
|
|
OpTypeVacuum PendingOperationType = "vacuum"
|
|
OpTypeReplication PendingOperationType = "replication"
|
|
)
|
|
|
|
// PendingOperation represents a pending volume/shard operation
|
|
type PendingOperation struct {
|
|
VolumeID uint32 `json:"volume_id"`
|
|
OperationType PendingOperationType `json:"operation_type"`
|
|
SourceNode string `json:"source_node"`
|
|
DestNode string `json:"dest_node,omitempty"` // Empty for non-movement operations
|
|
TaskID string `json:"task_id"`
|
|
StartTime time.Time `json:"start_time"`
|
|
EstimatedSize uint64 `json:"estimated_size"` // Bytes
|
|
Collection string `json:"collection"`
|
|
Status string `json:"status"` // "assigned", "in_progress", "completing"
|
|
}
|
|
|
|
// PendingOperations tracks all pending volume/shard operations
|
|
type PendingOperations struct {
|
|
// Operations by volume ID for conflict detection
|
|
byVolumeID map[uint32]*PendingOperation
|
|
|
|
// Operations by task ID for updates
|
|
byTaskID map[string]*PendingOperation
|
|
|
|
// Operations by node for capacity calculations
|
|
bySourceNode map[string][]*PendingOperation
|
|
byDestNode map[string][]*PendingOperation
|
|
|
|
mutex sync.RWMutex
|
|
}
|
|
|
|
// NewPendingOperations creates a new pending operations tracker
|
|
func NewPendingOperations() *PendingOperations {
|
|
return &PendingOperations{
|
|
byVolumeID: make(map[uint32]*PendingOperation),
|
|
byTaskID: make(map[string]*PendingOperation),
|
|
bySourceNode: make(map[string][]*PendingOperation),
|
|
byDestNode: make(map[string][]*PendingOperation),
|
|
}
|
|
}
|
|
|
|
// AddOperation adds a pending operation
|
|
func (po *PendingOperations) AddOperation(op *PendingOperation) {
|
|
po.mutex.Lock()
|
|
defer po.mutex.Unlock()
|
|
|
|
// Check for existing operation on this volume
|
|
if existing, exists := po.byVolumeID[op.VolumeID]; exists {
|
|
glog.V(1).Infof("Replacing existing pending operation on volume %d: %s -> %s",
|
|
op.VolumeID, existing.TaskID, op.TaskID)
|
|
po.removeOperationUnlocked(existing)
|
|
}
|
|
|
|
// Add new operation
|
|
po.byVolumeID[op.VolumeID] = op
|
|
po.byTaskID[op.TaskID] = op
|
|
|
|
// Add to node indexes
|
|
po.bySourceNode[op.SourceNode] = append(po.bySourceNode[op.SourceNode], op)
|
|
if op.DestNode != "" {
|
|
po.byDestNode[op.DestNode] = append(po.byDestNode[op.DestNode], op)
|
|
}
|
|
|
|
glog.V(2).Infof("Added pending operation: volume %d, type %s, task %s, %s -> %s",
|
|
op.VolumeID, op.OperationType, op.TaskID, op.SourceNode, op.DestNode)
|
|
}
|
|
|
|
// RemoveOperation removes a completed operation
|
|
func (po *PendingOperations) RemoveOperation(taskID string) {
|
|
po.mutex.Lock()
|
|
defer po.mutex.Unlock()
|
|
|
|
if op, exists := po.byTaskID[taskID]; exists {
|
|
po.removeOperationUnlocked(op)
|
|
glog.V(2).Infof("Removed completed operation: volume %d, task %s", op.VolumeID, taskID)
|
|
}
|
|
}
|
|
|
|
// removeOperationUnlocked removes an operation (must hold lock)
|
|
func (po *PendingOperations) removeOperationUnlocked(op *PendingOperation) {
|
|
delete(po.byVolumeID, op.VolumeID)
|
|
delete(po.byTaskID, op.TaskID)
|
|
|
|
// Remove from source node list
|
|
if ops, exists := po.bySourceNode[op.SourceNode]; exists {
|
|
for i, other := range ops {
|
|
if other.TaskID == op.TaskID {
|
|
po.bySourceNode[op.SourceNode] = append(ops[:i], ops[i+1:]...)
|
|
break
|
|
}
|
|
}
|
|
}
|
|
|
|
// Remove from dest node list
|
|
if op.DestNode != "" {
|
|
if ops, exists := po.byDestNode[op.DestNode]; exists {
|
|
for i, other := range ops {
|
|
if other.TaskID == op.TaskID {
|
|
po.byDestNode[op.DestNode] = append(ops[:i], ops[i+1:]...)
|
|
break
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// HasPendingOperationOnVolume checks if a volume has a pending operation
|
|
func (po *PendingOperations) HasPendingOperationOnVolume(volumeID uint32) bool {
|
|
po.mutex.RLock()
|
|
defer po.mutex.RUnlock()
|
|
|
|
_, exists := po.byVolumeID[volumeID]
|
|
return exists
|
|
}
|
|
|
|
// GetPendingOperationOnVolume returns the pending operation on a volume
|
|
func (po *PendingOperations) GetPendingOperationOnVolume(volumeID uint32) *PendingOperation {
|
|
po.mutex.RLock()
|
|
defer po.mutex.RUnlock()
|
|
|
|
return po.byVolumeID[volumeID]
|
|
}
|
|
|
|
// WouldConflictWithPending checks if a new operation would conflict with pending ones
|
|
func (po *PendingOperations) WouldConflictWithPending(volumeID uint32, opType PendingOperationType) bool {
|
|
po.mutex.RLock()
|
|
defer po.mutex.RUnlock()
|
|
|
|
if existing, exists := po.byVolumeID[volumeID]; exists {
|
|
// Volume already has a pending operation
|
|
glog.V(3).Infof("Volume %d conflict: already has %s operation (task %s)",
|
|
volumeID, existing.OperationType, existing.TaskID)
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
// GetPendingCapacityImpactForNode calculates pending capacity changes for a node
|
|
func (po *PendingOperations) GetPendingCapacityImpactForNode(nodeID string) (incoming uint64, outgoing uint64) {
|
|
po.mutex.RLock()
|
|
defer po.mutex.RUnlock()
|
|
|
|
// Calculate outgoing capacity (volumes leaving this node)
|
|
if ops, exists := po.bySourceNode[nodeID]; exists {
|
|
for _, op := range ops {
|
|
// Only count movement operations
|
|
if op.DestNode != "" {
|
|
outgoing += op.EstimatedSize
|
|
}
|
|
}
|
|
}
|
|
|
|
// Calculate incoming capacity (volumes coming to this node)
|
|
if ops, exists := po.byDestNode[nodeID]; exists {
|
|
for _, op := range ops {
|
|
incoming += op.EstimatedSize
|
|
}
|
|
}
|
|
|
|
return incoming, outgoing
|
|
}
|
|
|
|
// FilterVolumeMetricsExcludingPending filters out volumes with pending operations
|
|
func (po *PendingOperations) FilterVolumeMetricsExcludingPending(metrics []*types.VolumeHealthMetrics) []*types.VolumeHealthMetrics {
|
|
po.mutex.RLock()
|
|
defer po.mutex.RUnlock()
|
|
|
|
var filtered []*types.VolumeHealthMetrics
|
|
excludedCount := 0
|
|
|
|
for _, metric := range metrics {
|
|
if _, hasPending := po.byVolumeID[metric.VolumeID]; !hasPending {
|
|
filtered = append(filtered, metric)
|
|
} else {
|
|
excludedCount++
|
|
glog.V(3).Infof("Excluding volume %d from scan due to pending operation", metric.VolumeID)
|
|
}
|
|
}
|
|
|
|
if excludedCount > 0 {
|
|
glog.V(1).Infof("Filtered out %d volumes with pending operations from %d total volumes",
|
|
excludedCount, len(metrics))
|
|
}
|
|
|
|
return filtered
|
|
}
|
|
|
|
// GetNodeCapacityProjection calculates projected capacity for a node
|
|
func (po *PendingOperations) GetNodeCapacityProjection(nodeID string, currentUsed uint64, totalCapacity uint64) NodeCapacityProjection {
|
|
incoming, outgoing := po.GetPendingCapacityImpactForNode(nodeID)
|
|
|
|
projectedUsed := currentUsed + incoming - outgoing
|
|
projectedFree := totalCapacity - projectedUsed
|
|
|
|
return NodeCapacityProjection{
|
|
NodeID: nodeID,
|
|
CurrentUsed: currentUsed,
|
|
TotalCapacity: totalCapacity,
|
|
PendingIncoming: incoming,
|
|
PendingOutgoing: outgoing,
|
|
ProjectedUsed: projectedUsed,
|
|
ProjectedFree: projectedFree,
|
|
}
|
|
}
|
|
|
|
// GetAllPendingOperations returns all pending operations
|
|
func (po *PendingOperations) GetAllPendingOperations() []*PendingOperation {
|
|
po.mutex.RLock()
|
|
defer po.mutex.RUnlock()
|
|
|
|
var operations []*PendingOperation
|
|
for _, op := range po.byVolumeID {
|
|
operations = append(operations, op)
|
|
}
|
|
|
|
return operations
|
|
}
|
|
|
|
// UpdateOperationStatus updates the status of a pending operation
|
|
func (po *PendingOperations) UpdateOperationStatus(taskID string, status string) {
|
|
po.mutex.Lock()
|
|
defer po.mutex.Unlock()
|
|
|
|
if op, exists := po.byTaskID[taskID]; exists {
|
|
op.Status = status
|
|
glog.V(3).Infof("Updated operation status: task %s, volume %d -> %s", taskID, op.VolumeID, status)
|
|
}
|
|
}
|
|
|
|
// CleanupStaleOperations removes operations that have been running too long
|
|
func (po *PendingOperations) CleanupStaleOperations(maxAge time.Duration) int {
|
|
po.mutex.Lock()
|
|
defer po.mutex.Unlock()
|
|
|
|
cutoff := time.Now().Add(-maxAge)
|
|
var staleOps []*PendingOperation
|
|
|
|
for _, op := range po.byVolumeID {
|
|
if op.StartTime.Before(cutoff) {
|
|
staleOps = append(staleOps, op)
|
|
}
|
|
}
|
|
|
|
for _, op := range staleOps {
|
|
po.removeOperationUnlocked(op)
|
|
glog.Warningf("Removed stale pending operation: volume %d, task %s, age %v",
|
|
op.VolumeID, op.TaskID, time.Since(op.StartTime))
|
|
}
|
|
|
|
return len(staleOps)
|
|
}
|
|
|
|
// NodeCapacityProjection represents projected capacity for a node
|
|
type NodeCapacityProjection struct {
|
|
NodeID string `json:"node_id"`
|
|
CurrentUsed uint64 `json:"current_used"`
|
|
TotalCapacity uint64 `json:"total_capacity"`
|
|
PendingIncoming uint64 `json:"pending_incoming"`
|
|
PendingOutgoing uint64 `json:"pending_outgoing"`
|
|
ProjectedUsed uint64 `json:"projected_used"`
|
|
ProjectedFree uint64 `json:"projected_free"`
|
|
}
|
|
|
|
// GetStats returns statistics about pending operations
|
|
func (po *PendingOperations) GetStats() PendingOperationsStats {
|
|
po.mutex.RLock()
|
|
defer po.mutex.RUnlock()
|
|
|
|
stats := PendingOperationsStats{
|
|
TotalOperations: len(po.byVolumeID),
|
|
ByType: make(map[PendingOperationType]int),
|
|
ByStatus: make(map[string]int),
|
|
}
|
|
|
|
var totalSize uint64
|
|
for _, op := range po.byVolumeID {
|
|
stats.ByType[op.OperationType]++
|
|
stats.ByStatus[op.Status]++
|
|
totalSize += op.EstimatedSize
|
|
}
|
|
|
|
stats.TotalEstimatedSize = totalSize
|
|
return stats
|
|
}
|
|
|
|
// PendingOperationsStats provides statistics about pending operations
|
|
type PendingOperationsStats struct {
|
|
TotalOperations int `json:"total_operations"`
|
|
ByType map[PendingOperationType]int `json:"by_type"`
|
|
ByStatus map[string]int `json:"by_status"`
|
|
TotalEstimatedSize uint64 `json:"total_estimated_size"`
|
|
}
|