Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions backend/pkg/config/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ const DefaultMaxDeserializationPayloadSize = 20_480 // 20 KB
type Console struct {
TopicDocumentation ConsoleTopicDocumentation `yaml:"topicDocumentation"`
API ConsoleAPI `yaml:"api"`
OperationTimeouts OperationTimeouts `yaml:"operationTimeouts"`
}

// SetDefaults for Console configs.
func (c *Console) SetDefaults() {
c.TopicDocumentation.SetDefaults()
c.API.SetDefaults()
c.OperationTimeouts.SetDefaults()
}

// RegisterFlags for sensitive Console configurations.
Expand All @@ -45,5 +47,9 @@ func (c *Console) Validate() error {
return fmt.Errorf("failed to validate API config: %w", err)
}

if err := c.OperationTimeouts.Validate(); err != nil {
return fmt.Errorf("failed to validate timeouts config: %w", err)
}

return nil
}
48 changes: 48 additions & 0 deletions backend/pkg/config/operation_timeouts.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright 2024 Redpanda Data, Inc.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.md
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0

package config

import (
"errors"
"time"
)

// OperationTimeouts contains timeout configurations for various Kafka operations
// performed by the console service.
type OperationTimeouts struct {
// ClusterInfo is the timeout applied when fetching broker metadata and log dir
// information to build the cluster overview. A shorter timeout avoids long
// response times when a single broker is temporarily unreachable, but may
// cause incomplete results on slow clusters.
ClusterInfo time.Duration `yaml:"clusterInfo"`

// TopicsOverview is the timeout applied when fetching topic metadata and per-topic
// log dir sizes to build the topics list. A shorter timeout avoids long response
// times when a single broker is temporarily unreachable, but may cause incomplete
// results on slow clusters.
TopicsOverview time.Duration `yaml:"topicsOverview"`
}

// SetDefaults for ConsoleTimeouts.
func (c *OperationTimeouts) SetDefaults() {
c.ClusterInfo = 6 * time.Second
c.TopicsOverview = 5 * time.Second
}

// Validate ConsoleTimeouts.
func (c *OperationTimeouts) Validate() error {
if c.ClusterInfo <= 0 {
return errors.New("console.operationTimeouts.clusterInfo must be a positive duration")
}
if c.TopicsOverview <= 0 {
return errors.New("console.operationTimeouts.topicsOverview must be a positive duration")
}
return nil
}
3 changes: 1 addition & 2 deletions backend/pkg/console/cluster_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"context"
"log/slog"
"sort"
"time"

"github.com/twmb/franz-go/pkg/kmsg"
"golang.org/x/sync/errgroup"
Expand Down Expand Up @@ -53,7 +52,7 @@ func (s *Service) GetClusterInfo(ctx context.Context) (*ClusterInfo, error) {

// We use a child context with a shorter timeout because otherwise we'll potentially have very long response
// times in case of a single broker being down.
childCtx, cancel := context.WithTimeout(egCtx, 6*time.Second)
childCtx, cancel := context.WithTimeout(egCtx, s.cfg.Console.OperationTimeouts.ClusterInfo)
defer cancel()

eg.Go(func() error {
Expand Down
3 changes: 1 addition & 2 deletions backend/pkg/console/topic_overview.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"log/slog"
"sort"
"sync"
"time"
)

// DocumentationState denotes whether topic documentation is available for a certain
Expand Down Expand Up @@ -77,7 +76,7 @@ func (s *Service) GetTopicsOverview(ctx context.Context) ([]*TopicSummary, error

// 3. Get log dir sizes & configs for each topic concurrently
// Use a shorter ctx timeout so that we don't wait for too long if one broker is currently down.
childCtx, cancel := context.WithTimeout(ctx, 5*time.Second)
childCtx, cancel := context.WithTimeout(ctx, s.cfg.Console.OperationTimeouts.TopicsOverview)
defer cancel()

configs := make(map[string]*TopicConfig)
Expand Down
6 changes: 6 additions & 0 deletions docs/config/console.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,12 @@ serde:
# Console settings
#----------------------------------------------------------------------------
console:
# Optional: Configure timeouts for Kafka admin operations.
# operationTimeouts:
# Timeout for fetching broker metadata and log dir sizes (cluster overview).
# clusterInfo: 6s
# Timeout for fetching topic metadata and per-topic log dir sizes (topics list).
# topicsOverview: 5s
topicDocumentation:
enabled: false
# git:
Expand Down