feat: configurable cluster timeout (CLUSTER_TIMEOUT_MIN) and use in TUI backup

This commit is contained in:
2025-11-05 11:53:30 +00:00
parent fa337dfeac
commit 063184ddc9
3 changed files with 11 additions and 1 deletions

View File

@ -353,6 +353,9 @@ export MAX_CORES=16
# Backup settings
export BACKUP_DIR=/var/backups
export COMPRESS_LEVEL=6
# Cluster backup timeout in minutes (controls overall cluster operation timeout)
# Default: 240 (4 hours)
export CLUSTER_TIMEOUT_MIN=240
```
## 🏗️ Architecture

View File

@ -54,6 +54,8 @@ type Config struct {
// Single database backup/restore
SingleDBName string
RestoreDBName string
// Timeouts (in minutes)
ClusterTimeoutMinutes int
}
// New creates a new configuration with default values
@ -129,6 +131,9 @@ func New() *Config {
// Single database options
SingleDBName: getEnvString("SINGLE_DB_NAME", ""),
RestoreDBName: getEnvString("RESTORE_DB_NAME", ""),
// Timeouts
ClusterTimeoutMinutes: getEnvInt("CLUSTER_TIMEOUT_MIN", 240),
}
// Ensure canonical defaults are enforced

View File

@ -88,7 +88,9 @@ type backupCompleteMsg struct {
func executeBackupWithTUIProgress(cfg *config.Config, log logger.Logger, backupType, dbName string, ratio int, reporter *TUIProgressReporter) tea.Cmd {
return func() tea.Msg {
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Minute)
// Use configurable cluster timeout (minutes) from config; default set in config.New()
clusterTimeout := time.Duration(cfg.ClusterTimeoutMinutes) * time.Minute
ctx, cancel := context.WithTimeout(context.Background(), clusterTimeout)
defer cancel()
start := time.Now()