From 71b613371a5758867a510c8723d1f8e2951711df Mon Sep 17 00:00:00 2001 From: Ingo Oppermann Date: Mon, 10 Jul 2023 11:07:24 +0200 Subject: [PATCH] Add debug flag to cluster to disable FFmpeg check --- app/api/api.go | 3 +++ cluster/cluster.go | 24 ++++++++++++++++++------ config/config.go | 1 + config/data.go | 4 +++- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/app/api/api.go b/app/api/api.go index 442e86fe..1bedaf3f 100644 --- a/app/api/api.go +++ b/app/api/api.go @@ -508,6 +508,9 @@ func (a *api) start(ctx context.Context) error { CoreSkills: a.ffmpeg.Skills(), IPLimiter: a.sessionsLimiter, Logger: a.log.logger.core.WithComponent("Cluster"), + Debug: cluster.DebugConfig{ + DisableFFmpegCheck: cfg.Cluster.Debug.DisableFFmpegCheck, + }, }) if err != nil { return fmt.Errorf("unable to create cluster: %w", err) diff --git a/cluster/cluster.go b/cluster/cluster.go index 6968bd9c..af151353 100644 --- a/cluster/cluster.go +++ b/cluster/cluster.go @@ -93,6 +93,10 @@ type Peer struct { Address string } +type DebugConfig struct { + DisableFFmpegCheck bool +} + type Config struct { ID string // ID of the node Name string // Name of the node @@ -109,6 +113,8 @@ type Config struct { IPLimiter net.IPLimiter Logger log.Logger + + Debug DebugConfig } type cluster struct { @@ -166,6 +172,8 @@ type cluster struct { barrierLock sync.RWMutex limiter net.IPLimiter + + debugDisableFFmpegCheck bool } var ErrDegraded = errors.New("cluster is currently degraded") @@ -199,6 +207,8 @@ func New(ctx context.Context, config Config) (Cluster, error) { barrier: map[string]bool{}, limiter: config.IPLimiter, + + debugDisableFFmpegCheck: config.Debug.DisableFFmpegCheck, } if c.config == nil { @@ -1012,12 +1022,14 @@ func (c *cluster) checkClusterNodes() ([]string, error) { return nil, fmt.Errorf("node %s has a different configuration: %w", id, err) } - skills, err := node.CoreSkills() - if err != nil { - return nil, fmt.Errorf("node %s has no FFmpeg skills available: %w", id, err) - } - if !c.skills.Equal(skills) { - return nil, fmt.Errorf("node %s has mismatching FFmpeg skills", id) + if !c.debugDisableFFmpegCheck { + skills, err := node.CoreSkills() + if err != nil { + return nil, fmt.Errorf("node %s has no FFmpeg skills available: %w", id, err) + } + if !c.skills.Equal(skills) { + return nil, fmt.Errorf("node %s has mismatching FFmpeg skills", id) + } } for _, name := range config.Host.Name { diff --git a/config/config.go b/config/config.go index 35669c70..c2b8c211 100644 --- a/config/config.go +++ b/config/config.go @@ -296,6 +296,7 @@ func (d *Config) init() { d.vars.Register(value.NewInt64(&d.Cluster.SyncInterval, 5), "cluster.sync_interval_sec", "CORE_CLUSTER_SYNC_INTERVAL_SEC", nil, "Interval between aligning the process in the cluster DB with the processes on the nodes", true, false) d.vars.Register(value.NewInt64(&d.Cluster.NodeRecoverTimeout, 120), "cluster.node_recover_timeout_sec", "CORE_CLUSTER_NODE_RECOVER_TIMEOUT_SEC", nil, "Timeout for a node to recover before rebalancing the processes", true, false) d.vars.Register(value.NewInt64(&d.Cluster.EmergencyLeaderTimeout, 10), "cluster.emergency_leader_timeout_sec", "CORE_CLUSTER_EMERGENCY_LEADER_TIMEOUT_SEC", nil, "Timeout for establishing the emergency leadership after lost contact to raft leader", true, false) + d.vars.Register(value.NewBool(&d.Cluster.Debug.DisableFFmpegCheck, false), "cluster.debug.disable_ffmpeg_check", "CORE_CLUSTER_DEBUG_DISABLE_FFMPEG_CHECK", nil, "Disable checking for identical FFmpeg versions on all nodes", false, false) } // Validate validates the current state of the Config for completeness and sanity. Errors are diff --git a/config/data.go b/config/data.go index b637b97f..45c30126 100644 --- a/config/data.go +++ b/config/data.go @@ -180,13 +180,15 @@ type Data struct { } `json:"resources"` Cluster struct { Enable bool `json:"enable"` - Debug bool `json:"debug"` Address string `json:"address"` // ip:port Peers []string `json:"peers"` StartupTimeout int64 `json:"startup_timeout_sec" format:"int64"` // seconds SyncInterval int64 `json:"sync_interval_sec" format:"int64"` // seconds NodeRecoverTimeout int64 `json:"node_recover_timeout_sec" format:"int64"` // seconds EmergencyLeaderTimeout int64 `json:"emergency_leader_timeout_sec" format:"int64"` // seconds + Debug struct { + DisableFFmpegCheck bool `json:"disable_ffmpeg_check"` + } `json:"debug"` } `json:"cluster"` }