admin

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 7, 2026 License: GPL-3.0 Imports: 27 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	ActionPull    = "pull"
	ActionBuild   = "build"
	ActionRestart = "restart"
	ActionReboot  = "reboot"
	ActionApt     = "apt"
	ActionLogs    = "logs"
	ActionCustom  = "custom"
)

Supported orchestration action types.

Variables

This section is empty.

Functions

func LoadEnv

func LoadEnv(paths ...string)

LoadEnv loads environment variables from .env files if not already set in the process.

Types

type ActionEvent

type ActionEvent struct {
	Type       string `json:"type"` // "action_started", "node_started", "node_output", "node_finished", "action_finished"
	ActionID   string `json:"action_id"`
	Command    string `json:"command,omitempty"`
	NodeID     string `json:"node_id,omitempty"`
	Address    string `json:"address,omitempty"`
	Stream     string `json:"stream,omitempty"` // "stdout" or "stderr"
	Chunk      string `json:"chunk,omitempty"`
	ExitCode   int    `json:"exit_code"`
	DurationMs int64  `json:"duration_ms,omitempty"`
	Status     string `json:"status,omitempty"` // "running", "success", "failed"
	Error      string `json:"error,omitempty"`
}

ActionEvent represents a real-time event emitted during action execution.

type ActionRequest

type ActionRequest struct {
	ActionType     string                        `json:"action_type"`
	TargetNodeIDs  []string                      `json:"target_node_ids"`
	CustomCommand  string                        `json:"custom_command,omitempty"`
	RepoPath       string                        `json:"repo_path,omitempty"`
	GitBranch      string                        `json:"git_branch,omitempty"`
	MakeTarget     string                        `json:"make_target,omitempty"`
	TargetService  string                        `json:"target_service,omitempty"` // "fileserver", "metaserver", "admin", "all"
	AptMode        string                        `json:"apt_mode,omitempty"`       // "update_upgrade" (default), "update_only"
	TimeoutSeconds int                           `json:"timeout_seconds,omitempty"`
	SSHPort        int                           `json:"ssh_port,omitempty"`
	LogLines       int                           `json:"log_lines,omitempty"`
	LogPath        string                        `json:"log_path,omitempty"`
	RestartMode    string                        `json:"restart_mode,omitempty"` // "systemctl" (default) or "binary"
	LogMode        string                        `json:"log_mode,omitempty"`     // "journalctl" (default) or "tail"
	RestartParams  map[string]*NodeRestartParams `json:"restart_params,omitempty"`
	SSHUser        string                        `json:"ssh_user,omitempty"`
	SSHKeyPath     string                        `json:"ssh_key_path,omitempty"`
}

ActionRequest specifies an orchestration operation to execute across cluster nodes.

type AdminServer

type AdminServer struct {
	// contains filtered or unexported fields
}

AdminServer coordinates fileserver discovery, metrics polling, and serves the REST API + UI.

func NewAdminServer

func NewAdminServer(stateFile, staticDir string) *AdminServer

NewAdminServer creates a new AdminServer instance.

func (*AdminServer) AlertManager

func (a *AdminServer) AlertManager() *AlertManager

AlertManager returns the alert management engine.

func (*AdminServer) AuthManager

func (a *AdminServer) AuthManager() *AuthManager

AuthManager returns the current authentication manager.

func (*AdminServer) CallSetQuota

func (a *AdminServer) CallSetQuota(address string, username string, quotaBytes uint64) error

CallSetQuota invokes the SetQuota gRPC RPC on the target fileserver address.

func (*AdminServer) FetchNodeLogs

func (a *AdminServer) FetchNodeLogs(ctx context.Context, nodeID string, service string, lines int, mode string, extraOpts ...string) (*LogTailResponse, error)

FetchNodeLogs queries the remote node via SSH to tail recent system or file logs.

func (*AdminServer) History

func (a *AdminServer) History() *CommandHistory

History returns the command history storage.

func (*AdminServer) IsTLS

func (a *AdminServer) IsTLS() bool

IsTLS reports whether direct TLS is active on the admin server.

func (*AdminServer) LoadMetricsSnapshot

func (a *AdminServer) LoadMetricsSnapshot(filePath string) error

LoadMetricsSnapshot restores historical ring-buffer data from disk.

func (*AdminServer) Orchestrator

func (a *AdminServer) Orchestrator() *Orchestrator

Orchestrator returns the orchestration engine.

func (*AdminServer) Run

func (a *AdminServer) Run(port int) error

Run starts the background pollers and the HTTP API/UI server.

func (*AdminServer) SaveMetricsSnapshot

func (a *AdminServer) SaveMetricsSnapshot(filePath string) error

SaveMetricsSnapshot serializes all node ring-buffer histories to disk atomically.

func (*AdminServer) SetAlertManager

func (a *AdminServer) SetAlertManager(am *AlertManager)

SetAlertManager configures the alert manager (useful in tests).

func (*AdminServer) SetAuthManager

func (a *AdminServer) SetAuthManager(am *AuthManager)

SetAuthManager sets the authentication manager (useful for testing).

func (*AdminServer) SetHistory

func (a *AdminServer) SetHistory(h *CommandHistory)

SetHistory configures the command history storage.

func (*AdminServer) SetOrchestrator

func (a *AdminServer) SetOrchestrator(o *Orchestrator)

SetOrchestrator configures the orchestration engine (useful for injecting mock SSH executors in tests).

func (*AdminServer) SetTLS

func (a *AdminServer) SetTLS(certFile, keyFile string)

SetTLS configures direct TLS certificates for the admin console.

func (*AdminServer) Stop

func (a *AdminServer) Stop()

Stop shuts down background tickers and flushes metrics snapshot.

type Alert

type Alert struct {
	ID         string        `json:"id"`
	Timestamp  int64         `json:"timestamp"`
	Severity   AlertSeverity `json:"severity"`
	Type       AlertType     `json:"type"`
	Title      string        `json:"title"`
	Message    string        `json:"message"`
	NodeID     string        `json:"node_id,omitempty"`
	NodeName   string        `json:"node_name,omitempty"`
	Username   string        `json:"username,omitempty"`
	Resolved   bool          `json:"resolved"`
	ResolvedAt int64         `json:"resolved_at,omitempty"`
}

Alert represents an event record in the system alert log.

type AlertFilters

type AlertFilters struct {
	Severity   string
	NodeID     string
	Unresolved bool
	Limit      int
}

AlertFilters specifies criteria for querying alerts.

type AlertManager

type AlertManager struct {
	// contains filtered or unexported fields
}

AlertManager detects system health events, tracks active condition states, avoids duplicate alert flooding, and persists alerts to disk.

func NewAlertManager

func NewAlertManager(capacity int, filePath string) *AlertManager

NewAlertManager creates a new AlertManager instance.

func (*AlertManager) CheckNodeHealth

func (am *AlertManager) CheckNodeHealth(node *NodeState, prevLastSeen int64, prevUptime float64)

CheckNodeHealth evaluates telemetry for a single node and triggers/resolves alerts accordingly.

func (*AlertManager) CheckUserQuota

func (am *AlertManager) CheckUserQuota(username string, used, quota uint64, homeNodeID, homeNodeLabel string)

CheckUserQuota evaluates a user's storage usage against their quota limit.

func (*AlertManager) GetAll

func (am *AlertManager) GetAll(f AlertFilters) []Alert

GetAll returns alerts matching the given filters.

func (*AlertManager) ResolveAlert

func (am *AlertManager) ResolveAlert(id string) bool

ResolveAlert marks a specific alert as resolved by ID.

func (*AlertManager) ResolveAll

func (am *AlertManager) ResolveAll() int

ResolveAll marks all alerts as resolved.

func (*AlertManager) Summary

func (am *AlertManager) Summary() AlertSummary

Summary returns the current count of alerts grouped by severity.

type AlertSeverity

type AlertSeverity string

AlertSeverity defines the urgency levels for system alerts.

const (
	SeverityInfo     AlertSeverity = "info"
	SeverityWarning  AlertSeverity = "warning"
	SeverityCritical AlertSeverity = "critical"
)

type AlertSummary

type AlertSummary struct {
	CriticalCount   int `json:"critical_count"`
	WarningCount    int `json:"warning_count"`
	InfoCount       int `json:"info_count"`
	TotalUnresolved int `json:"total_unresolved"`
}

AlertSummary reports aggregate counts of active alerts.

type AlertType

type AlertType string

AlertType categorizes the source or cause of the alert.

const (
	AlertTypeNodeOffline    AlertType = "node_offline"
	AlertTypeNodeOnline     AlertType = "node_online"
	AlertTypeStorageWarning AlertType = "storage_warning"
	AlertTypeTempWarning    AlertType = "temp_warning"
	AlertTypeQuotaExceeded  AlertType = "quota_exceeded"
	AlertTypeErrorSpike     AlertType = "error_spike"
	AlertTypeServiceRestart AlertType = "service_restart"
)

type AuthManager

type AuthManager struct {
	// contains filtered or unexported fields
}

AuthManager handles password hash verification, session token generation, and route protection.

func NewAuthManager

func NewAuthManager(envPaths ...string) *AuthManager

NewAuthManager initializes the authentication manager by loading .env if available.

func (*AuthManager) CreateSession

func (am *AuthManager) CreateSession() string

CreateSession generates a 32-byte cryptographically secure session token, stores it with sessionTTL, and returns the hex token string.

func (*AuthManager) ExtractToken

func (am *AuthManager) ExtractToken(r *http.Request) string

ExtractToken retrieves the auth token from: 1. Authorization: Bearer <token> 2. Cookie: dvfs_admin_token=<token> 3. Query parameter: ?token=<token>

func (*AuthManager) GetHash

func (am *AuthManager) GetHash() string

GetHash returns the configured password hash.

func (*AuthManager) IsAuthenticated

func (am *AuthManager) IsAuthenticated(r *http.Request) bool

IsAuthenticated verifies whether the request carries a valid, non-expired session token.

func (*AuthManager) RequireAuth

func (am *AuthManager) RequireAuth(next http.HandlerFunc) http.HandlerFunc

RequireAuth wraps an http.HandlerFunc, returning 401 Unauthorized if the request is unauthenticated.

func (*AuthManager) RevokeSession

func (am *AuthManager) RevokeSession(token string)

RevokeSession invalidates a session token immediately.

func (*AuthManager) SetHash

func (am *AuthManager) SetHash(hash string)

SetHash manually updates the password hash (primarily for tests).

func (*AuthManager) VerifyPassword

func (am *AuthManager) VerifyPassword(candidate string) bool

VerifyPassword hashes the candidate password using SHA-256 and compares it constant-time with am.hash. Strictly NO plaintext verification is supported.

type ClusterHistorySnapshot

type ClusterHistorySnapshot struct {
	Timestamp         int64   `json:"timestamp"`
	WriteMbps         float64 `json:"write_mbps"`
	ReadMbps          float64 `json:"read_mbps"`
	WriteIOPS         float64 `json:"write_iops"`
	ReadIOPS          float64 `json:"read_iops"`
	ActiveConnections int     `json:"active_connections"`
	ErrorRatePct      float64 `json:"error_rate_pct"`
}

ClusterHistorySnapshot represents an aggregated time slice across all cluster nodes.

type ClusterResponse

type ClusterResponse struct {
	Nodes               []*NodeState      `json:"nodes"`
	Users               map[string]string `json:"users"`
	NodeCount           int               `json:"node_count"`
	OnlineCount         int               `json:"online_count"`
	TotalStorageBytes   uint64            `json:"total_storage_bytes"`
	UsedStorageBytes    uint64            `json:"used_storage_bytes"`
	TotalUsers          int               `json:"total_users"`
	OnlineUsers         int               `json:"online_users"`
	ClusterWriteMbps    float64           `json:"cluster_write_mbps"`
	ClusterReadMbps     float64           `json:"cluster_read_mbps"`
	ClusterWriteIOPS    float64           `json:"cluster_write_iops"`
	ClusterReadIOPS     float64           `json:"cluster_read_iops"`
	ClusterErrorRatePct float64           `json:"cluster_error_rate_pct"`
}

type CommandHistory

type CommandHistory struct {
	// contains filtered or unexported fields
}

CommandHistory implements a fixed-size, bounded circular ring buffer for command executions to guarantee that memory and disk usage never grow unbounded.

func NewCommandHistory

func NewCommandHistory(capacity int, filePath string) *CommandHistory

NewCommandHistory creates a bounded command history buffer with atomic JSON persistence.

func (*CommandHistory) Count

func (ch *CommandHistory) Count() int

Count returns the number of records currently held in the ring buffer.

func (*CommandHistory) GetAll

func (ch *CommandHistory) GetAll() []CommandRecord

GetAll returns all stored records in reverse chronological order (newest first).

func (*CommandHistory) GetByID

func (ch *CommandHistory) GetByID(id string) (*CommandRecord, bool)

GetByID finds a specific command record by ID.

func (*CommandHistory) Push

func (ch *CommandHistory) Push(r CommandRecord)

Push adds a record to the circular buffer and flushes to disk.

func (*CommandHistory) Update

func (ch *CommandHistory) Update(r CommandRecord)

Update updates an existing record in-place by ID (useful when transitioning from running to success/failed).

type CommandRecord

type CommandRecord struct {
	ID          string                 `json:"id"`
	Timestamp   int64                  `json:"timestamp"`
	ActionType  string                 `json:"action_type"`
	Command     string                 `json:"command"`
	TargetNodes []string               `json:"target_nodes"`
	Status      string                 `json:"status"` // "running", "success", "failed"
	DurationMs  int64                  `json:"duration_ms"`
	NodeResults map[string]*NodeResult `json:"node_results"`
}

CommandRecord represents a single orchestration action execution across cluster nodes.

type FSInfo

type FSInfo struct {
	Address           string `json:"address"`
	UserCount         int    `json:"user_count"`
	LastHeartbeatUnix int64  `json:"last_heartbeat_unix"`
	Status            string `json:"status"`
}

FSInfo holds the state of a single fileserver as recorded by the metaserver.

type FileserverMetrics

type FileserverMetrics struct {
	DiskTotalBytes      uint64            `json:"disk_total_bytes"`
	DiskUsedBytes       uint64            `json:"disk_used_bytes"`
	DiskFreeBytes       uint64            `json:"disk_free_bytes"`
	DiskUsagePercent    float64           `json:"disk_usage_percent"`
	PerUserStorage      map[string]uint64 `json:"per_user_storage"`
	PerUserQuota        map[string]uint64 `json:"per_user_quota"`
	ChunkCount          int               `json:"chunk_count"`
	CPUTempCelsius      float64           `json:"cpu_temp_celsius"`
	CPUUsagePercent     float64           `json:"cpu_usage_percent"`
	MemUsedBytes        uint64            `json:"mem_used_bytes"`
	MemTotalBytes       uint64            `json:"mem_total_bytes"`
	MemUsagePercent     float64           `json:"mem_usage_percent"`
	LoadAvg1m           float64           `json:"load_avg_1m"`
	LoadAvg5m           float64           `json:"load_avg_5m"`
	UptimeSeconds       float64           `json:"uptime_seconds"`
	LastRestartUnix     int64             `json:"last_restart_unix"`
	ActiveConnections   int               `json:"active_connections"`
	ActiveUsers         []string          `json:"active_users"`
	UsersAssigned       int               `json:"users_assigned_count"`
	BytesWrittenTotal   uint64            `json:"bytes_written_total"`
	BytesReadTotal      uint64            `json:"bytes_read_total"`
	WriteOpsTotal       uint64            `json:"write_ops_total"`
	ReadOpsTotal        uint64            `json:"read_ops_total"`
	ErrorsTotal         uint64            `json:"errors_total"`
	FailedWritesTotal   uint64            `json:"failed_writes_total"`
	FailedReadsTotal    uint64            `json:"failed_reads_total"`
	OpLatencyWriteMsP50 float64           `json:"op_latency_write_ms_p50"`
	OpLatencyWriteMsP95 float64           `json:"op_latency_write_ms_p95"`
	OpLatencyWriteMsP99 float64           `json:"op_latency_write_ms_p99"`
	OpLatencyReadMsP50  float64           `json:"op_latency_read_ms_p50"`
	OpLatencyReadMsP95  float64           `json:"op_latency_read_ms_p95"`
	OpLatencyReadMsP99  float64           `json:"op_latency_read_ms_p99"`
}

FileserverMetrics mirrors the Metrics struct in the fileserver package and is used for JSON decoding of HTTP responses from fileserver nodes.

type LogTailResponse

type LogTailResponse struct {
	NodeID    string `json:"node_id"`
	Address   string `json:"address"`
	Service   string `json:"service"`
	Lines     int    `json:"lines"`
	Content   string `json:"content"`
	Timestamp int64  `json:"timestamp"`
}

LogTailResponse captures the output of a log query for a specific fileserver node.

type MetaState

type MetaState struct {
	FileServers map[string]FSInfo `json:"fileservers"` // string key (numeric fsID)
	Users       map[string]uint64 `json:"users"`       // username -> fsID
	NextFsID    uint64            `json:"next_fs_id"`
}

MetaState is the top-level shape of the metaserver_state.json file.

func LoadMetaState

func LoadMetaState(path string) (*MetaState, error)

LoadMetaState reads and parses the metaserver state JSON file.

type MetricsSnapshotFile

type MetricsSnapshotFile struct {
	SavedAt  int64                       `json:"saved_at"`
	NodeData map[string]NodeHistoryStore `json:"node_data"`
}

MetricsSnapshotFile captures the persisted state of all node ring buffers.

type MockSSHCall

type MockSSHCall struct {
	Host    string
	Port    int
	User    string
	KeyPath string
	Command string
}

MockSSHCall records details of an executed call.

type MockSSHExecutor

type MockSSHExecutor struct {
	Responses map[string]MockSSHResponse
	Default   MockSSHResponse
	Calls     []MockSSHCall
	// contains filtered or unexported fields
}

MockSSHExecutor simulates SSH command execution for unit and integration testing.

func NewMockSSHExecutor

func NewMockSSHExecutor() *MockSSHExecutor

NewMockSSHExecutor creates a new MockSSHExecutor with nominal default response.

func (*MockSSHExecutor) Run

func (m *MockSSHExecutor) Run(ctx context.Context, host string, port int, user string, keyPath string, command string, stdout io.Writer, stderr io.Writer) (int, error)

Run simulates command execution using registered responses.

type MockSSHResponse

type MockSSHResponse struct {
	Stdout   string
	Stderr   string
	ExitCode int
	Delay    time.Duration
	Err      error
}

MockSSHResponse defines a simulated execution result for testing.

type NodeHistoryStore

type NodeHistoryStore struct {
	FsID      string     `json:"fs_id"`
	Snapshots []Snapshot `json:"snapshots"`
}

NodeHistoryStore captures historical snapshot records for a single fileserver node.

type NodePerformance

type NodePerformance struct {
	FsID              string  `json:"fsID"`
	DisplayID         int     `json:"display_id"`
	DisplayName       string  `json:"display_name"`
	MachineName       string  `json:"machine_name"`
	Address           string  `json:"address"`
	Status            string  `json:"status"`
	WriteMbps         float64 `json:"write_mbps"`
	ReadMbps          float64 `json:"read_mbps"`
	WriteIOPS         float64 `json:"write_iops"`
	ReadIOPS          float64 `json:"read_iops"`
	ErrorRatePct      float64 `json:"error_rate_pct"`
	LatencyWriteP50   float64 `json:"latency_write_p50"`
	LatencyWriteP95   float64 `json:"latency_write_p95"`
	LatencyWriteP99   float64 `json:"latency_write_p99"`
	LatencyReadP50    float64 `json:"latency_read_p50"`
	LatencyReadP95    float64 `json:"latency_read_p95"`
	LatencyReadP99    float64 `json:"latency_read_p99"`
	ActiveConnections int     `json:"active_connections"`
}

NodePerformance holds current throughput, IOPS, and latency stats for a fileserver node.

type NodeRestartParams

type NodeRestartParams struct {
	FsID     string `json:"fs_id"`
	Address  string `json:"address"`
	Host     string `json:"host"`
	Port     int    `json:"port"`
	SSHPort  int    `json:"ssh_port,omitempty"`
	SSHUser  string `json:"ssh_user,omitempty"`
	MetaAddr string `json:"meta_addr"`
	OwnIP    string `json:"own_ip"`
	DataDir  string `json:"data_dir"`
}

NodeRestartParams holds configurable parameters for fileserver process launch.

type NodeResult

type NodeResult struct {
	NodeID     string `json:"node_id"`
	Address    string `json:"address"`
	ExitCode   int    `json:"exit_code"`
	Output     string `json:"output"`
	Error      string `json:"error,omitempty"`
	DurationMs int64  `json:"duration_ms"`
}

NodeResult captures the output and status of a command on a specific node.

type NodeState

type NodeState struct {
	FsID               string             `json:"fsID"`
	DisplayID          int                `json:"displayID"`
	DisplayName        string             `json:"displayName"`
	MachineName        string             `json:"machineName"`
	Address            string             `json:"address"`
	MetricsURL         string             `json:"metricsURL"`
	Status             NodeStatus         `json:"status"`
	LastSeen           int64              `json:"lastSeen"`
	Metrics            *FileserverMetrics `json:"metrics"`
	WriteThroughputBps float64            `json:"writeThroughputBps"`
	ReadThroughputBps  float64            `json:"readThroughputBps"`
	WriteMbps          float64            `json:"writeMbps"`
	ReadMbps           float64            `json:"readMbps"`
	WriteIOPS          float64            `json:"writeIOPS"`
	ReadIOPS           float64            `json:"readIOPS"`
	ErrorRatePct       float64            `json:"errorRatePct"`
	History            *RingBuffer        `json:"-"`
}

NodeState represents the tracked state and latest telemetry of a single fileserver.

type NodeStatus

type NodeStatus string
const (
	StatusOnline   NodeStatus = "online"
	StatusWarning  NodeStatus = "warning"
	StatusDegraded NodeStatus = "degraded"
	StatusCritical NodeStatus = "critical"
	StatusOffline  NodeStatus = "offline"
)

type NodeUserStorage

type NodeUserStorage struct {
	FsID        string `json:"fs_id"`
	DisplayID   int    `json:"display_id"`
	DisplayName string `json:"display_name"`
	MachineName string `json:"machine_name"`
	Address     string `json:"address"`
	UsedBytes   uint64 `json:"used_bytes"`
	QuotaBytes  uint64 `json:"quota_bytes"`
}

type Orchestrator

type Orchestrator struct {
	// contains filtered or unexported fields
}

Orchestrator coordinates SSH command execution across fileserver nodes.

func NewOrchestrator

func NewOrchestrator(server *AdminServer, ssh SSHExecutor, history *CommandHistory, defaultSSHUser, defaultSSHKey, defaultRepoPath string, defaultSSHPort ...int) *Orchestrator

NewOrchestrator creates a new Orchestrator instance.

func (*Orchestrator) Execute

func (o *Orchestrator) Execute(ctx context.Context, req ActionRequest, onEvent func(ActionEvent)) (*CommandRecord, error)

Execute orchestrates command execution across selected nodes in parallel.

func (*Orchestrator) FormatCommand

func (o *Orchestrator) FormatCommand(req *ActionRequest, nodeID string, params *NodeRestartParams) string

FormatCommand generates the exact bash command string for a specific node.

func (*Orchestrator) GetPresets

func (o *Orchestrator) GetPresets() map[string]*NodeRestartParams

GetPresets generates pre-filled configuration parameters for all discovered nodes.

type PerformanceResponse

type PerformanceResponse struct {
	ClusterWriteMbps    float64           `json:"cluster_write_mbps"`
	ClusterReadMbps     float64           `json:"cluster_read_mbps"`
	ClusterWriteIOPS    float64           `json:"cluster_write_iops"`
	ClusterReadIOPS     float64           `json:"cluster_read_iops"`
	ClusterErrorRatePct float64           `json:"cluster_error_rate_pct"`
	Nodes               []NodePerformance `json:"nodes"`
}

PerformanceResponse summarizes cluster and per-node throughput, IOPS, and latencies.

type RemoteSSHExecutor

type RemoteSSHExecutor struct{}

RemoteSSHExecutor executes commands on remote Linux servers using public key SSH authentication.

func NewRemoteSSHExecutor

func NewRemoteSSHExecutor() *RemoteSSHExecutor

NewRemoteSSHExecutor creates a new RemoteSSHExecutor.

func (*RemoteSSHExecutor) Run

func (r *RemoteSSHExecutor) Run(ctx context.Context, host string, port int, user string, keyPath string, command string, stdout io.Writer, stderr io.Writer) (int, error)

Run connects to host:port via SSH and executes command, streaming stdout and stderr.

type RingBuffer

type RingBuffer struct {
	// contains filtered or unexported fields
}

RingBuffer is a fixed-capacity circular buffer of Snapshots. It is safe for concurrent use.

func NewRingBuffer

func NewRingBuffer(size int) *RingBuffer

NewRingBuffer creates a RingBuffer with the given capacity.

func (*RingBuffer) GetAll

func (rb *RingBuffer) GetAll() []Snapshot

GetAll returns all stored snapshots in chronological order (oldest → newest).

func (*RingBuffer) GetLast

func (rb *RingBuffer) GetLast() (Snapshot, bool)

GetLast returns the most recently pushed snapshot, or false if the buffer is empty.

func (*RingBuffer) Push

func (rb *RingBuffer) Push(s Snapshot)

Push adds a snapshot to the ring buffer, overwriting the oldest entry when full.

type SSHExecutor

type SSHExecutor interface {
	Run(ctx context.Context, host string, port int, user string, keyPath string, command string, stdout io.Writer, stderr io.Writer) (int, error)
}

SSHExecutor defines the interface for running commands on remote nodes via SSH.

type SetQuotaPayload

type SetQuotaPayload struct {
	QuotaBytes uint64 `json:"quota_bytes"`
}

type Snapshot

type Snapshot struct {
	Timestamp          int64             `json:"timestamp"`
	Metrics            FileserverMetrics `json:"metrics"`
	WriteThroughputBps float64           `json:"write_throughput_bps"`
	ReadThroughputBps  float64           `json:"read_throughput_bps"`
	WriteMbps          float64           `json:"write_mbps"`
	ReadMbps           float64           `json:"read_mbps"`
	WriteIOPS          float64           `json:"write_iops"`
	ReadIOPS           float64           `json:"read_iops"`
	ErrorRatePct       float64           `json:"error_rate_pct"`
}

Snapshot pairs a Unix timestamp with a metrics reading and calculated rate metrics.

type UserSummary

type UserSummary struct {
	Username       string            `json:"username"`
	HomeFsID       string            `json:"home_fs_id"`
	HomeFsDisplay  string            `json:"home_fs_display"`
	HomeFsMachine  string            `json:"home_fs_machine"`
	HomeFsAddress  string            `json:"home_fs_address"`
	QuotaLimit     uint64            `json:"quota_limit"`
	QuotaUsed      uint64            `json:"quota_used"`
	UsagePercent   float64           `json:"usage_percent"`
	ActiveSessions int               `json:"active_sessions"`
	IsOnline       bool              `json:"is_online"`
	Nodes          []NodeUserStorage `json:"nodes"`
}

type WebSocketHandler

type WebSocketHandler struct {
	// contains filtered or unexported fields
}

WebSocketHandler manages real-time streaming connections for orchestration commands.

func NewWebSocketHandler

func NewWebSocketHandler(orchestrator *Orchestrator, authManager ...*AuthManager) *WebSocketHandler

NewWebSocketHandler creates a new WebSocketHandler.

func (*WebSocketHandler) ServeHTTP

func (h *WebSocketHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP handles incoming WebSocket client connections at /ws/actions.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL