From 063184ddc9bc72fd8cf41f0822c81638febd4882 Mon Sep 17 00:00:00 2001 From: Renz Date: Wed, 5 Nov 2025 11:53:30 +0000 Subject: [PATCH] feat: configurable cluster timeout (CLUSTER_TIMEOUT_MIN) and use in TUI backup --- README.md | 3 +++ internal/config/config.go | 5 +++++ internal/tui/backup_exec.go | 4 +++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8299cd5..9b44b12 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/internal/config/config.go b/internal/config/config.go index 7e71c64..0cd7c37 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -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 diff --git a/internal/tui/backup_exec.go b/internal/tui/backup_exec.go index 677c7d2..5f862b3 100644 --- a/internal/tui/backup_exec.go +++ b/internal/tui/backup_exec.go @@ -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()